mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
26k stars 1.25k forks source link

Missing HDR format (Dolby Vision) on the generated file #1031

Closed the123blackjack closed 1 year ago

the123blackjack commented 2 years ago

I presume the Dolby vision metadata is lost during the merge.

This is observed on the version 3.42.0 in windows platform.

When i later checked with cut operation its observed the same.

Obviously i have flagged to keep the metadata for mp4/mov

(*Not sure if it is a bug but the export options for merge operation either doesnt show up or doest ask to keep the metadata, but it appears only on cut operation - will have to log a separate issue for this)

the123blackjack commented 2 years ago

Also i am not sure how the missing DV tag affects playback in players

mifi commented 2 years ago

Did you try with the "Experimental flag" enabled? See also #329 - I believe iPhone videos are also dolby vision, judging from discussion here: https://trac.ffmpeg.org/ticket/8632

the123blackjack commented 2 years ago

Original Files: image

Merged By Lossless Cut (with or withour experimental flag) image

the123blackjack commented 2 years ago

This is Iphone 12, 13 ++ files with Dolby vision HDR. Post concatenation / merging the Dolby Vision Metadata is stripped off leaving only as HLG

mifi commented 2 years ago

Ok. It's definitely an ffmpeg issue. you can confirm it by doing the same with ffmpeg from the command line. Hopefully they will fix it in the future

the123blackjack commented 2 years ago

Yes for sure even on the command line this issue was reproduced as is an issue with ffmpeg

mifi commented 2 years ago

@ValZapod I thought -strict experimental is a superset of -strict unofficial? https://superuser.com/a/543593/658247

mifi commented 2 years ago

I'm not sure what you mean. Do you mean that unofficial will preserve Dolby Vision HDR format, while experimental will not? Could you show an example file to reproduce this?

the123blackjack commented 2 years ago

@mifi @ValZapod There is some good news with some extensive testing with the -strict experimental flag ffmpeg is maintaining Dolby Vision Metadata but only if i output it to mp4 container. I was actually outputting to .mov container as the source file are .mov / iphone videos.

@mifi in lossless cut can we have an enhancement to have output / merge to .mp4 / .mkv... well as it is still lossless our philosophy but with just a container change

Command i ran : ffmpeg -f concat -safe 0 -i VideoList.txt -n -c copy -strict experimental output.mp4 2> Output.log

the123blackjack commented 2 years ago

@mifi is this error serious and how to mitigate this.

This is for the files which i am trying to concat. The files are of same timebase and same audio sample

So what i am planning is if you enhance the merge operation to custom output as mp4 in losslesscut and then the below scenario is handled within lossless cut its a quick win for me

Also how to see ffmpeg logs in Losslesscut

[mp4 @ 000001d82f5b3480] Non-monotonous DTS in output stream 0:0; previous: 5311072, current: 5304544; changing to 5311073. This may result in incorrect timestamps in the output file. [mp4 @ 000001d82f5b3480] Non-monotonous DTS in output stream 0:0; previous: 5311073, current: 5304864; changing to 5311074. This may result in incorrect timestamps in the output file.

mifi commented 2 years ago

@the123blackjack that’s good news! Losslesscut already lets the user choose output format, so they can change it to mp4 to make it work. But maybe we should show them a warning if they try to use .mov and the input file is dolby? Not sure how to detect dolby using ffprobe but im sure it’s possible

the123blackjack commented 2 years ago

1) ffprobe does return the DOVI value in Side Date so we are good for detection and to display a warning for all iphone users :) @mifi Side data: DOVI configuration record: version: 1.0, profile: 8, level: 6, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 4

2) Unfortunately the output from Losslesscut is still stripping away the Side Data even after selecting .mp4

The command i run successfully is the below for which i am getting with Dolby Vision Side Data / Meta data is the below:

ffmpeg -f concat -safe 0 -i VideoList.txt -n -c copy -strict experimental output.mp4 2> Output.log

On the FFMPEG Version :

ffmpeg version n5.0-4-g911d7f167c-20220310 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 11.2.0 (crosstool-NG 1.24.0.533_681aaef)

mifi commented 2 years ago
  1. Cool!
  2. Did you enable the experimental setting in losslesscut?
the123blackjack commented 2 years ago

Yes it is enabled, however still i am unable to get the metadata in LosslessCut. Is this the FFMEG Version of the backend command being used by you?

mifi commented 2 years ago

losslesscut currently includes ffmpeg 4.4.1. But as of latest losslesscut you can specify an external ffmpeg command to use too. Maybe 5.0 is needed for this to work?

the123blackjack commented 2 years ago

Yes this Support for Dolby vision for mp4 was included four months back. Is adding version 5 in Losslesscut in the pipeline? @mifi

Subfader commented 2 years ago

Found this tool today and it was a big downer to see Dolby HLG is not supported. 2nd shock was to find out the App Store app is 3.36 from 11 months ago. 3rd shock was to see that the latest version here on GitHub uses an 11 months old ffmpeg 4 version while 5.0 has been available for 3 months.

I cancelled the 18 € app, sorry. I would be happy to pay that for an up to date version that can handle my iPhone videos..

Subfader commented 2 years ago

And I can confirm that just using ffmpeg 5 wil do the trick (-strict experimental not needed). I just ran the command from the last ffmpeg command list in Terminal using ffmpeg 5.0 via brew:

ffmpeg -hide_banner -ss '4.66639' -i '/path/in.MOV' -t '48.05855' -avoid_negative_ts make_zero -map '0:0' '-c:0' copy -map '0:1' '-c:1' copy -map_metadata 0 -movflags '+faststart' -default_mode infer_no_subs -ignore_unknown '-metadata:s:v:0' 'rotate=360' -f mov -y '/path/out.mov'

The result was perfect a perfect HLG MOV file.

the123blackjack commented 2 years ago

@Subfader i had this checked and required exporting to .mp4 container with strict experimental flags.

HLG may be intact by the Dolby Vision (DvCC) is getting stripped off otherwise

Subfader commented 2 years ago

OK, I just checked for HLG in MediaInfo and dropped it into Final Cut using my HLG to Rec709 presets.

mifi commented 2 years ago

Yes this Support for Dolby vision for mp4 was included four months back. Is adding version 5 in Losslesscut in the pipeline? @mifi

Yes, it will be included in the not too far future. See #981

2nd shock was to find out the App Store app is 3.36 from 11 months ago.

Where do you see that? According to AppStoreConnect the latest version is 3.39.2 which was released on 30.oct 2021. (4+ months ago). Anyways, I have implemented a lot of new features and refactoring of losslesscut lately, that's why I don't release it immediately to the app stores. I want those who pay for the app to have the most stable experience, and I consider the latest github versions to be a public "beta". In fact there are currently multiple bugs in the latest version that I'm working on fixing.

3rd shock was to see that the latest version here on GitHub uses an 11 months old ffmpeg 4 version while 5.0 has been available for 3 months.

I have been busy implementing a bunch of new features and I wasn't aware that ffmpeg 5 supported dolby, so I haven't spent much time on upgrading ffmpeg unfortunately, but will definitely be prioritizing it now. It's been out for a little over 2 months btw, I don't consider it a long time, and there hasn't even come a bugfix release of ffmpeg yet after that (5.0.1)

BTW FYI all: the newest github version of losslesscut lets you select an external ffmpeg command to use, so if you want a sneak peek of ffmpeg 5 with losslesscut you can do that.

Subfader commented 2 years ago

Where do you see that? According to AppStoreConnect the latest version is 3.39.2

Sorry, my mis-reading on the mini About popup. macOS App Store has 3.39.2 :)

BTW FYI all: the newest github version of losslesscut lets you select an external ffmpeg command to use, so if you want a sneak peek of ffmpeg 5 with losslesscut you can do that.

THANKS! I just re-installed 3.44.0 and HLG is preserved by default (?).

mifi commented 2 years ago

Latest losslesscut now includes ffmpeg 5.0.1. will push to stores once tested a bit more.

mifi commented 1 year ago

Because losslesscut now includes ffmpeg5 and I saw comments saying that ffmpeg5 solves the problem, i’ll close this.