Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASS Subtitle] Normalize timestamps like Aegisub #10783

Closed
moi15moi opened this issue Oct 24, 2022 · 6 comments
Closed

[ASS Subtitle] Normalize timestamps like Aegisub #10783

moi15moi opened this issue Oct 24, 2022 · 6 comments

Comments

@moi15moi
Copy link
Contributor

moi15moi commented Oct 24, 2022

Expected behavior of the wanted feature

MPV should maybe normalize the timestamps of the video to display an .ass file.

What means normalize the timestamps?

It means the first frame will have a timestamps of 0 ms.

Example:
If the timestamps look like this:

# timestamp format v2
10000
10042
etc...

Then, the normalize timestamps would look like that:

# timestamp format v2
0
42
etc...

Here is how Aegisub implemented it

Why should it normalize the timestamps?

Aegisub, the most used program for editing .ass subtitle, normalize the timestamps.
This means that currently, if the first video timestamps does not start at 0, the subtitle will not be render at the exact same frame between MPV and Aegisub.

Why it should maybe not normalize the timestamps?

Currently, there is an issue opened about this problem on Aegisub repos.
See: TypesettingTools/Aegisub#21

But, since 2010, Aegisub has always normalize the timestamps, so if mpv does not normalize it, it can cause an different timing rendering.

Then, what should mpv does? Should it implement the normalize option or not?

I created this issue, because I wanted to let know the mpv developpers about this possible problem.
I am not 100% sure if it should normalize the timestamps like Aegisub or not.

How to test the different rendering between Aegisub and MPV?

The easiest solution is to use an mkv video and apply this command with mkvmerge:
mkvmerge --output OUTPUT.MKV --sync -1:ANY_NUMBER_ABOVE_0 INPUT.MKV

It will delay the timestamps. The important is that the first timestamps does not start at 0 and if the video fps is 24000/1001, you should at least wrote >42ms to see an difference between Aegisub rendering and mpv rendering.

Then, open Aegisub and create a few lines and save the subtitle.

Finally, open the video and the .ass subtitle with MPV and you will be able to see that the subtitles will not be rendered at the same frame.

@Traneptora
Copy link
Member

Traneptora commented Nov 3, 2022

mpv does rebase start times. --rebase-start-time=yes is on by default and it shifts it so the start of playback is at timestamp 0.

Are you attempting to play back a file where the video stream doesn't start at timestamp 0 but the subtitle stream does? That's a corrupt file and it's the fault of whoever muxed it.

@moi15moi
Copy link
Contributor Author

moi15moi commented Nov 5, 2022

I should have mentionned it, but yes, --rebase-start-time=yes seems to be the equivalent of what I am talking about, but when I tested it, the timestamps did not seems to have been rebased.

Here is an sample to test what I said: Sample.zip
MPV - The subs will be not sync with the video.
Aegisub - The subs will be sync to the video.
The first timestamps of this video is 1000 ms.

Are you attempting to play back a file where the video stream doesn't start at timestamp 0 but the subtitle stream does? That's a corrupt file and it's the fault of whoever muxed it.

I said that Aegisub always normalize/rebase the timestamps, so the ass subtitle stream will always start at 0. That's not really corrupt, it is only like that the Aegisub works.

@Traneptora
Copy link
Member

Traneptora commented Nov 5, 2022

You'll have to remux the input file as --rebase-start-time slides the timestamps of all tracks equally to prevent any of them from desyncing. Alternatively you can set --sub-delay.

@moi15moi
Copy link
Contributor Author

moi15moi commented Nov 5, 2022

Remux the input file as --rebase-start-time.

What do you mean?
Can you provide an example?

Alternatively you can set --sub-delay.

I don't think this is an good idea. Any .ass works like that. I don't see why the user should be the one to apply an delay when mpv should do it automatically.

@Traneptora
Copy link
Member

ffmpeg -i input.mkv -map 0 -c copy output.mkv
Would be one way to do it.

If you're using aegisub you're authoring a file, so you are not an end user. And the reason it doesn't do it automatically is, as I explained, mpv slides the timestamps of all tracks equally to prevent any of them from desyncing.

@moi15moi
Copy link
Contributor Author

moi15moi commented Nov 5, 2022

ffmpeg -i input.mkv -map 0 -c copy output.mkv Would be one way to do it.

I just tested it and it doesn't work, but, anyways, mkvmerge --output OUTPUT.MKV --sync -1:FIRST_TIMESTAMPS_*_-1 INPUT.MKV does what you mean.

And the reason it doesn't do it automatically is, as I explained, mpv slides the timestamps of all tracks equally to prevent any of them from desyncing.

Ok, so in brief, you are saying that it is not mpv job to works has Aegisub.
Then, the issue is closed.

@moi15moi moi15moi closed this as completed Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants