Opened 7 months ago

Closed 2 months ago

#13416 closed Bug Report - General (Fixed)

Interlaced Mediacodec counts fast on Shield

Reported by: mspieth Owned by: Peter Bennett
Priority: minor Milestone: 30.1
Component: MythTV - Video Playback Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

I have been using avsync2 and mediacodec with interlaced recorded TV program.

I play back at faster than real time e.g. x1.2 or x1.5. The counter for the end of the program reaches 0 before the actual end of the program, thus reverting to x1.0. It seems to be the same ratio regardless of the rate played.

Attachments (3)

20190227_1659_timing_fix.patch (2.4 KB) - added by Peter Bennett 7 months ago.
Proposed, lightly tested, fix
monotonic-time-avsync2-20190303.patch (3.4 KB) - added by mspieth 7 months ago.
monotonic-time-avsync2-20190303.2.patch (3.6 KB) - added by mspieth 7 months ago.

Download all attachments as: .zip

Change History (16)

Changed 7 months ago by Peter Bennett

Proposed, lightly tested, fix

comment:1 Changed 7 months ago by Peter Bennett

This fix only applies to avsync2. Elapsed playback time is now based on the timecodes of the frames rather than count of number of frames played. This should help with any video or situation where the timecode advances at the wrong rate.

I have a 30 minute recording that I played using mediacodec on shield at 1.5x. Before this change it reverted to 1.0x and showed 30 playback minutes when it was actually only 2/3 through (at the 20 minute point approximately). With the patch the timings are correct and it reaches the end of the recording correct;y at the 1.5x speed, also the timings displayed with Info are now correct.

I have done some tests with cutpoints also, and they seem OK with this change.

comment:2 Changed 7 months ago by Peter Bennett

Milestone: needs_triage30.1

Changed 7 months ago by mspieth

comment:3 Changed 7 months ago by mspieth

This may be a buffer problem as markk suggests.

comment:4 Changed 7 months ago by mspieth

Add patch which will mitigate any ntp time jumps that occur during playback and avsync2.

Feel free to disregard the sleep loop which is supposed to trick the scheduler from deferring this thread/process after the actual time expired. The trick is used elsewhere in myth too.

comment:5 Changed 7 months ago by Peter Bennett

I agree that I should have used QElapsedTimer here. I will make the change, but ...

One thing mystifies me, I cannot see where the timer is started. According to the QElapsedTimer documentation, the timer is invalid until QElapsedTimer::start() is called, and I cannot find any call to start() in the patch. It would be good enough to just call start() in the constructor, I think, and it could continue timing until destroyed.

Is something missing or am I missing something?

comment:6 Changed 7 months ago by mspieth

Sorry I missed copying the m_avTimer.start() in mythplayers constructor.

Changed 7 months ago by mspieth

comment:7 Changed 7 months ago by mspieth

Also its probably a good idea to read the use avsync2 setting in teh constructor and cache it as I think it will make mysql a bit busy.

comment:8 Changed 7 months ago by Peter Bennett

AFAIK All settings are cached, only read from sql the first time accessed.

comment:9 Changed 6 months ago by Peter Bennett <pbennett@…>

Resolution: fixed
Status: assignedclosed

In 6a5fb07fa/mythtv:

AVSync2: Use frame timestamps to determine elapsed play time

MythTV uses frame count to determine the elapsed time of a recording
for display, jumps, etc. This can be inaccurate with variable rate
content and also with frame doubling being done in the decoder.
This change recalculates the frame count based on the time code.
This ensures MythTV elapsed time will be accurate.

Fixes #13416

comment:10 Changed 6 months ago by Mark Spieth <mark@…>

In d5a2223bf2/mythtv:

AVSync2: Change to use monotonic timer

Use a monotonic timer to avoid possible problems when time is reset
during playback.

Refs #13416

Signed-off-by: Peter Bennett <pbennett@…>

comment:11 Changed 6 months ago by Peter Bennett <pbennett@…>

In bceea69806/mythtv:

AVSync2: Use frame timestamps to determine elapsed play time

MythTV uses frame count to determine the elapsed time of a recording
for display, jumps, etc. This can be inaccurate with variable rate
content and also with frame doubling being done in the decoder.
This change recalculates the frame count based on the time code.
This ensures MythTV elapsed time will be accurate.

Fixes #13416

(cherry picked from commit 6a5fb07fa17d7a7da09bd8a7be0394c8e4948122)

comment:12 Changed 3 months ago by Peter Bennett

Resolution: fixed
Status: closednew

Reopening as this needs to be fixed another way. The applied fix will be reverted.

Explanation -

It causes jumps in the frame numbers which prevent the VideoOutput classes detecting a discontinuity and releasing out of date reference frames for multi-frame deinterlacers

comment:13 Changed 2 months ago by Peter Bennett

Resolution: Fixed
Status: newclosed

Closing this again as the frame discontinuity issue is now being handled differently and this fix has been committed again. Also, changing the way this works will be a lot of work and it is working well as is.

Note: See TracTickets for help on using tickets.