Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12196 closed Bug Report - General (fixed)

Invalid bitrate from AVFormat can stall reads from the RingBuffer

Reported by: david.madsen@… Owned by: Jean-Yves Avenard <jyavenard@…>
Priority: minor Milestone: 0.27
Component: MythTV - General Version: Unspecified
Severity: medium Keywords:
Cc: Ticket locked: no

Description

I've had trouble recently with some recordings that can't be played back in the frontend or commflagged.

The bitrate returned from AVFormat is incorrect because of a glitch near the end of the recording which reset the PTS near the end. This cause AVFormat to have an entirely invalid bitrate, which was then propagated to the RingBuffer via the following code:

AVFormatDecoder::ScanStreams() in libmythtv/avformatdecoder.cpp

    if (ic && ((uint)ic->bit_rate > bitrate))
        bitrate = (uint)ic->bit_rate;

    if (bitrate > 0)
    {
        bitrate = (bitrate + 999) / 1000;
        if (ringBuffer)
            ringBuffer->UpdateRawBitrate(bitrate);
    }

This ended up setting the fill_min in the RingBuffer larger than the full size of the buffer, and consequently blocking reads from the RingBuffer since this condition never becomes true:

        if ((0 == read_return) || (numfailures > 5) ||
            (readsallowed != (used >= fill_min || ateof ||
                              setswitchtonext || commserror)))
        {

I've attached a patch where I just capped the bitrate returned from AVFormat to exclude the erroneous values, though I'm not sure that's the best way to fix the problem. Maybe a safeguard in the RingBuffer itself on the value of fill_min would be a better method.

Attachments (2)

mythtv_fix_avf_bitrate.patch (1.2 KB ) - added by david.madsen@… 11 years ago.
mythtv_fix_avf_bitrate.2.patch (1.1 KB ) - added by david.madsen@… 11 years ago.
Cleaned up patch to avoid null pointer

Download all attachments as: .zip

Change History (5)

by david.madsen@…, 11 years ago

by david.madsen@…, 11 years ago

Cleaned up patch to avoid null pointer

comment:1 by Jean-Yves Avenard <jyavenard@…>, 11 years ago

Owner: set to Jean-Yves Avenard <jyavenard@…>
Resolution: fixed
Status: newclosed

In 83050ac67d40a449bc5433e0edda2c41d75eb45f/mythtv:

Error: Processor CommitTicketReference failed
GIT backend not available

comment:2 by Jean-Yves Avenard <jyavenard@…>, 11 years ago

In db46c6a71c53bccebc640331ad35f0481c4c7fc2/mythtv:

Error: Processor CommitTicketReference failed
GIT backend not available

comment:3 by paulh, 11 years ago

Milestone: unknown0.27
Note: See TracTickets for help on using tickets.