I am using ffmpeg/ffprobe v8.1.2 installed from homebrew on MacOS 26.6
ffprobe input.mp4 is similar to this
Duration: 00:30:00.50, start: 0.000000, bitrate: 1200 kb/s
Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1065 kb/s, 24 fps, 24 tbr, 12288 tbn (default)
Metadata:
creation_time : 2023-12-23T01:02:19.000000Z
handler_name : VideoHandler
encoder : Lavc62.28.102 libx265
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 161 kb/s (default)
Metadata:
creation_time : 2023-12-23T01:02:19.000000Z
handler_name : Stereo
I am trying to add to this file: 1) cover image, 2) metadata; for that I use the following 2 commands:
ffmpeg -i input.mp4 -i img.jpg -map 0 -map 1 -c copy -disposition:v:1 attached_pic output1.mp4
## ffprobe gives me then also
# Stream #0:2[0x0]: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn (attached pic)
ffmpeg -i output1.mp4 -map 0 -c copy -movflags +use_metadata_tags \
-metadata publisher="ABC" -metadata title="MyTitle" \
-metadata encoded_by="MeMeMe" -metadata genre="Genre" \
output2.mp4
However, the result is that when I add the metadata then the image is gone when checked again with ffprobe. If I perform the actions in the opposite order, then I have image in stream 0:2, but then metadata gets mostly deleted.
I've tried adding image using mp4art and AtomicParsley in conjunction with ffmepg, but result is basically the same. I also tried all of this as one command, but if +use_metadata_tags is present then the image doesn't get saved, that's why I separated all of this into separate commands hoping that in 2 steps this would not interfere. I've tried adding -c:v:1 mjpeg as advised by AI, but to no avail.
Is it possible to add both metadata and cover image using ffmpeg?
I am looking for a solution which would ideally use ffmpeg only, or a simple command line tools. I don't want to use Python or any other language, as I don't know it. I'd like to stay within zsh and some commonly available free tools for processing mp4 video files.