Я использую FFmpeg для наложения ряда изображений на видео, но в некоторых случаях на некоторых видео MP4 это не удается (но иногда это работает отлично).  Моя команда выдает ошибку вроде:

Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

Моя команда ffmpeg приведена ниже:

ffmpeg -y -i myvideo.mp4 -loop 1 -i img_%d.png -strict -2 -filter_complex [0:v][1:v]overlay=39:54:shortest=1:enable='between(t,0,4)' -codec:a copy Preview.mp4 



 WARNING: linker: /data/data/com.benzatine.videoeffects/app_bin/ffmpeg  has text relocations. This is wasting memory and prevents security 

hardening. Please fix.
     ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 4.9 (GCC) 20140827 (prerelease)
     configuration:
     --enable-cross-compile --cross-prefix=i686-linux-android- --target- os=linux --arch=x86 --cpu=x86 --disable-doc --disable-ffplay
     --disable-ffprobe --disable-ffserver --disable-symver --disable-debug --disable-everything --enable-protocol=pipe 
     --enable-protocol=file --enable-protocol=tcp --enable-static --enable-filter=scale --enable-filter=crop --enable-filter=transpose 
 --enable-filter=overlay --enable-encoder=gif --enable-decoder=gif --enable-muxer=gif --enable-demuxer=gif --enable-filter=palettegen 
 --enable-filter=paletteuse --enable-encoder=mpeg4 --enable-decoder=mpeg4 --enable-demuxer=rawvideo --enable-decoder=rawvideo --enable-muxer=image2 
 --enable-muxer=image2pipe --enable-muxer=mjpeg --enable-encoder=mjpeg --enable-encoder=png --enable-demuxer=image2 --enable-demuxer=image2pipe
 --enable-demuxer=mjpeg --enable-decoder=mjpeg --enable-decoder=png --enable-muxer=webm --enable-encoder=libvpx_vp8 --enable-demuxer=matroska
 --enable-decoder=libvpx_vp8 --enable-libx264 --enable-gpl --enable-muxer=mp4 --enable-encoder=libx264 --enable-demuxer=mov --enable-decoder=h264
 libavutil      55. 17.103 / 55. 17.103
 libavcodec     57. 24.102 / 57. 24.102
 libavformat    57. 25.100 / 57. 25.100
 libavdevice    57.  0.101 / 57.  0.101
 E/ERROR(3219):   libavfilter     6. 31.100 /  6. 31.100
 libswscale      4.  0.100 /  4.  0.100
 libswresample   2.  0.101 /  2.  0.101
 libpostproc    54.  0.100 / 54.  0.100
 Guessed Channel Layout for  Input Stream #0.1 : mono
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/VideoStikers/myvideo.mp4':
 Metadata:
 major_brand     : mp42
 minor_version   : 0
 compatible_brands: isommp42
 creation_time   : 2016-03-02 09:37:42
 Duration: 00:00:04.16, start: 0.000000, bitrate: 900 kb/s
 Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 320x240, 97 kb/s, SAR 1:1 DAR 4:3, 16.26 fps, 24.67 tbr, 90k tbn, 180k tbc (default)
 Metadata:
 rotate          : 90
 creation_time   : 2016-03-02 09:37:4
 handler_name    : VideoHandle
 Side data:
 displaymatrix: rotation of -90.00 degrees
 Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, 1 channels, 12 kb/s (default)
 Metadata:
 creation_time   : 2016-03-02 09:37:42
 handler_name    : SoundHandle
 Input #1, image2, from '/storage/emulated/0/VideoStikers/02/img_%d.png':
 Duration: 00:00:01.00, start: 0.000000, bitrate: N/A
 Stream #1:0: Video: png, rgba(pc), 108x98, 25 fps, 25 tbr, 25 tbn, 25 tbc
 [libx264 @ 0xf6827000] using SAR=1/1
 [libx264 @ 0xf6827000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
 [libx264 @ 0xf6827000] profile High, level 1.3
 [libx264 @ 0xf6827000] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
 [mp4 @ 0xf685c000] Could not find tag for codec amr_nb in stream #1, codec not currently supported in container
 Output #0, mp4, to '/storage/emulated/0/VideoStikers/PreviewVideoStikers/Preview.mp4':
 Metadata:
 major_brand     : mp42
 minor_version   : 0
 compatible_brands: isommp42
 encoder         : Lavf57.25.100
 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 240x320 [SAR 1:1 DAR 3:4], q=-1--1, 24.67 fps, 18944 tbn, 24.67 tbc (default)
 Metadata:
 encoder         : Lavc57.24.102 libx264
 Side data:
 unknown side data type 10 (24 bytes)
 Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, 12 kb/s (default)
 Metadata:
 creation_time   : 2016-03-02 09:37:42
 handler_name    : SoundHandle
 Stream mapping:
 Stream #0:0 (h264) -> overlay:main
 Stream #1:0 (png) -> overlay:overlay
 overlay -> Stream #0:0 (libx264)
 Stream #0:1 -> #0:1 (copy)
 Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
: 1

Кто-нибудь может предложить мне правильное решение?

1 ответ1

0

Похоже, что ffmpeg MOV muxer не поддерживает amr_nb в mp4, но попробуйте

ffmpeg -y -i myvideo.mp4 -loop 1 -i img_%d.png -strict -2 \
-filter_complex [0:v][1:v]overlay=39:54:shortest=1:enable='between(t,0,4)' \
-atag samr -copy_unknown -c:a copy Preview.mp4 

Если не,

ffmpeg -y -i myvideo.mp4 -loop 1 -i img_%d.png -strict -2 \
-filter_complex [0:v][1:v]overlay=39:54:shortest=1:enable='between(t,0,4)' \
-c:a aac Preview.mp4 

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .