exiftool semi-corrupts some movies when inserting CoverArt .png

Started by wywh, April 29, 2024, 11:41:51 AM

Previous topic - Next topic

wywh

I tried to make custom Poster Frames to movies because some default frames are not so good.

It works OK for .mp4 and .m4v with ffmpeg 6 (here a frame 1.2 seconds from the beginning of the movie):

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
But for some reason it does not work for .mov: macOS 14 QuickTime Player.app displays the old Poster Frame and exiftool does not report any ItemList:CoverArt in the output .mov.

https://video.stackexchange.com/questions/37412/add-custom-poster-frame-to-a-movie-with-ffmpeg-by-combining-two-commands-with-a

A workaround for .mov is to extract .png and use exiftool to insert it as Poster Frame:

ffmpeg -ss 0.4 -i input.mov -frames:v 1 image-%03d.png
exiftool -P -overwrite_original -api LargeFileSupport=1 '-CoverArt<=image-001.png' input.mov
-> BUT for some strange reason exiftool 12.84 seems to semi-corrupt some of my test movies (the movie plays OK but the metadata is no longer correctly displayed). Most movies behave OK, even the very large ones.

The culprit might be some (not all) 4K HEVC 10-bit HLG .mov files. The sample movie has a very truncated exiftool output (below) and with an added -m switch there are many screens of gibberish (some movies display that without -m):

exiftool -a -G1 -s -api LargeFileSupport=1 output.mov
[ExifTool]      ExifToolVersion                 : 12.84
[ExifTool]      Warning                         : [Minor] Skipping 'moov' atom > 32 MiB
[System]        FileName                        : output.mov
[System]        Directory                       : .
[System]        FileSize                        : 48 MB
[System]        FileModifyDate                  : 2022:06:01 12:00:00+03:00
[System]        FileAccessDate                  : 2024:04:29 17:42:00+03:00
[System]        FileInodeChangeDate             : 2024:04:29 18:22:24+03:00
[System]        FilePermissions                 : -rw-r--r--
[File]          FileType                        : MOV
[File]          FileTypeExtension               : mov
[File]          MIMEType                        : video/quicktime
[QuickTime]     MajorBrand                      : Apple QuickTime (.MOV/QT)
[QuickTime]     MinorVersion                    : 0.2.0
[QuickTime]     CompatibleBrands                : qt
[QuickTime]     MediaDataSize                   : 4084745
[QuickTime]     MediaDataOffset                 : 43646005

If I clumsily copy a Poster Frame from a .mp4 to a problematic .mov, then it works OK without those issues:

exiftool -m -overwrite_original -api LargeFileSupport=1 -tagsFromFile output.mp4 '-ItemList:CoverArt' 2022-0612-1923-17.mov
The original 200 MB .mov where metadata has been very modestly edited behaves the same (iPhone 13 Pro, iOS 15.5). I can email that if needed.

Attached is a clip trimmed with Avidemux (input.mov), ffmpeg extracted image (image-001.png) and the input.mov after exiftool has inserted the image to it (output.mov).

https://www.dropbox.com/scl/fi/3f340el4hoshcya3vbvp2/CoverArt_movie.zip?rlkey=lv6kwfzsdtmqosuhwsaxl01m1&dl=0

The .png that ffmpeg extracts is quite huge (43.6 MB, 3840x2160 etc) so it bloats the movie. Is it too big for this purpose? Is it better to use .png or .jpg for this?

edit: it is possible to revert that issue with:

exiftool -CoverArt= output.mov
- Matti

Phil Harvey

Hi Matti,

Thanks.  One of the data consistency checks would break if the data size for this tag was larger than 16 MB.  I'll patch this in 12.85.  But you will still have to use the -m switch if the 'moov' atom is larger than 32 MB.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

wywh

Yes, the culprit was adding too large .png as CoverArt. It might be better to use .jpg instead .png for this so the movies do not bloat.

For example, in that offending movie the 44 MB 3840x2160 Deep Color .png could be substituted by exporting just 0.5 MB 3840x2160 True color .jpg from ffmpeg. Apple's Compressor 4.7 also uses .jpg in CoverArt Poster Frames.

- Matti