Embedded subtitles out of sync in time-cropped video
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
mpv Information
mpv : git-2025-06-06-v0.40.0-dev-g6b178e4f5
FFmpeg: git 2025-06-05 18:24:07 17729aa8
System: macOS 15.5 (24F74)
Model : MacBookAir10,1
Sample Files
Reproduction Steps
#!/bin/bash
mpv --config=no --sub-auto=no /tmp/x.m4v # RIGHT
mpv --config=no --sub-auto=no /tmp/y.m4v # WRONG: shows subtitle for 10s at 8s
open -a 'QuickTime Player' /tmp/y.m4v # RIGHT
Expected Behavior
Subtitles in sync
Actual Behavior
Subtitles out of sync
(Blocky screenshot of subtitle might be a separate issue with Retina displays.)
Log File
Issue might be related to keyframes.
#!/usr/bin/env ruby
%w[x y].each do |f|
base = { 'video' => 16_384, 'subtitle' => 1_000_000 }
info = base.transform_values { [] }
`ffprobe -v error -show_entries packet=codec_type,pts,flags -of csv /tmp/#{f}.m4v | grep K`.lines(chomp: true).each do |item|
_, type, pts = item.split(',')
info[type] << (pts.to_f / base[type])
end
pp info
end
{"video" => [0.0, 10.0], "subtitle" => [0.0, 5.0, 10.0]}
{"video" => [0.0, 7.0], "subtitle" => [-5.0, 0.0, 5.0]}
Other Information
To create variants with different timings for debugging/testing:
#!/usr/bin/env ruby
def ts(sec)
ms = sec * 1000
format '%02d:%02d:%02d,%03d', *([1000, 60, 60, 100].map { |f| ms.tap { ms /= f } % f }).reverse
end
(0..15).step(5).each_cons(2).with_index do |(a, b), i|
printf "%s\n%s --> %s\n%s / %s\n\n", i + 1, ts(a), ts(b), ts(a), a
end
#!/bin/bash
for t in $(seq 0 12); do
magick null: -background '#8c8' -extent 320x240 -pointsize 40 -gravity center -annotate +0+0 "$t" "/tmp/$t.png"
done
ffmpeg -r 1 -i /tmp/%d.png -i /tmp/sub.srt -pix_fmt yuv420p -c:s mov_text -y /tmp/x.m4v
ffmpeg -ss 3 -i /tmp/x.m4v -c:s mov_text -y /tmp/y.m4v
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.
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 issue with the attached xy.zip files and the provided mpv commands, then compare the ffprobe keyframe timing output for x.m4v and y.m4v. Investigate subtitle timing during the time-cropped playback path; done means embedded subtitles remain synchronized in y.m4v while the existing reproduction still distinguishes the expected and actual behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100