Playing a Transport Stream file with stubs segments messes up whole duration and can't seek
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 --version
mpv v0.40.0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 7.1.1
FFmpeg library versions:
libavcodec 61.19.101
libavdevice 61.3.100
libavfilter 10.4.100
libavformat 61.7.100
libavutil 59.39.100
libswresample 5.3.100
libswscale 8.3.100
Other Information
- macOS version: macOS 15.4 (24E248)
- Source of mpv: brew.sh
- Latest known working version: unknown
- Issue started after the following happened: create ts file with stubs
Reproduction Steps
Create a sample Transport Stream file where one of the segments is a stub like this:
byte[] transportStreamStub =
{
0x47, 0x40, 0x00, 0x1A, 0x00, 0x00, 0xB0, 0x0D, 0x00, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x2A, 0xB1, 0x04, 0xB2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF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FF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x3F, 0x84, 0x80, 0x05, 0x21, 0x06, 0xC3, 0xCF, 0x45, 0xFF, 0xF1, 0x4C, 0x40, 0x01, 0x7F, 0xFC, 0x00, 0xD0, 0x00, 0x07,
0xFF, 0xF1, 0x4C, 0x40, 0x01, 0x7F, 0xFC, 0x00, 0xD0, 0x00, 0x07, 0xFF, 0xF1, 0x4C, 0x40, 0x01, 0x7F, 0xFC, 0x00, 0xD0, 0x00, 0x07, 0xFF, 0xF1, 0x4C, 0x40, 0x01, 0x7F, 0xFC, 0x00, 0xD0, 0x00, 0x07, 0xFF, 0xF1, 0x4C,
0x40, 0x01, 0x7F, 0xFC, 0x00, 0xD0, 0x00, 0x07
};
And place it in the middle of a Twitch stream, like this:
$ cat 598.ts stub.ts 600.ts > sample.ts
The size of each of those files is.
7874756 bytes
376 bytes
7991128 bytes
sample.ts has 15866260 bytes in it.
The original issue is discussed here: https://github.com/lay295/TwitchDownloader/issues/1344
Expected Behavior
display correctly file duration and playback correctly all the way through.
Actual Behavior
Each segment is 10 seconds. The first one play correctly, but when reached the third, audio and video get out of sync. Also the duration of sample.ts changes from 00:00:30 to -24:55:08. Also trying to seek in the middle of the stub just ends the playback.
Log File
Sample Files
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
Reproduce sample.ts by concatenating 598.ts, stub.ts, and 600.ts, then run mpv with the attached sample and output log. Investigate Transport Stream handling for duration, timestamp synchronization, and seeking. Done means the file reports the correct duration, remains synchronized through the stub, and seeking across it continues playback.
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
- 42/100