Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#12479 closed Bug Report - General (fixed)

Mythtranscode HLS heavy distortion on Australian FTA recordings

Reported by: William Wilhelm <will@…> Owned by: JYA
Priority: minor Milestone: 0.28.1
Component: MythTV - General Version: Master Head
Severity: medium Keywords: HLS, AVF, mythtranscode
Cc: Ticket locked: no

Description

HLS transcoding via mythtranscode --hls is producing heavily distorted output (see attached screenshot) for recordings from 13/15 Australian Free-To-Air channels (ABC News 24 and SBS 2 are unaffected).

This issue has been present since commit db5c40cfc14dcca456446fe059b01fe90211dd60. Reverting this commit fixes the issue (patch attached). I haven't noticed any foul consequences after applying the patch myself, but welcome all knowledge on any effects this may have.

Attachments (3)

distortion.png (301.3 KB) - added by William Wilhelm <will@…> 4 years ago.
Screenshot of distortion
hls_fix.patch (1.5 KB) - added by William Wilhelm <will@…> 4 years ago.
myth-version.txt (752 bytes) - added by William Wilhelm <will@…> 4 years ago.

Download all attachments as: .zip

Change History (36)

Changed 4 years ago by William Wilhelm <will@…>

Attachment: distortion.png added

Screenshot of distortion

Changed 4 years ago by William Wilhelm <will@…>

Attachment: hls_fix.patch added

Changed 4 years ago by William Wilhelm <will@…>

Attachment: myth-version.txt added

comment:1 Changed 4 years ago by warpme@…

I have exactly the same HLS distortions on H264 SD channels. HD channels are OK. Reverting commit You mention fixes issue for me. This is definitely regression.

comment:2 Changed 4 years ago by perkins1724@…

This is impacting mythtranscode in FIFO mode as well. Reverting the commit identified above has resolved for me although I am not sure if it has other unintended side effects.

On master.

My notes here: http://www.gossamer-threads.com/lists/mythtv/users/591542

comment:3 Changed 4 years ago by JYA

Owner: set to JYA
Status: newaccepted

comment:4 Changed 4 years ago by antipode07@…

Exact same issue here with SD recordings from Dutch TV. HD channels are OK, SD channel recordings transcoded to H264 exhibit heavy distortion. Would be great to see this bug solved sometime soon.

System info:

# mythbackend --version Please attach all output as a file in bug reports. MythTV Version : v0.28-pre-3221-g7292e21 MythTV Branch : master Network Protocol : 87 Library API : 0.28.20151024-1 QT Version : 5.4.2

comment:5 Changed 4 years ago by Christophe Boyanique <tof-mythtvtrac@…>

Same bug here with french TV which switched one month ago do HD. I was using MythTV 0.27 (from ubuntu 15.10) and everything was working fine. After upgrading to Ubuntu 16.04 with MythTV 0.28 I encounter this bug with some channels that are 1440x1080 sized. Full HD channels (1920x1080) are ok.

Here is an example of TS file mediainfo output:

Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : 27
Duration                                 : 56s 440ms
Bit rate                                 : 4 086 Kbps
Width                                    : 1 440 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 fps
Standard                                 : Component
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : MBAFF
Scan type, store method                  : Separated fields
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 0.105
Stream size                              : 27.5 MiB (89%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

I can confirm that using hls_fix.patch resolves the problem.

I uploaded all material to http://ombos.raceme.org/tof/nobackup/mythtranscode-0.28/ if someone is interrested to investigate, you will find:

transcode.txt                    detail of commands used and results

TF1-1920w-mythtranscode.out      screen output (1920 width)
TF1-1920w-mythtranscode.raw      raw file output (plays correctly on mplayer)

FR5-1440w-mythtranscode.out      screen output (1440 width)
FR5-1440w-mythtranscode.raw      raw file output (corrupted)
FR5-1440w-mplayer-correct.jpg    what should be displayed (original ts file)
FR5-1440w-mplayer-corrupted.jpg  what is played with mplayer
FR5-1440w-mplayer-1472w-1.jpg    1st image with mplayer with 1472 forced width
FR5-1440w-mplayer-1472w-2.jpg    2nd image with mplayer with 1472 forced width

comment:6 Changed 4 years ago by JYA

Could you post a sample video somewhere? First 50MB will do. Thank you.

comment:7 Changed 4 years ago by William Wilhelm <will@…>

Here is a recording (5.8 MB) which mythtranscode --hls distorts http://will.wilhelm.com.au/fails.ts. (File is pre-transcoding)

comment:8 Changed 4 years ago by Christophe Boyanique <tof-mythtvtrac@…>

Here is another one (first 50 Mb, french DVB-T 1440x1080) which mythtranscode -fifo distorts (same problem i suppose): http://ombos.raceme.org/tof/nobackup/mythtranscode-0.28/2005_20160509043500.ts

comment:9 Changed 3 years ago by seven@…

Still a problem in v0.28-46-ge5ce273, let me know if you need more samples

comment:10 in reply to:  6 Changed 3 years ago by seven@…

Replying to jyavenard:

Could you post a sample video somewhere? First 50MB will do. Thank you.

Hi JYA,

any reason why this cannot be reverted?

comment:11 Changed 3 years ago by mailaccountfueralles@…

Same issue here in FIFO-Mode on german SD-Channels (720x576 and aspect ratio 4:3 or 16:9) after upgrading MythTV from 0.27 to 0.28. Video is distrorted, Audio seems to be ok.

Output of SD transcode (aspect ratio 4:3)

...
2016-08-16 19:42:54.681995 N  Transcoding from /var/lib/mythtv/recordings/30487_20160809172000.ts to FIFO
2016-08-16 19:42:54.805519 I  AFD: codec MP2 has 2 channels
2016-08-16 19:42:54.805693 I  AFD: Opened codec 0x128fa20, id(MP2) type(Audio)
2016-08-16 19:42:54.806031 I  AFD: codec MP2 has 2 channels
2016-08-16 19:42:54.806132 I  AFD: Opened codec 0x11ca320, id(MP2) type(Audio)
2016-08-16 19:42:54.806231 I  AFD: Opened codec 0x11cb9a0, id(DVB_SUBTITLE) type(Subtitle)
2016-08-16 19:42:54.806248 I  AFD: codec AC3 has 2 channels
2016-08-16 19:42:54.806698 I  AFD: Opened codec 0x11cc5c0, id(AC3) type(Audio)
2016-08-16 19:42:54.810886 I  AFD: Opened codec 0x128eee0, id(MPEG2VIDEO) type(Video)
2016-08-16 19:42:54.811379 N  AudioPlayer: Enabling Audio
2016-08-16 19:42:54.834871 I  Honoring the cutlist while transcoding
2016-08-16 19:42:54.835823 I  Cutlist        : 0-15744,37064-52482
2016-08-16 19:42:54.835832 I  Original Length: 52482 frames
2016-08-16 19:42:54.835840 I  New Length     : 21320 frames
2016-08-16 19:42:54.870092 I  FifoVideoWidth 720
2016-08-16 19:42:54.870114 I  FifoVideoHeight 576
2016-08-16 19:42:54.870138 I  FifoVideoAspectRatio 1.77778
2016-08-16 19:42:54.870158 I  FifoVideoFrameRate 25
2016-08-16 19:42:54.870170 I  FifoAudioFormat ac3
2016-08-16 19:42:54.870177 I  FifoAudioChannels 2
2016-08-16 19:42:54.870189 I  FifoAudioSampleRate 48000
2016-08-16 19:42:54.870352 I  Created video fifo: /tmp/mythar14789/vidout
2016-08-16 19:42:54.871591 I  Created audio fifo: /tmp/mythar14789/audout
2016-08-16 19:42:54.872006 I  Video 720x576@25fps Audio rate: 48000
2016-08-16 19:42:54.872016 I  Created fifos. Waiting for connection.
2016-08-16 19:42:54.872061 I  Dumping Video and Audio data to fifos
2016-08-16 19:42:54.882977 I  Player(0): Fast-Forwarding from 0 to 15546
2016-08-16 19:42:54.937520 I  Clean cut: discarding frame from 15546 to 15744: vid 198 aud 380160
2016-08-16 19:42:54.939073 I  Audio is 40ms behind video at # 1: auddelta=86143215, viddelta=86143175
2016-08-16 19:42:54.939088 I  Dropping video frame
2016-08-16 19:42:55.285101 I  Clean cut: end of video cut; audio frames left to cut 1920
2016-08-16 19:42:55.289897 I  Clean cut: end of audio cut; vidio frames left to cut 0
...

Output of mythtranscode --version

MythTV Version : v0.28-47-g29d7067
MythTV Branch : fixes/0.28
Network Protocol : 88
Library API : 0.28.20160309-1
QT Version : 5.2.1
Options compiled in:
 linux profile use_hidesyms using_alsa using_oss using_pulse using_pulseoutput using_backend using_bindings_perl using_bindings_python using_bindings_php using_crystalhd using_dvb using_firewire using_frontend using_hdhomerun using_vbox using_ceton using_hdpvr using_ivtv using_joystick_menu using_libcec using_libcrypto using_libdns_sd using_libfftw3 using_libxml2 using_lirc using_mheg using_opengl using_opengl_video using_opengl_themepainter using_qtwebkit using_qtscript using_qtdbus using_sdl using_taglib using_v4l2 using_x11 using_xrandr using_xv using_profiletype using_bindings_perl using_bindings_python using_bindings_php using_freetype2 using_mythtranscode using_opengl using_vaapi using_vdpau using_ffmpeg_threads using_mheg using_libass using_libxml2

comment:12 Changed 3 years ago by William Wilhelm <will@…>

@jyavenard Any chance of movement on this? Recent discussion on mailing list has more people hitting this problem.

comment:13 Changed 3 years ago by JYA

going to work on it now..

comment:14 in reply to:  7 Changed 3 years ago by JYA

Replying to William Wilhelm <will@…>:

Here is a recording (5.8 MB) which mythtranscode --hls distorts http://will.wilhelm.com.au/fails.ts. (File is pre-transcoding)

Could you provide me with the full command line (one that doesn't require to have a full backend setup with recordings) to reproduce the problem?

Thank you. JY

comment:15 Changed 3 years ago by JYA

got it, can reproduce thank you for your perseverance.

comment:16 Changed 3 years ago by JYA

FIFO mode is a different story... The script used to process the fifo output should be adjusted to account for the new stride size...

comment:17 Changed 3 years ago by seven@…

Thanks JYA, if you would like someone to test once you have a fix, happy to test but I dont yet have a build environment, if you could provide deb's of publish to your repo I'll happily test.

comment:18 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

Resolution: fixed
Status: acceptedclosed

In 5e3a9bf2ce9ffa3e46b5691340e0feaae8ffb5f7/mythtv:

Properly handle stride size when transcoding.

Fixes #12479

comment:19 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 1d9033084562f24b7e0a4003dc05da6cea4c19f8/mythtv:

Properly handle stride size when transcoding in fifo mode.

Fixes #12479

comment:20 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 97054767dd3f838ceb02998a69703c574cdb1eb3/mythtv:

Fix FIFO transcoding.

There were two issues at play.
One that was a regression over 0.27, in that it was assumed the stride was identical to the width which is no longer true from 0.28
Second, if the file being transcoded changed resolution, the video output would have been corrupted.

TODO: Handle codecs not returning a YUV420 frame.

Fixes #12479

comment:21 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In cea674d6b6198f61d1bfed1c59ddf34ce99262e0/mythtv:

Fixes transcoding when decoder doesn't ouput YUV420 frame.

Fix #12479

comment:22 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 86962abc626add3d7f2fbac8646c7d0194e4a8cb/mythtv:

Fix RTjpeg transcoding.

Fixes #12479

comment:23 in reply to:  17 Changed 3 years ago by JYA

Replying to seven@…:

Thanks JYA, if you would like someone to test once you have a fix, happy to test but I dont yet have a build environment, if you could provide deb's of publish to your repo I'll happily test.

The changes have been pushed to master. They should be in mythbuntu daily build in the next day or so...

Let me know how it goes, if no major problems are found, I'll uplift to fixes/0.28.

I've tested the following setup (they all had issues one way or another)

  • --avf (with both 1440 and 1920 wide recordings)
  • --hls
  • --mpeg2
  • --fifodir
  • Transcoding to nuv/mpeg4
  • Transcoding to nuv/RTjpeg

Some modes had been broken for quite a while I'm afraid.

comment:24 Changed 3 years ago by seven@…

Is master still compatible with 0.28 Schema wise?

comment:25 Changed 3 years ago by JYA

The schema is, but the difference with the protocol version will make a backend not work simply due to 28 vs 29.

Could always uplift to 0.28 now, and wait for the consequences... it should be fairly safe

comment:26 Changed 3 years ago by seven@…

That would be great, whats the worst that could happen.

comment:27 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 261858dc9db063c84e0e462e5111c98c4a18a38e/mythtv:

Properly handle stride size when transcoding.

Fixes #12479

(cherry picked from commit 5e3a9bf2ce9ffa3e46b5691340e0feaae8ffb5f7)

comment:28 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In f513db7548ba14ed52fda13fa1108b478dbf0c23/mythtv:

Properly handle stride size when transcoding in fifo mode.

Fixes #12479

(cherry picked from commit 1d9033084562f24b7e0a4003dc05da6cea4c19f8)

comment:29 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 825d528a6ec42103c600b8991613f4f6b3d19775/mythtv:

Fix FIFO transcoding.

There were two issues at play.
One that was a regression over 0.27, in that it was assumed the stride was identical to the width which is no longer true from 0.28
Second, if the file being transcoded changed resolution, the video output would have been corrupted.

TODO: Handle codecs not returning a YUV420 frame.

Fixes #12479

(cherry picked from commit 97054767dd3f838ceb02998a69703c574cdb1eb3)

comment:30 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 49ef81ea4c31dea3140fc3c0f69423660b2e5900/mythtv:

Fixes transcoding when decoder doesn't ouput YUV420 frame.

Fix #12479

(cherry picked from commit cea674d6b6198f61d1bfed1c59ddf34ce99262e0)

comment:31 Changed 3 years ago by Jean-Yves Avenard <jyavenard@…>

In 5bf021a477e998267ee1ebd2f09c39b96962ebb2/mythtv:

Fix RTjpeg transcoding.

Fixes #12479

(cherry picked from commit 86962abc626add3d7f2fbac8646c7d0194e4a8cb)

comment:32 Changed 3 years ago by JYA

Milestone: unknown0.28.1

comment:33 Changed 3 years ago by Andy Harvey <Andy@…>

For info: I have just opened ticket #12954 as the changes to NuppelVideoRecorder?.cpp have broken my recording from a USBTV encoder.

Note: See TracTickets for help on using tickets.