[mythtv] Jitter with time stretch

Peter Bennett pb.mythtv at gmail.com
Mon Jul 16 14:47:53 UTC 2018



On 07/15/2018 10:02 PM, David Engel wrote:
> On Sun, Jul 15, 2018 at 07:05:21PM -0400, Peter Bennett wrote:
>> On 07/15/2018 04:50 PM, David Engel wrote:
>>> I found it!  In MythPlayer::SetFrameInterval(), the frame_interval and
>>> avsync_predictor_enabled are getting set wrong because frame_period
>>> passed in is wrong.  It is still set the 30fps equivalent instead of
>>> the 60fps equivalent after the frame doubling in decoding.
>>>
>>> After forcing frame_interval and avsync_predictor_enabled to the
>>> correct values, I get smooth playback of my sample, 1080i content on
>>> my 1080p TV at speed upto 1.90x.  At 1.95x, a little bit of
>>> non-predicted adjustment is needed, but it's barely noticeable.  At
>>> 2.00x, it a little more noticeable, but really isn't too bad.
>>>
>>> On my 4k TV, the results aren't quite as good.  The video gets
>>> noticeably jittry at 1.55x.  It seems the scaling from 1080 to 4k
>>> impacts how fast the decoding and deinterlacing can go.  I wonder what
>>> effect using Surface rendering would have on that.
>>>
>>> Note that the above was all done with using the old numbers of buffers
>>> (vbuffers.Init(31, true, 1, 12, 4, 2)).  I'm going to see how far I
>>> can reduce them without degrading the timestretching performance.
> Things seem to be okay with the modified numbers of buffers
> (vbuffers.Init(4, true, 1, 2, 2, 1)).  I have more TV watching, I mean
> testing, to do, though. :)
I am adding a line to only allocate the lower number of buffers if it is 
mediacodec. I found that using the smaller number on Linux with OpenGL 
profile turns playback into a slideshow with corrupted frames.
>>> Finally, I don't have a proposed fix for the correct setting of
>>> frame_interval and avsync_predictor_enabled yet.  I'll defer to those
>>> of you more familiar with the MythPlayer setup for the time being.  It
>>> probably needs to be tied into the code that Peter added to detect the
>>> frame doubling during decoding.
>>>
>>> David
>>>
>>>
>> I agree - frame_interval needs fixing. We just need to be careful of not
>> using the adjusted value when seeking, because for file access it uses the
>> original frame number. For example in MythPlayer::UpdateFFRewSkip, I amnot
>> quite sure what that is doing with it. I will go through and check all the
>> places where frame_interval is used and see if I can get it right.
> We could possibly get by with just a new variable that flags when the
> decoder doubles the frame rate.  I think the modified frame_interval
> is only needed in MythPlayer::SetFrameInterval() where
> avsync_predictor_enabled is initialized and in MythPlayer::AVSync()
> where avsync_predictor_enabled is checked and used.
I already have a flag stored in the decoder and accessed from mythplayer 
using "decoder->GetfpsMultiplier()" It takes values 1 or 2, 1=normal, 
2=doubled frames as with mediacodec.

I am currently using fpsMultiplier only in AVSync where frame_delay is 
calculated from frame_interval. I need to take that out and change the 
calculation of frame_interval itself to use fpsMultiplier instead.

Peter



> David



More information about the mythtv-dev mailing list