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

First frame of video does not seem to adhere to frame rate #14615

Closed
6 tasks done
forthrin opened this issue Jul 31, 2024 · 5 comments
Closed
6 tasks done

First frame of video does not seem to adhere to frame rate #14615

forthrin opened this issue Jul 31, 2024 · 5 comments

Comments

@forthrin
Copy link

forthrin commented Jul 31, 2024

mpv Information

mpv version: git-2024-07-31-0647089
FFmpeg version: git-2024-07-31-43f702a

Other Information

System Version: macOS 14.5 (23F79)
Model Identifier: MacBookAir10,1

Reproduction Steps

Mux any set of still pictures with any/silent audio as follows:

$ magick "/Library/User Pictures/Flowers"/*.heic %d.png
$ ffmpeg -r 1/3 -i %d.png -f lavfi -i anullsrc -pix_fmt yuv420p -shortest -y out.mp4
$ mpv --no-config --log-file=out.log out.mp4

Expected Behavior

Each still picture should be shown for three seconds. It does in QuickTime.

Actual Behavior

The first still is shown for one frame only, with error message below. Subsequent stills are shown correctly (3 secs each).

Audio/Video desynchronisation detected! Possible reasons include too slow
hardware, temporary CPU spikes, broken drivers, and broken files. Audio
position will not match to the video (see A-V status field).
Consider trying --profile=fast and/or --hwdec=auto-safe as they may help.

If rewinding the video back to start, the first still is shown for 3 secs as expected.

If using a higher frame rate, the error message disappears, but the first frame is still rushed.

Log File

out.log

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.
@llyyr
Copy link
Contributor

llyyr commented Jul 31, 2024

This happens because ffmpeg inserts a bogus audio track when you generate the final mp4, you can add -an to the command to not add the audio track then mpv will display the file correctly.

Although we shouldn't skip the first frame even if the bogus audio track exists, so this is indeed a mpv bug.

@forthrin
Copy link
Author

Thanks for confirming. FYI, the issue happens with an actual (any) audio file too. A silent audio file was just used for simplicity. (It's a good thing if the bogus track uncovered another/broader issue, leading to a more resilient fix.)

llyyr added a commit to llyyr/mpv that referenced this issue Jul 31, 2024
while still rejecting the case where we're delaying audio start and
audio_status is at STATUS_READY.

Prior art: cb2b579 (reverted in b0e6ac3)
However, the general idea of the original commit was correct and the
only edgecase we need to handle is audio_status being stuck at
STATUS_READY in the case where audio starts after the video.

Also fixes mpv-player#14615
@llyyr
Copy link
Contributor

llyyr commented Jul 31, 2024

This was broken by b0e6ac3 which was trying to fix a different sample where audio started after the video.

#14616 fixes this issue without breaking the other sample

@forthrin
Copy link
Author

Thanks for the quick pounce. The two patches do indeed improve the issue. However, the first frame seems to display somewhat longer than expected (about 4 seconds), as opposed to the 3 expected seconds in subsequent frames.

llyyr added a commit to llyyr/mpv that referenced this issue Jul 31, 2024
Waiting for audio_started to be set to true takes too long which causes
us to miss it for the first frame, instead invert the condition so it's
set on the first frame.

Fixes mpv-player#14615
llyyr added a commit to llyyr/mpv that referenced this issue Jul 31, 2024
Waiting for audio_started to be set to true takes too long which causes
us to miss it for the first frame, instead invert the condition so it's
set on the first frame.

Fixes mpv-player#14615
llyyr added a commit to llyyr/mpv that referenced this issue Jul 31, 2024
Waiting for audio_started to be set to true takes too long which causes
us to miss it for the first frame, instead invert the condition so it's
set on the first frame.

Fixes mpv-player#14615
@forthrin
Copy link
Author

forthrin commented Aug 1, 2024

By all accounts, e06e9c3 consistently displays each frame, including the first, for the expected 3 seconds. Well done!

na-na-hi pushed a commit to na-na-hi/mpv that referenced this issue Sep 28, 2024
Waiting for audio_started to be set to true takes too long which causes
us to miss it for the first frame, instead invert the condition so it's
set on the first frame.

Fixes mpv-player#14615
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

3 participants