[SOLVED] Incorrect aspect ratio with some tvheadend channels

  • I've noticed, that the amlogic hardware decoder (S905) switches to a resolution of 1440x1080 on some live tv channels (DVB-S, 1080i via tvheadend), while it should be 1920x1080. The problem does not occur, when playing a recording of the same channel. I think it's the same problem, gergov reported: LibreELEC

    After some tinkering, I've figured out that I can work around this with the following kodi patch:

    Of course, this isn't a correct fix, as it overrides the width for all 1440x1080 videos, but it works for me...

    Edited once, last by kszaq (September 27, 2016 at 1:14 PM).


  • Hi chbmuc,

    Some short video sample would be appreciated to reproduce the issue and help fix the issue in Kodi permanently.

    Thank you.

    With all Hungarian hd dvb-t channels I have this problem too.
    Resolution is 1440*1080I 50Hz
    Displayed with 4:3, but this is 16:9

    I have problem with 5.1 DD too. 2-3 times every minute dropped the sound for a half sec.
    When I switch to aac audio or mp3, then no drop.
    Dolby Digital I use with bitstream.
    When needed I can provide sample video tomorrow

  • I maked log.
    When I watch livetv with htsp profile, then aspect ratio is 4:3 (bad), when I watch the same channel recorded mkv video, then 16:9 (good)
    Here hearable audio drop too, what I already other topic describe.
    log-2016-09-10-05.13.49.zip

    Mkv record:
    H'irad'o.mkv
    H'irad'o.mkv

    With htsp profile choose I cannot record
    And with ts pass profile I have same result as mkv record

    Edited once, last by envagyok (September 10, 2016 at 6:52 AM).


  • I forget: livetv is 1440*1080 50i

  • I noticed this affects only h264 streams. I wrote a patch (all parts were already available in internet), modified DVDVideoCodecAmlogic.cpp and BitstreamConverter.cpp, created function similarly to mpeg2_sequence_header in BitStreamConverter.cpp that detects correct aspect ratio from h264 stream.
    It can be seen here Add aspect ratio detection for amcodec h264 · tarvip/SPMC@888e681 · GitHub IMHO it needs some work for upstream PR (need to split that huge function to smaller chunks, finish and use already existing SPS decoder instead the one I created), but not sure I have time for that.
    I am using SPMC on Android (WeTek Hub) instead of LibreELEC/Kodi, but it should work also with LibreELEC/Kodi.
    This also detects aspect ratio changes in the middle of stream, for example in my case some broadcasters are changing aspect ratio to 4:3 for 4:3 content and later changing back to 16:9.

    I have been using this approach for more than 2 weeks, so far it seems to work fine.

    Also added second patch that sets default aspect ratio to 16:9 for h264 SD content.
    If we have h264 SD content assume it is widescreen · tarvip/SPMC@e7ac400 · GitHub
    In my case most of the broadcasts are actually 16:9 not 4:3, without this patch first few frames were still shown as 4:3 and then correct ascpect ratio was detected and enabled.

    Edited once, last by pec (September 11, 2016 at 6:21 PM).

  • Edited once, last by chbmuc (September 16, 2016 at 6:56 PM).

  • pec @chbmub Many thanks for your work! I will ask Codesnake to have a look at the patch as I don't watch/have access to DVB channels and maybe this could also be merged to upstream project.

  • I have problem so far with sd dvb-t channels too.
    Hungarian dvb-t channels
    720*576 ar15:11 (when I record, I see this in tvheadend log), this is 4:3 stream, and played almost good.
    720*576 ar20:11 this is 16:9 channel, but played at 4:3 mode.
    1440*1080 ar16:9 played 4:3 too

    So please 720*576 with ar 20:11 make to switch 16:9

    I test DVB-T channels from Austria. The stream 720*576 ar16:9, it played perfect.

    Edited once, last by envagyok (September 17, 2016 at 6:47 AM).

  • envagyok The only way to get solutions fast is to get sources, fix it and compile yourself.

    Otherwise you have to wait patiently for a fix to be developed (this seems to be done), reviewed and tested. This can take undefined amount of time, you have to be patient.

    Edited once, last by kszaq (September 25, 2016 at 1:07 AM).

  • Good news: all of my aspect ratios perfect :)
    Bad news: sound gone. Or no sound, or very distorted ununderstandable. I tried videos/channels with ac3,mp2,aac,dts,dts-hd, with settings passtrough on,and off.
    There is some big problem w audio

    XJdM

    Maybe change iec958 hdmi audio from PCM16_RAW to PCM32 is the problem?
    Maybe audio decoder settings

  • Can you re-download a device tree from 7.0.2.007 build and try the devel build again? Amlogic introduced a new timer (BC_TIMER) that may be needed for audio to work correctly.


  • Can you re-download a device tree from 7.0.2.007 build and try the devel build again? Amlogic introduced a new timer (BC_TIMER) that may be needed for audio to work correctly.

    Is any possibility to put device tree to nand build without total reinstall?
    Or can I make sd install when le in NAND?


  • The easiest way is: download device tree and use dd if=new_device_tree.dtb of=/dev/dtb bs=256k.

    Ok. :)
    With the new device tree the Aspect ratio working perfectly.
    I will try the other thing too later (cec)

    For the new BC timer what news can we thanks?