--lavfi-complex drops metadata when combining multiple video files
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
- mpv version: 0.34.0
- Source of the mpv binary: shinchiro Windows build
For example, the following command:
mpv --lavfi-complex='[vid1] [vid2] vstack [vo]' hdr1.mp4 --external-file=hdr2.mp4
Will drop metadata associated with the video streams. In particular any metadata related to HDR, such as colormatrix, primaries or gamma will be dropped, even if both streams use the same values for these properties. The logs show a [vf] output of auto/auto/auto/auto/auto where e.g. bt.2020-ncl/bt.2020/pq/limited/auto would be expected. As a result HDR video is shown as if it was SDR, and obviously looks wrong.
This can be worked around by reinstating the metadata manually:
--vf=format=colormatrix=bt.2020-ncl:colorlevels=limited:primaries=bt.2020:gamma=pq
But that is tedious, error-prone, and will not adapt to variations in the video streams used.
I found a similar ffmpeg ticket, which was closed with the rationale that since there could be multiple inputs, it's not possible to know which one to extract the metadata from. This strikes me as a bit defeatist (clearly lavfi could be smart enough to pass through the metadata if it's identical in both inputs of a filter), but whatever.
In mpv, the command line interface makes somewhat of a de facto distinction between the "main file" and "external files". I wonder if it would make sense to use metadata from the main file by default in this case. Clearly that won't be correct in all cases but that seems more useful than giving up and just using some random SDR default.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported command with --lavfi-complex, using the two HDR video inputs described in the issue, and inspect the resulting video metadata. Trace how metadata is selected or discarded when the lavfi graph combines streams; done means preserving appropriate HDR metadata instead of producing auto/auto/auto/auto/auto defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100