0

I would like to put some videos on iPAd with Cover/Thumbnail image

I can do that in two steps. That seems to work, but I'm not able to encode and add image at the same time. (Win 10 and the latest ffmpeg download for Windows 64bit)

works:

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"

This doesn't work

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

nor

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

Using PNG filter causes this error

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!

Using copy this

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

Map the image first, that way you know which absolute stream index in the output has the image.

Use

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
1
  • Thanks, it works! I don't understand why - I thought I'm referrencing the stream exactly via -c:v:1 copy – Hurda May 11 '20 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.