0

I can export a frame as .png from, say 1.2 seconds from the beginning of the movie (=1 second and 5 or 6 frames with 25 or 30 fps input):

ffmpeg -ss 1.2 -i input.mp4 -frames:v 1 image.png

And then losslessly use that .png as a custom Poster Frame in that movie:

ffmpeg -i input.mp4 -i image.png -map 0 -map 1 -c copy -disposition:v:1 attached_pic output.mp4

Question: how can I pipe those two commands together?

1 Answer 1

0

Generate the poster frame in the same command:

ffmpeg -i input.mp4 -ss 1.2 -i input.mp4 -map 0 -map 1:v:0 -c copy -c:v:1 png -filter:v:1 trim=end_frame=1,setpts=0 -fps_mode:v:1 passthrough -disposition:v:1 attached_pic output.mp4

3
  • Thanks, that works with ffmpeg 6.1.1 with .mp4 and .m4v. But that does not work with .mov: macOS 14 QuickTime Player.app displays the old Poster Frame and exiftool does not report any ItemList:CoverArt in the output .mov. With .mov input and .mp4 or .m4v output it works. Apple's Compressor.app 4.7 can insert Poster Frame also to the re-encoded .mov but that is lossy. p.s. thanks for the info about that workflow with ffmpeg. I am still curious how to pipe such commands. My attempts to do so produced at best only the output of the 1st command, which I could not pipe to the 2nd command.
    – wywh
    Apr 29 at 5:33
  • A workaround for .mov is to extract .png and insert it with exiftool: ffmpeg -ss 1.2 -i input.mov -frames:v 1 image-%03d.png and exiftool -P -overwrite_original '-CoverArt<=image-001.png' input.mov With 4K 10-bit HLG .mov the exported .png might be too large (~44 MB) but that should be patched in exiftool 12.85. Is it possible to reduce the size ffmpeg exports? Or maybe use .jpg instead? link
    – wywh
    Apr 29 at 20:14
  • png bloats the movie so it might be better to use 'mjpeg' instead 'png' in the Gyan's and my commands above. For example, in one movie the 44 MB 3840x2160 Deep Color png could be substituted by just 0.5 MB 3840x2160 True color jpg. Apple's Compressor 4.7 also uses .jpg in its CoverArt Poster Frames.
    – wywh
    Apr 30 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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