AvPlayer: in no-sync mode the video plays at the game's frame rate, so cinematics fall far behind their audio #1635

Closed
opened 2026-10-08 15:22:51 +00:00 by awake-devel · 0 comments
awake-devel commented 2026-10-08 15:22:51 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-08T15:22:51Z.


Investigated and written by Claude Code (AI), and posted by me after review.

What happens

In Hollow Knight: Silksong (PPSA12544) on Linux, the intro cinematic's sound plays far ahead of the picture. By the time the sound ends, the picture is about 52 s behind, and the last part of the cinematic plays with almost no sound.

Measurements

  • Source: Media/StreamingAssets/Intro_Cinematic.mp4, 79.6 s, 1916x1080, 30 fps, AAC.
  • Method: two window recordings of the cinematic. Every recorded frame was matched to a film frame (match score 0.99), and the recorded sound was matched to the film's sound at 9 points.
  • Sound: plays at real speed and stays in step with the film.
  • Picture: plays at 0.52–0.58×. It covers film time 3.4 s → 75.7 s in 125 s of real time in one recording, and 2.4 s → 75.8 s in 140 s in the other.
  • Gap: grows steadily (2, 8, 21, 34 s, and about 52 s when the sound ends). This is a rate problem, not a start offset.
  • Log: the mp4 is opened at t+112 s and its buffers freed at t+250 s, so 138 s for a 79.6 s film.
  • Decoding is not the bottleneck: ffmpeg decodes this film to NV12 at about 220 fps on one thread on the test machine.

Likely cause

  • The title calls sceAvPlayerSetAvSyncMode with mode 1 (no sync); #591 notes Unity titles do this.
  • In that mode, Source.cpp's takeVideo hands out the next decoded frame on each call and never compares it with the clock. Late frames are only dropped when sync is on (core/libs/prx/libSceAvPlayer/src/Source.cpp:512-516 on cba8d86d).
  • The title runs at about 7–19 fps here, so the 30 fps film advances one frame per game frame, at roughly half speed, while the audio is pulled at real time. On a PS5 the title runs at 60 fps, so this never shows.

Open question, being checked now

Does the title call sceAvPlayerGetVideoData once per game frame, or several times when it is behind? If it is the second, AnyPS5 may be answering "no frame" because the decode-ahead has not produced the next frame yet. The faithful fix would then be to have frames ready sooner. A run that logs every call is under way.

Candidate fix

In no-sync mode, while the title is pulling audio, skip queued frames that are already older than the audio clock. Frames that are not late are handed out as today. This departs from the console's "hand out every frame" only for frames that are already late. It would be recorded in TechnicalDebt.md, and once the title runs at the film's frame rate or faster, nothing is skipped.

A unit test reproduces the problem in miniature: in no-sync mode with audio pulled in real time and 15 video requests per second, the video falls 465 ms behind.

Related: #591, #1601 (flicker in the same cinematic), #1486 (audio pacing), discussion #1519.

Test machine: Arch Linux, i7-8750H, GTX 1050 Ti Max-Q, NVIDIA 580.178.04.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5764428128 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1635). Originally posted by [awake-devel](https://github.com/awake-devel) on 2026-10-08T15:22:51Z. --- > Investigated and written by Claude Code (AI), and posted by me after review. ### What happens In Hollow Knight: Silksong (PPSA12544) on Linux, the intro cinematic's **sound plays far ahead of the picture**. By the time the sound ends, the picture is about 52 s behind, and the last part of the cinematic plays with almost no sound. ### Measurements - **Source:** `Media/StreamingAssets/Intro_Cinematic.mp4`, 79.6 s, 1916x1080, 30 fps, AAC. - **Method:** two window recordings of the cinematic. Every recorded frame was matched to a film frame (match score 0.99), and the recorded sound was matched to the film's sound at 9 points. - **Sound:** plays at real speed and stays in step with the film. - **Picture:** plays at **0.52–0.58×**. It covers film time 3.4 s → 75.7 s in 125 s of real time in one recording, and 2.4 s → 75.8 s in 140 s in the other. - **Gap:** grows steadily (2, 8, 21, 34 s, and about 52 s when the sound ends). This is a rate problem, not a start offset. - **Log:** the mp4 is opened at t+112 s and its buffers freed at t+250 s, so 138 s for a 79.6 s film. - **Decoding is not the bottleneck:** ffmpeg decodes this film to NV12 at about 220 fps on one thread on the test machine. ### Likely cause - The title calls `sceAvPlayerSetAvSyncMode` with mode 1 (no sync); #591 notes Unity titles do this. - In that mode, `Source.cpp`'s `takeVideo` hands out the next decoded frame on each call and never compares it with the clock. Late frames are only dropped when sync is on (`core/libs/prx/libSceAvPlayer/src/Source.cpp:512-516` on cba8d86d). - The title runs at about 7–19 fps here, so the 30 fps film advances one frame per game frame, at roughly half speed, while the audio is pulled at real time. On a PS5 the title runs at 60 fps, so this never shows. ### Open question, being checked now Does the title call `sceAvPlayerGetVideoData` once per game frame, or several times when it is behind? If it is the second, AnyPS5 may be answering "no frame" because the decode-ahead has not produced the next frame yet. The faithful fix would then be to have frames ready sooner. A run that logs every call is under way. ### Candidate fix In no-sync mode, while the title is pulling audio, skip queued frames that are already older than the audio clock. Frames that are not late are handed out as today. This departs from the console's "hand out every frame" only for frames that are already late. It would be recorded in TechnicalDebt.md, and once the title runs at the film's frame rate or faster, nothing is skipped. A unit test reproduces the problem in miniature: in no-sync mode with audio pulled in real time and 15 video requests per second, the video falls 465 ms behind. Related: #591, #1601 (flicker in the same cinematic), #1486 (audio pacing), discussion #1519. **Test machine:** Arch Linux, i7-8750H, GTX 1050 Ti Max-Q, NVIDIA 580.178.04.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#1635
No description provided.