-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
There have been many requests for preserving metadata, or some metadata getting lost when exporting. In my experience it seems to happen more often in older or more obscure codecs. Some related issues:
- When I export the split files of a file in 4:3 AR, the aspect ratio have changed to 16:9 #1336
- Extremely high frame rate in data after cutting #1096
- MKV Framerate changed #757
- Exporting MKV loses aspect ratio #1959
- Please preserve original metadata #99
- MKV FrameCount metadata not updated #756
- Trimming VIRB360 video loses the projection information #169
- LC is discarding the language tag from chapters in .MKV files #991
Although it seems there is no silver bullet, I will gather and summarise challenges and possible options here.
Default ffmpeg -i mp4 -c copy out.mp4
This seems to copy only some metadata, like some timestamps (both global and per-track).
ffmpeg -map_metadata X
Where X is the file input index. Typically -map_metadata 0
for mapping metadata from the first input to the output.
LosslessCut uses this by default when cutting (also for merge, but only if keep original metadata when merging
is enabled).
ffmpeg -movflags use_metadata_tags
If you enable the Preserve all MP4/MOV metadata
, it will use this flag. This flag will make ffmpeg copy additional tags (for MOV/MP4 only). However it will copy them into a different location than the source file. Example tag shown in exiftool
:
- Original:
MOV-Movie-UserData-Meta-ItemList:Comment: Test Comment
- Output:
MOV-Movie-UserData-Meta-Keys:Comment: Test Comment
- Original:
MOV-Movie-UserData-Meta-ItemList-iTunesInfo:CUSTOM1: Old File Name
- Output:
MOV-Movie-UserData-Meta-Keys:CUSTOM1: Old File Name
See #853 (comment)
Problems:
- This causes players like VLC to no longer show the metadata (although ffprobe will show it).
- Importing the resulting file into Apple's iTunes it will break the edit metadata in iTunes, so one must be careful with enabling this option.
- Also breaks other editors: All exported videos have errors due to incorrect ffmpeg setting #402
Copy tags with exiftool
See branch https://github.com/mifi/lossless-cut/tree/exiftool-integration
Although not yet implemented in LosslessCut (feb 2022), this command will copy some more useful metadata than -movflags use_metadata_tags
, for example:
- 360 spherical projection (e.g.
MOV-Movie-Track-SphericalVideoXML:ProjectionType: equirectangular
), see Trimming VIRB360 video loses the projection information #169 (comment) works in VLC after copy. - UserData will be copied to the correct location and works in VLC after copy (e.g.
MOV-Movie-UserData-Meta-ItemList:Comment: Test Comment
), see Metadata inconsistency and request #853 (comment)
However, exiftool
will also skip some tags that ffmpeg -movflags use_metadata_tags
will copy:
MOV-Movie-UserData-Meta-ItemList-iTunesInfo:CUSTOM1: Old File Name
- completely dropped, see Metadata inconsistency and request #853 (comment)
Here is the command:
exiftool -tagsFromFile original.mp4 -all:all -overwrite_original with-exiftool.mp4
Exiftool can also give other benefits:
- view/edit all exiftool metadata as strings
- view and modify all dates
- view gps data on a map
- modify gps data
- preserve some metadata that ffmpeg does not copy (but also lose some other metadata)
- 360 spherical projection seems to be preserved
- gps preserved?
- option to export all exiftool metadata to separate file?
- set "encoder" meta to "lavf-xx/LosslessCut" (currently hardcoded by ffmpeg and not possible to override)
See also #2096