1

I am working on android application that crop videos using ffmpg,This works fine for all videos but not for videos recorded by phone camera,I have noticed that all these kind of videos has "rotate" parameter greater than 0 in video stream meta data. Here is ffmpg complete command

ffmpeg -y -i /storage/VID_20.3gp -vf crop=280:70:176:0 -c:a copy -threads 5 -strict experimental -preset veryslow /storage/VID_203.3gp

This is output of above command

Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

and this link to output of ffmpeg report

If I try to specify the codecs using following command

ffmpeg -y -i /storage/VID_20.3gp -codec:v x264 -vf crop=280:70:176:0 -c:a copy -threads 5 -strict experimental -preset veryslow /storage/VID_203.3gp

Then error changes to following

[NULL @ 0x4115d960] Unable to find a suitable output format for 'crop=280:70:176:0' I: crop=280:70:176:0: Invalid argument

and this link to output of ffmpeg report

ffmpeg started on 2016-01-13 at 18:48:54
Report written to "ffmpeg-20160113-184854.log"
Command line:
/data/data/fnzstudios.com.videocrop/app_bin/ffmpeg -y -i /storage/sdcard0/DCIM/Camera/VID_20160113_101209.3gp "-codec:v x264" -vf "crop=280:70:176:0" -c:a copy -threads 5 -strict experimental -preset veryslow -report /storage/sdcard0/croppedvideos/VID_20160113_101209.3gp
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 22 2014 12:52:34 with gcc 4.6 20120106 (prerelease)
  configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/home/n8fr8/dev/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/home/n8fr8/dev/android/ndk/platforms/android-16/arch-arm --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie' --extra-ldflags='-L../x264 -fPIE -pie' --enable-version3 --enable-gpl --disable-doc --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filters --enable-avresample --enable-libfreetype --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-libx264 --enable-zlib
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4211b3d0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4211b3d0] ISO: File Type Major Brand: 3gp4
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4211b3d0] File position before avformat_find_stream_info() is 1384931
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4211b3d0] All info found
rfps: 8.083333 0.010260
rfps: 8.166667 0.001840
rfps: 8.250000 0.000241
rfps: 8.250000 0.000241
rfps: 8.333333 0.005463
rfps: 8.333333 0.005463
rfps: 8.416667 0.017508
rfps: 16.333333 0.007358
rfps: 16.416667 0.000750
rfps: 16.416667 0.000750
rfps: 16.500000 0.000963
rfps: 16.500000 0.000963
rfps: 16.583333 0.007997
rfps: 16.583333 0.007997
rfps: 24.500000 0.016556
rfps: 24.583333 0.004937
rfps: 24.666667 0.000141
rfps: 24.666667 0.000141
rfps: 24.750000 0.002166
rfps: 24.750000 0.002166
rfps: 24.833333 0.011012
rfps: 32.750000 0.012804
rfps: 32.833333 0.002998
rfps: 32.833333 0.002998
rfps: 32.916667 0.000013
rfps: 32.916667 0.000013
rfps: 33.000000 0.003850
rfps: 33.083333 0.014509
rfps: 41.000000 0.009534
rfps: 41.000000 0.009534
rfps: 41.083333 0.001540
rfps: 41.083333 0.001540
rfps: 41.166667 0.000367
rfps: 41.166667 0.000367
rfps: 41.250000 0.006016
rfps: 41.333333 0.018486
rfps: 49.166667 0.019750
rfps: 49.250000 0.006746
rfps: 49.250000 0.006746
rfps: 49.333333 0.000563
rfps: 49.333333 0.000563
rfps: 49.416667 0.001202
rfps: 49.500000 0.008663
rfps: 57.416667 0.015630
rfps: 57.416667 0.015630
rfps: 57.500000 0.004438
rfps: 57.500000 0.004438
rfps: 57.583333 0.000068
rfps: 57.583333 0.000068
rfps: 57.666667 0.002519
rfps: 57.666667 0.002519
rfps: 57.750000 0.011791
rfps: 57.750000 0.011791
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4211b3d0] File position after avformat_find_stream_info() is 548036
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/sdcard0/DCIM/Camera/VID_20160113_101209.3gp':
  Metadata:
    major_brand     : 3gp4
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2016-01-13 05:12:09
  Duration: 00:00:05.39, start: 0.000000, bitrate: 2052 kb/s
    Stream #0:0(eng), 21, 1/90000: Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1935 kb/s, 8.21 fps, 32.92 tbr, 90k tbn, 300 tbc
    Metadata:
      rotate          : 90
      creation_time   : 2016-01-13 05:12:09
      handler_name    : VideoHandle
    Stream #0:1(eng), 143, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2016-01-13 05:12:09
      handler_name    : SoundHandle
    [NULL @ 0x421230a0] Unable to find a suitable output format for 'crop=280:70:176:0'
crop=280:70:176:0: Invalid argument

Any help will be appreciated.

2
  • Add -report and run. Paste generated logfile.
    – Gyan
    Commented Jan 13, 2016 at 12:36
  • @Mulvya updated my question with report log-files Commented Jan 13, 2016 at 14:03

2 Answers 2

1

When output video codec isn't specified, FFmpeg autoselects H.263 for 3GP container, and

Valid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152.

Use H.264

ffmpeg -y -i /storage/VID_20.3gp -c:v libx264 -vf crop=280:70:176:0 -c:a copy -threads 5 -strict experimental -preset veryslow /storage/VID_203.3gp
2
  • I see that you have updated the codec to correct value,but this command is also producing the same error.This looks to me issue with video Rotation,I will try to apply the rotate filter then crop and see the results. Commented Jan 13, 2016 at 18:33
  • I didn't notice, but as LN pointed out, your version is way too old. Update that first.
    – Gyan
    Commented Jan 14, 2016 at 8:37
1

You have multiple issues:

  • ffmpeg version 0.11.1 is absolutely ancient and unsupported. You need to upgrade. You're wasting your (and our) time trying to use it and there may be security implications using it.

  • There is no encoder named x264. Use libx264.

  • Remove the quotes surrounding -codec:v.

  • Recent ffmpeg will automatically rotate the video and remove the rotate metadata, so that is another reason to upgrade.

  • Recent ffmpeg has major improvements to the AAC encoder.

  • Please don't use -report: the increased verbosity is usually more annoying than helpful. Just provide the default console output.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .