Opened 11 years ago

Closed 11 years ago

#7935 closed patch (fixed)

[PATCH] Improve MPEG-TS seeking performance by 60X

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


I've recently discovered that slow seeking for MPEG-TS using av_seek_frame is caused by inefficient handling of EOF in libs/libmythtv/RingBuffer.cpp. The attached patch addresses the following issues:

  • Inside safe_read() we need to break after a read() if it's an "oldfile" (>30 minutes). There is no reason to delay (60000 usec) and retry for this case. The calling code will retry anyways if ret > 0 and if ret == 0 then it really is the EOF.

  • When an lseek is performed we need to adjust the totfree buffer amount before entering a 50000 usec delay. Every time an lseek is performed the buffer gets reset so we should update totfree before checking to see if the buffer it full and we need to wiat.

One other issue I believe is that 30 minutes is too long to determine if a file is an "oldfile". I'd like to see that reduced to a more reasonable value and if possible add a better check to determine it the file is open for writing.

Without this patch applied an av_seek_frame takes ~0.9 secs and with the patch it takes ~0.015. This will also improve performance for other containers as well.

Attachments (2)

t7935_improve_mpegts_seeking_v1.diff (1.0 KB) - added by taylor.ralph@… 11 years ago.
initial revision (trunk 23210)
t7935_improve_mpegts_seeking_v2.diff (1.0 KB) - added by taylor.ralph@… 11 years ago.
fix comment

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by taylor.ralph@…

initial revision (trunk 23210)

comment:1 Changed 11 years ago by markk

Owner: changed from Janne Grunau to markk
Status: newaccepted

Changed 11 years ago by taylor.ralph@…

fix comment

comment:2 Changed 11 years ago by markk

Resolution: fixed
Status: acceptedclosed

(In [23288]) Improved AVFormatDecoder seeking with patches from Taylor Ralph.

I've been testing for a few days and the improvement in navigating files without a markup (i.e. MythVideo?) is substantial.

I'd delayed due to an issue seen with certain test matroska files but I've now realised that this is a separate, existing seek problem with these files that manifests itself slightly differently following these changes.

Closes #7521, Closes #7935.

Note: See TracTickets for help on using tickets.