[mythtv] HVEC frame counting broken

John P Poet jppoet at gmail.com
Sun Sep 25 15:43:27 UTC 2022


On Sun, Sep 25, 2022 at 8:07 AM Scott Theisen <scott.the.elm at gmail.com>
wrote:

> On 9/25/22 00:10, John P Poet wrote:
>
> On Sat, Sep 24, 2022 at 7:01 PM John P Poet <jppoet at gmail.com> wrote:
>
>> On Sat, Sep 24, 2022 at 3:35 PM John P Poet <jppoet at gmail.com> wrote:
>>
>>> On Sat, Sep 24, 2022 at 3:38 AM John Pilkington <johnpilk222 at gmail.com>
>>> wrote:
>>>
>>>> On 24/09/2022 02:18, John P Poet wrote:
>>>> > On Fri, Sep 23, 2022 at 7:02 PM John P Poet <jppoet at gmail.com
>>>> > <mailto:jppoet at gmail.com>> wrote:
>>>> >
>>>> >     On Fri, Sep 23, 2022 at 6:31 PM Scott Theisen
>>>> >     <scott.the.elm at gmail.com <mailto:scott.the.elm at gmail.com>> wrote:
>>>> >
>>>> >         On 9/23/22 18:59, David Engel wrote:
>>>> >          > On Fri, Sep 23, 2022 at 04:38:19PM -0600, John P Poet
>>>> wrote:
>>>> >          >> On Fri, Sep 23, 2022 at 4:32 PM John P Poet
>>>> >         <jppoet at gmail.com <mailto:jppoet at gmail.com>> wrote:
>>>> >          >>
>>>> >          >>> I just upgraded from 39b850f1a9 to 06da3119d5 and
>>>> >         discovered that frame
>>>> >          >>> counting is now broken for ffmpeg/nvenc encoded HVEC. The
>>>> >         OSD indicates
>>>> >          >>> that the shows are twice as long as they really are.
>>>> >          >>>
>>>> >          >>> This weekend I will do a bisec to figure out which commit
>>>> >         did the damage,
>>>> >          >>> unless someone else already knows?
>>>> >          >>>
>>>> >          >> Sorry. Make that  26b2e76ae to 06da3119d5.
>>>> >          > It's probably the very, recent, ffmpeg merge.
>>>> >          >
>>>> >          > While you're in there, though, would you mind looking into
>>>> the
>>>> >          > long-standing issue with mythcommflag --rebuild not working
>>>> >         on HEVC
>>>> >          > encoded files, or at least those encoded by HandBarke? :)
>>>> >
>>>> >         A note on bisecting the recent FFmpeg merge:
>>>> >
>>>>  a1868defe9c48c5ca53e1c5d26010a19ebd7db13..753a94ccb7a39ef66c6f8591e5784bf08a1b002e
>>>> >
>>>> >         wont compile (inclusive..exclusive) fully because of how I
>>>> split
>>>> >         the
>>>> >         commits.
>>>> >
>>>> >         My harmonization of libavcodec/mpegts-mythtv.c is also in the
>>>> >         range you
>>>> >         gave.  While each commit compiles, I didn't test functionality
>>>> >         of each
>>>> >         commit.  But, even if the container is an MPEG-TS, I would
>>>> also
>>>> >         suspect
>>>> >         the new version of FFmpeg.
>>>> >
>>>> >         Could be related to (HEVC):
>>>> >         Playback of DVB recordings shows displayed time doubled ·
>>>> Issue
>>>> >         #548 ·
>>>> >         MythTV/mythtv · GitHub
>>>> >         https://github.com/MythTV/mythtv/issues/548
>>>> >         <https://github.com/MythTV/mythtv/issues/548>
>>>> >         ?
>>>> >
>>>> >         Regards,
>>>> >
>>>> >         Scott
>>>> >
>>>> >
>>>> >     Thank you Scott.
>>>> >
>>>> >     What is bizaar is that I went back to 39b850f1a9 and it was still
>>>> >     doubling. I could have sworn that was the commit I was running
>>>> >     before! I ended up jumping back and back and back until I randomly
>>>> >     found 31ee7f9e64 to work correctly. So, now I have to say the
>>>> >     problem occured somewhere between 31ee7f9e64 and 3e802f9075. I
>>>> will
>>>> >     try and narrow it down tomorrow.
>>>> >
>>>> >
>>>> > Okay, so I was running  39b850f1a9 on my production machine and
>>>> > 26b2e76ae on my development machine. I had not noticed the issue on
>>>> my
>>>> > dev machine.
>>>> >
>>>> > The problem does seem to be between 31ee7f9e64 and 3e802f9075.
>>>> Looking
>>>> > at the commits in that range, 40fb3cd09d and db93047399 seem like
>>>> > possibilities. My production machine is now recording stuff for the
>>>> > evening so I will test more tomorrow.
>>>> >
>>>> > John
>>>>
>>>> Issue #548 was reported as being years-old for some HEVC recordings.  I
>>>> had similar issues with just one of six DVB-T (mpeg2ts) multiplexes,
>>>> now
>>>> fixed by PR#610.
>>>>
>>>> mythcommflag --rebuild gave good frame counts for me, but gigem says it
>>>> doesn't work with handbrake's HEVC encoding.
>>>>
>>>> It looks to me as if ffmpeg doesn't understand 'with field pictures'
>>>> encoding.
>>>>
>>>
>>> Doing a git bisect on my 10 year old production mythbackend machine is a
>>> bit painful, but the result is that 7b2ac1eeb5 is the culprit. I see that
>>> a6e1128e0f2 fixes a problem caused by 7b2ac1eeb5 but not this one. I will
>>> work on narrowing down the problem.
>>>
>>
>>  HEVCParser::parseSPS is seriously broken with 7b2ac1eeb5. It does not
>> even get the sps_id correct, let alone width, height or timescale. I have
>> spent the last several hours trying to figure out exactly where the parsing
>> goes wrong but have not tracked it down yet.
>>
>
> I really think that 7b2ac1eeb5 should be reverted. At least until a new
> version can be written which doesn't break so much logic. I tried just
> doing that against master, but myth's ffmpeg api has changed enough that it
> is not straight forward...
>
> John
>
>
> The API hasn't changed; you just need to re-add the exports.  In addition
> to reverting a6e1128e0f2 and 7b2ac1eeb5, you also need to first partially
> revert
> https://github.com/MythTV/mythtv/commit/4e5b66eaab3936c90f4de1d2e8318f024c771f0b
> like this:
>
> ```
> diff --git a/mythtv/external/FFmpeg/libavcodec/libavcodec.v
> b/mythtv/external/FFmpeg/libavcodec/libavcodec.v
> index d863e056a5..3f01fd3fd5 100644
> --- a/mythtv/external/FFmpeg/libavcodec/libavcodec.v
> +++ b/mythtv/external/FFmpeg/libavcodec/libavcodec.v
> @@ -4,6 +4,9 @@ LIBAVCODEC_MAJOR {
>          avcodec_*;
>          avpriv_*;
>          avsubtitle_free;
> +        ff_ue_golomb_vlc_code;
> +        ff_golomb_vlc_len;
> +        ff_se_golomb_vlc_code;
>      local:
>          *;
>  };
> ```
>
> However, I would also like to hide the includes of get_bits.h and golomb.h
> in the parsers' .cpp files.
>
> Could you share your sample and instructions to reproduce so I can test
> it?  I would prefer to fix it instead of reverting it since these are
> internal FFmpeg headers.
>
> Thanks
>
> Scott
>
>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-dev
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org


Thank you Scott. I just uploaded a HEVC sample to dropbox. It should be
shared with you.

Without 7b2ac1eeb5, HEVCParser::parseSPS detects the
sps_id: 0
width, height: 1920x1088
unitsInTick / timeScale: 166817 / 10000000

With 7b2ac1eeb5, HEVCParser::parseSPS the spd_id, width and height are
garbage and the unitsinTick / timeScale are never decoded --
vps_extension_flag is zero.

My best guess is that there is an alignment issue and the BitReader that is
being passed into HEVCParser::parseSPS is not pointing at the correct
position.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20220925/dfacca64/attachment.htm>


More information about the mythtv-dev mailing list