使用ffmpeg自定义视频裁剪

时间:2018-03-29 05:51:56

标签: video ffmpeg video-processing

我正在使用writingminds ffmpeg库来裁剪视频并通过自定义选择器获取高度,宽度,x和y坐标。 我正在使用以下代码进行裁剪:

 String[] cmd = {"-i", path, "-filter:v", "crop=" + valuewidth + ":" + 
 valueheight + ":" + valuex + ":" + valuey, "-c:a", "copy", videoPath};
 execFFmpegBinary(cmd);

在调试时,我收到了这个日志:

03-29 11:15:36.069 198-9920/? I/OMXCodec: [OMX.qcom.video.decoder.avc] Crop 
rect is 368 x 272 @ (0, 0)
03-29 11:15:36.209 198-684/? E/MediaPlayerService: WFD client is not created 
03-29 11:15:36.229 198-9925/? I/OMXCodec: [OMX.qcom.video.decoder.avc] Crop 
rect is 368 x 272 @ (0, 0)
03-29 11:15:36.359 15596-15596/zoptal.com.appegovidexample 
D/CropperActivity: ffmpeg : correct Loaded
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 
'/storage/emulated/0/WhatsApp/Media/WhatsApp Animated Gifs/VID-20170318- 
WA0000.mp4':

Metadata:

major_brand     : mp42

minor_version   : 1

compatible_brands: mp41mp42isom

creation_time   : 2017-03-10 14:32:13

Duration: 00:00:05.00, start: 0.080000, bitrate: 206 kb/s

  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,  
  /smpte170m/bt709), 368x272, 203 kb/s, 14 fps, 100 tbr, 600 tbn, 1200 tbc 
  (default)

  Metadata:

 creation_time   : 2017-03-10 14:32:13

 handler_name    : Core Media Video

 [Parsed_crop_0 @ 0x41e47550] Invalid too big or non positive size for width 
 '630' or height '592'

 [Parsed_crop_0 @ 0x41e47550] Failed to configure input pad on Parsed_crop_0

 Error opening filters!
 03-29 11:17:32.253 15596-15596/zoptal.com.appegovidexample 
  D/CropperActivity: Finished command : ffmpeg [Ljava.lang.String;@427f0d48
  03-29 11:17:32.273 15596-15596/zoptal.com.appegovidexample E/MediaPlayer: 
  Unable to create media player

编辑: 我尝试通过在命令中添加“scale = 1280:720”来缩放视频(基于视频的默认裁剪矩形为368 x 272 @(0,0))。现在,我收到此错误:

 Metadata:

 creation_time   : 2017-03-10 14:32:13

 handler_name    : Core Media Video

 [NULL @ 0x41b65c80] Unable to find a suitable output format for 
 'crop=692:745:115:115'

 crop=692:745:115:115: Invalid argument

0 个答案:

没有答案