Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#7397 closed patch (fixed)

libav seeking near the start of video is broken

Reported by: tralph11@… Owned by: markk
Priority: minor Milestone: 0.23
Component: MythTV - Video Playback Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Using libav seeking to a position near the start when the video has a non-zero context start time causes future seeks to be broken. The following code in avformatdecoder.cpp is incorrect since the start_time is not zero for some videos and is required to correctly calculate the timestamp fed to av_seek_frame().

    if (desiredFrame <= 1)
    {
        av_update_cur_dts(ic, st, 0);
        ic->start_time = 0;
    }

This code appears to have been added because it was assumed that seeking to the beginning caused it to return a DTS timestamp toward the end of the video. In actuality it sometimes returns a DTS value that is _earlier_ than the start time. This causes the lsb3full function called later to generate an adj_cur_dts value well beyond the end of the video. The fix should be to check if the cur_dts is earlier than the context start_time. If so, either one of the following changes should work:

  • fix1 -> remove broken code and set the start_time to the current DTS time

OR

  • fix2 -> remove broken code and set adj_cur_dts to zero if it's earlier than the start time

I've tested both methods wiht success and no apparent problems. I'm attaching both methods to the ticket.

Attachments (3)

mythtv_libav_seek_start_fix1.diff (1.4 KB) - added by tralph11@… 14 years ago.
update the start time if dts earlier than start time
mythtv_libav_seek_start_fix2.diff (1.3 KB) - added by tralph11@… 14 years ago.
set adj_cur_dts to zero if dts is earlier than start_time
t7397_mythtv_libav_seek_start_v3.diff (1.3 KB) - added by taylor.ralph@… 14 years ago.
final update (trunk 23210)

Download all attachments as: .zip

Change History (9)

Changed 14 years ago by tralph11@…

update the start time if dts earlier than start time

Changed 14 years ago by tralph11@…

set adj_cur_dts to zero if dts is earlier than start_time

comment:1 Changed 14 years ago by tralph11@…

After more thought and testing the second fix which sets adj_cur_dts to zero is a much better solution since future calculations for seeking and possibly other functionality relies upon the ic->start_time value.

Changed 14 years ago by taylor.ralph@…

final update (trunk 23210)

comment:2 Changed 14 years ago by markk

Owner: changed from Janne Grunau to markk
Status: newaccepted

comment:3 Changed 14 years ago by markk

Milestone: unknown0.23

comment:4 Changed 14 years ago by markk

Resolution: fixed
Status: acceptedclosed

(In [23294]) Fix seeking to the beginning of certain streams that have non-zero start times. Patch from Taylor Ralph.

Closes #7397.

comment:5 Changed 14 years ago by tralph

(In [23561]) Backport [23294] to fix seeking to start of stream with non-zero start_time, refs #7397.

comment:6 Changed 14 years ago by tralph

(In [23751]) Properly handle both seeking near the start of stream and pts wrap. The previous code would confuse a pts wrap condition as a seek to a position less than the start time condition.

Refs #7397.

Note: See TracTickets for help on using tickets.