我想将一些视频和封面/缩略图放在 iPad 上
我可以分两步完成。这似乎可行,但我无法同时编码和添加图像。(Win 10 和适用于 Windows 64 位的最新 ffmpeg 下载)
作品:
ffmpeg -i "$1" -map 0
-c:v:0 libx264 -vprofile main -level 3.1 -preset medium -crf 23 -x264-params ref=4
-c:a:0 copy -movflags +faststart "dp-$1".mp4
ffmpeg -i "$1" -i "$1.png" -map 1 -map 0 -c copy -disposition:0 attached_pic "dp-$1"
这不管用
ffmpeg -i "$1" -i "$1.png" -map 0 -map 1
-c:V:0 libx264 -vprofile main -level 3.1 -preset medium -crf 23 -x264-params ref=4
-c:a:0 copy -movflags +faststart
-c:v:1 png -disposition:1 attached_pic "dp-$1".mp4
也不
ffmpeg -i "$1" -i "$1.png" -map 0 -map 1
-c:V:0 libx264 -vprofile main -level 3.1 -preset medium -crf 23 -x264-params ref=4
-c:a:0 copy -movflags +faststart
-c:v:1 copy -disposition:1 attached_pic "dp-$1".mp4
使用 PNG 滤镜会导致此错误
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (copy)
Stream #1:0 -> #0:2 (png (native) -> png (native))
Press [q] to stop, [?] for help
[mpeg4 @ 00000205d98d25c0] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
[libx264 @ 00000205d98cf3c0] using SAR=1/1
[libx264 @ 00000205d98cf3c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000205d98cf3c0] profile Main, level 3.1, 4:2:0, 8-bit
[libx264 @ 00000205d98cf3c0] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=4 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 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=23 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
[png @ 00000205d98d1cc0] [Eval @ 0000006f8f1fe3f0] Undefined constant or missing '(' in 'main'
[png @ 00000205d98d1cc0] Unable to parse option value "main"
[png @ 00000205d98d1cc0] Error setting option profile to value main.
Error initializing output stream 0:2 -- Error while opening encoder for output stream #0:2 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
使用复制此
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (copy)
Stream #1:0 -> #0:2 (copy)
Press [q] to stop, [?] for help
[mpeg4 @ 0000016892e30f00] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
[libx264 @ 0000016892e2f3c0] using SAR=1/1
[libx264 @ 0000016892e2f3c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000016892e2f3c0] profile Main, level 3.1, 4:2:0, 8-bit
[libx264 @ 0000016892e2f3c0] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=4 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 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=23 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 @ 0000016892e2dbc0] Could not find tag for codec ac3 in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
答案1
首先映射图像,这样您就知道输出中的哪个绝对流索引具有图像。
使用
ffmpeg -i "$1" -i "$1.png" -map 1 -map 0
-c copy -c:v:1 libx264 -profile:v:1 main -level 3.1 -preset medium -crf 23 -x264-params ref=4
-c:a:0 copy -disposition:0 attached_pic -movflags +faststart "dp-$1".mp4