Обрезать видео с поворотом с помощью ffmpg

1281
user2528012

Я работаю над приложением для Android, которое обрезает видео с помощью ffmpg. Это отлично работает для всех видео, но не для видео, записанных камерой телефона. Я заметил, что у всех этих видов видео параметр «rotate» больше 0 в метаданных видеопотока. Вот команда ffmpg complete

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 

Это вывод вышеуказанной команды

Ошибка при открытии кодировщика для выходного потока # 0: 0 - возможно, неверные параметры, такие как bit_rate, скорость, ширина или высота

и эта ссылка на вывод отчета ffmpeg

Если я пытаюсь указать кодеки с помощью следующей команды

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 

Тогда ошибка изменится на следующую

[NULL @ 0x4115d960] Невозможно найти подходящий выходной формат для 'crop = 280: 70: 176: 0' I: crop = 280: 70: 176: 0: неверный аргумент

и эта ссылка на вывод отчета ffmpeg

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 

Любая помощь будет оценена.

2
Добавьте `-report` и запустите. Вставить сгенерированный лог-файл. Gyan 8 лет назад 0
@Mulvya обновил мой вопрос с помощью файлов журнала отчетов user2528012 8 лет назад 0

2 ответа на вопрос

1
Gyan

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 
Я вижу, что вы обновили кодек до правильного значения, но эта команда также выдает ту же ошибку. Это выглядит для меня проблемой с вращением видео, я попытаюсь применить фильтр поворота, затем обрезать и увидеть результаты. user2528012 8 лет назад 0
Я не заметил, но, как указал LN, ваша версия слишком старая. Обновите это сначала. Gyan 8 лет назад 0
1
LordNeckbeard

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.

Похожие вопросы