Opened 6 years ago

Closed 5 years ago

#11371 closed Patch - Bug Fix (Fixed)

DVD video sometimes freezes briefly

Reported by: peper03@… Owned by: peper03
Priority: minor Milestone: 0.27
Component: MythTV - DVD Playback Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

When playing DVDs such as Cars 2 or Brave using VDPAU or with the 'Extra audio buffering' option enabled, the video sometimes freezes for a couple of seconds.

This is because the audio timestamp has jumped backwards (from say 20000 to 47). The condition in AvFormatDecoder::GetFrame? ('lastapts < lastvpts + 100') that determines whether to continue buffering video frames always evaluates to true because lastvpts does not get updated until a frame is actually processed, which it won't because the video frames keep getting buffered.

This situation continues until either the audio buffer fills up (setting 'allowedquit' to true and breaking out of the loop) or until the maximum number of video frames have been buffered (currently 220). If the input data cannot be read quickly enough (e.g. when reading from a physical DVD rather than an image), the picture freezes for around 2 seconds.

The exact behaviour depends on the input reading speed and the configured audio output (7.1 analogue output will fill the audio buffers faster than stereo or SPDIF).

The attached patch detects when the audio timestamp jumps backwards and prevents more video frames from being buffered until the frames already in the buffer have been processed and the video timestamp has also jumped backwards.

Attachments (4)

0001-Detect-when-the-audio-timestamp-resets-to-ensure-we-.patch (4.1 KB) - added by peper03@… 6 years ago.
0001-DVD-PTS-discontinuities-are-now-handled-by-flattenin.patch (11.2 KB) - added by peper03@… 6 years ago.
New patch that flattens DVD timestamps to avoid PTS jumps.
timestamp_bad.txt (114.0 KB) - added by peper03@… 6 years ago.
Logs of problem before patch (using VDPAU decoding and analogue stereo output)
timestamp_good.txt (53.7 KB) - added by peper03@… 6 years ago.
Logs after applying 2nd patch (sync traces on 'lba' parameter)

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by peper03@…

Changed 6 years ago by peper03@…

New patch that flattens DVD timestamps to avoid PTS jumps.

Changed 6 years ago by peper03@…

Attachment: timestamp_bad.txt added

Logs of problem before patch (using VDPAU decoding and analogue stereo output)

Changed 6 years ago by peper03@…

Attachment: timestamp_good.txt added

Logs after applying 2nd patch (sync traces on 'lba' parameter)

comment:1 Changed 6 years ago by peper03@…

The second patch approaches the problem from a different direction by detecting PTS discontinuities and flattening them so that no matter how much the user jumps about, the timecodes should always be contiguous.

The sample 'Cars2Titles.iso' in stuartm's DVD repository contains a small excerpt from the opening credits of Cars 2. The point at which the '2' comes together is approximately where the timecodes jump back and cause problems.

comment:2 Changed 6 years ago by Jim Stichnoth

Owner: set to Jim Stichnoth
Status: newaccepted

Second patch committed in b6c0ec5529d8b921a846c38b5d6afeb06a4d5671

comment:3 Changed 5 years ago by Richard <peper03@…>

In fe3e4d09da1c6bc51d6209d3dd0527119a3febdf/mythtv:

DVD PTS discontinuities are now handled by 'flattening' the timecodes of incoming packets. This prevents AVFormatDecoder getting stuck buffering video frames when the timecodes jump backwards.

Signed-off-by: Stuart Morgan <smorgan@…>
(cherry picked from commit b6c0ec5529d8b921a846c38b5d6afeb06a4d5671)

Refs #11371

comment:4 Changed 5 years ago by Jim Stichnoth

Owner: changed from Jim Stichnoth to peper03
Status: acceptedassigned

comment:5 Changed 5 years ago by peper03

Milestone: unknown0.27
Resolution: Fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.