Opened 9 years ago
Closed 6 years ago
Last modified 6 years ago
#12396 closed Bug Report - General (fixed)
external .srt subtitles go out of sync in some use cases since 59512d5e9d
Reported by: | Owned by: | Peter Bennett | |
---|---|---|---|
Priority: | minor | Milestone: | 30.0 |
Component: | MythTV - Video Playback | Version: | 0.27.4 |
Severity: | medium | Keywords: | subtitle timing |
Cc: | Ticket locked: | no |
Description
After upgrading my 0.24 to 0.27 fixes I see subtitles timing problem. It manifests itself with .avi files and srt/sub subtitles. When you play avi file first time, subtitles are usually timed correctly (not allways). But when retrying watching from bookmark subtitles are allmost allways about 3sec late/early. This happens with various avi files. Also tested with different system running master, same problem.
Attachments (1)
Change History (23)
comment:1 Changed 9 years ago by
comment:2 follow-up: 4 Changed 9 years ago by
There's a good chance the timing issues will be solved by generating a seektable for the video using "mythcommflag --rebuild". Can you try that and report back?
Lack of complaints likely due to:
- MythTV doesn't record .avi files (i.e. you have to go to extra work to import them), so most people don't play them.
- Most people don't care about captions/subtitles.
IIRC, what's happening is that without a seektable, MythTV must ask the decoder (ffmpeg) to seek to the desired frame, but ffmpeg only seeks to the nearest keyframe, while MythTV believes it is at the exact frame. If keyframes in the .avi file are far apart, subtitles are likely to be out of sync. But if a seektable is present, MythTV seeks to a keyframe, then frame-by-frame advances to the desired frame.
comment:3 Changed 9 years ago by
I generated seektables for few videos. Unfortunately, it did not fix the problem.
comment:4 follow-up: 6 Changed 9 years ago by
Replying to stichnot:
Lack of complaints likely due to:
- MythTV doesn't record .avi files (i.e. you have to go to extra work to import them), so most people don't play them.
- Most people don't care about captions/subtitles.
this has happens to me many times... subtitles are good at first and then they start diverging to the point they are unusable. I've never managed to reproduce the problem correctly, and often I just blamed the subtitles and moved on.
IIRC, what's happening is that without a seektable, MythTV must ask the decoder (ffmpeg) to seek to the desired frame, but ffmpeg only seeks to the nearest keyframe, while MythTV believes it is at the exact frame. If keyframes in the .avi file are far apart, subtitles are likely to be out of sync. But if a seektable is present, MythTV seeks to a keyframe, then frame-by-frame advances to the desired frame.
That seems like a bug to me... Yes ffmpeg will seek to the next keyframe, but you still get the right time and adjust the subtitle for that time. Also, why not do like with the seek table present a move frame by frame then?
comment:5 Changed 9 years ago by
One noticeable thing is, subtitles are always just 3sec behind or ahead. If this would be keyframe related problem, should timing offset vary?
comment:6 Changed 9 years ago by
Replying to jyavenard:
Replying to stichnot:
Lack of complaints likely due to:
- MythTV doesn't record .avi files (i.e. you have to go to extra work to import them), so most people don't play them.
- Most people don't care about captions/subtitles.
this has happens to me many times... subtitles are good at first and then they start diverging to the point they are unusable. I've never managed to reproduce the problem correctly, and often I just blamed the subtitles and moved on.
That sounds like subtitle drift, which is separate from the OP's issue, I think. Drift can come from a mismatch between the video and the subtitle file, or even from inconsistency between the container's reported framerate and actual content (#11415 comes to mind).
IIRC, what's happening is that without a seektable, MythTV must ask the decoder (ffmpeg) to seek to the desired frame, but ffmpeg only seeks to the nearest keyframe, while MythTV believes it is at the exact frame. If keyframes in the .avi file are far apart, subtitles are likely to be out of sync. But if a seektable is present, MythTV seeks to a keyframe, then frame-by-frame advances to the desired frame.
That seems like a bug to me... Yes ffmpeg will seek to the next keyframe, but you still get the right time and adjust the subtitle for that time. Also, why not do like with the seek table present a move frame by frame then?
I thought I had debugged in the past the issue of seeking in a particular container type and seeing this kind of imprecision from ffmpeg, but I could be misremembering. In any case, the OP reporting that it snaps to +/-3sec off, plus no seektable difference, suggests that it's something else.
comment:7 Changed 9 years ago by
Yes, this definitely is not subtitle drift problem. It happen to all avi and mp4 files, and I can play those files with mplayer/vlc with correct timing. Just skipping forward/backward, start watching from bookmark sets timing incorrect. Sometimes, if timing is incorrect when I continue watching from bookmark, I can skip few times backwards and then ahead, and get right timing again. But this is little painful. Usually I check that are subs ahead or behind and adjust subtitle delay +/- 3sec and get timing ok.
comment:8 Changed 9 years ago by
Milestone: | 0.27.5 → 0.27.6 |
---|
comment:9 Changed 8 years ago by
I have the same problem, and reported it on mythtv-users¹. Reverting commit 59512d5e9dad1ca fixes the issue, but I don't know what else broke that that commit fixed.
¹http://lists.mythtv.org/pipermail/mythtv-users/2015-October/382147.html
comment:10 Changed 8 years ago by
I have the same problem. When I was on the old 26.x version I did not have the subtitle issue but now all of my downloaded mp4+srt files have drift issues. When playing the same videos on a windows machine on VLC or something similar the timing is fine.
comment:11 Changed 8 years ago by
I've also noticed this recently.
The srt subtitles go out of sync when skipping. I've noticed the problem is worse on a file that is variable frame rate and 1920x1080. There's also a problem on 1280x720, but it's less pronounced. It's nonexistant on other smaller files (848x480, constant frame rate).
I've played the files using VLC on the same machine and had no issues with synchronization.
comment:12 Changed 8 years ago by
Owner: | changed from JYA to Jim Stichnoth |
---|---|
Status: | new → assigned |
Summary: | Mythvideo subtitle timing problem → external .srt subtitles go out of sync in some use cases since 59512d5e9d |
The mailing list discussion suggests to convert the .avi+.srt or .mp4+.srt into a Matroska file with a subtitle track as work around.
Jim, can you see how your commit causes such behavior?
comment:13 Changed 8 years ago by
Milestone: | 0.27.6 → 0.27.7 |
---|
Reschedule all tickets planned for, but not solved in time for, 0.27.6 to 0.27.7.
comment:14 follow-up: 16 Changed 8 years ago by
Hello, I was wondering if this was fixed in 0.28? ismota or jklaas notice this? I haven't upgraded yet so I can't confirm either way.
comment:16 Changed 8 years ago by
Replying to wpcprez@…:
Hello, I was wondering if this was fixed in 0.28? ismota or jklaas notice this? I haven't upgraded yet so I can't confirm either way.
still broken on 0.28 fixes
comment:17 Changed 7 years ago by
Well - it looks like GetSecondsPlayed?(false, 1); not delivers properly. Switch to GetDecoder?()->NormalizeVideoTimecode? solves problem albeit this is just workaround. patch attached...
Changed 7 years ago by
Attachment: | 0323-ticket12396-.srt-subs-go-out-of-sync.patch added |
---|
workaround for .srt de-sync after seeks
comment:18 Changed 6 years ago by
I tested this with an avi video with srt subtitles, skip 12 minutes in. Without the patch, the subtitles are way out of sync. With the patch they are in perfect sync.
comment:19 Changed 6 years ago by
Owner: | changed from Jim Stichnoth to Peter Bennett |
---|---|
Status: | assigned → accepted |
comment:20 Changed 6 years ago by
Milestone: | 0.27.7 → 30.0 |
---|
comment:21 Changed 6 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:22 Changed 6 years ago by
Owner: | changed from Peter Bennett to Peter Bennett |
---|
I am little surprised that others does not notice this problem (I haven't seen any discussion about it in forums/mailing lists). Practically all my avi files have this problem. Subtitles are usually ok if video is started from beginning. But restarting it from bookmark and often also seeking/jumping in video sets subtitle timing wrong.
mkv files are allways ok. mp4 files suffers this problem.