Skip to content

Conversation

@ulmus-scott
Copy link
Contributor

This was fairly straightforward, only a few minor merge conflicts in FFmpeg due to our modifications.

I'll rebase and see about upstreaming more of our changes later.

Checklist

In mpeg_decode_a53_cc() only the A/53 part 4 CC data ("GA94") is saved between
frames. The other formats incorrectly created a larger buffer than they use
since a705bcd763e344fac191e157ffeddc285388b7fa because they did not append to
the previous data.

The a53_buf_ref is added to the frame in mpeg_field_start() which will only be
called in decode_chunks() if not all of the picture data slices are skipped.

For these formats, utilize the data added to the buffer in case frames are skipped
(concatenating the CC data until a frame can be exported), in a similar fashion to
the A/53 part 4 logic.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Marth64 <marth64@proxyid.net>
(cherry picked from commit 8ad2d1919fdf8a33f72761799367293bbb379b55)
The format is used by at least Dish Network, but is not
defined in any DVB standard, so remove references to DVB.

This is a simple rename, no functional change.

Signed-off-by: Marth64 <marth64@proxyid.net>
(cherry picked from commit 33daef5f498c7c6092dd1440481fa898f7c83cf4)
IVTV, a Linux driver for TV tuners, and V4L2 utilize
a coding named after IVTV to carry sliced VBI data
in MPEG streams produced by tuner cards with
VBI capture capability and an MPEG-2 encoder SoC.

IVTV or V4L2 driver will transport the coded data into a
MPEG-PS private stream ("IVTV") that can be captured
from the card alongside the video/audio.

The data could include:
EIA-608, Teletext, WSS (PAL widescreen signaling),
or VPS (PAL VCR signaling).

Signed-off-by: Marth64 <marth64@proxyid.net>
(cherry picked from commit 9fb806fa57731690852dfb9ac2a0ae4ad5692fbf)

avformat/mpeg: demux ivtv captions

The packets start 'IVT0' or 'ivt0'
('I' = 0x49, 'i' = 0x69).

Signed-off-by: Marth64 <marth64@proxyid.net>
(cherry picked from commit e838e6cbe2d8ab4ad9cea85e04e545ff27e97bdb)
It has been split from FFmpeg in version 8.0.
It was pointed out when trying to upstream this change that
the crash MythTV was trying to fix was already fixed by
the prior if (pmt_pid == ts->current_pid) test.  The PID
for the PAT is 0 and the added check was originally just
against 0.
@warpme
Copy link
Contributor

warpme commented Dec 18, 2025

Scott,
I'm testing this pull on various platforms (x86, arm64)
On my intel n3450 frontend it works but i'm getting in log some errors (abelit playback seems to be ok):
(e.g. pls look arround 2025-12-18 10:47:12.029445)
my sys is: myth-master current head, 6.18.0 kernel, latest intel-gmmlib (22.9.0) and latest intel media driver (25.4.5)

2025-12-18 10:47:06.766711 I  TV::StartPlayer(): Created player.
2025-12-18 10:47:06.766736 I  TV::HandleStateChange(): Changing from None to WatchingLiveTV
2025-12-18 10:47:06.766742 I  TV::HandleStateChange(): State is LiveTV
2025-12-18 10:47:06.768291 I  TV::HandleStateChange(): UpdateOSDInput done
2025-12-18 10:47:06.768308 I  TV::HandleStateChange(): UpdateLCD done
2025-12-18 10:47:06.769215 I  TV::HandleStateChange(): ITVRestart done
2025-12-18 10:47:06.770995 I  ScreenSaverX11: Inhibited X11 screensaver
2025-12-18 10:47:06.772919 I  TV::HandleStateChange(): Main UI disabled.
2025-12-18 10:47:06.772949 I  TV::StartTV(): Entering main playback loop.
2025-12-18 10:47:06.857150 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 10:47:06.860878 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 10:47:06.862293 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 10:47:06.862324 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 10:47:06.868731 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 10:47:06.870905 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 10:47:06.870936 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 10:47:06.872725 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 10:47:06.872761 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 10:47:10.249584 I  Player(0): Opening 'myth://mythtv/8049_20251218094709.ts'
2025-12-18 10:47:11.463373 W  avcodec_find_decoder fail for 94215
2025-12-18 10:47:11.463417 I  AFD: codec mp2 has 2 channels
2025-12-18 10:47:11.463556 I  AFD: Opened codec 0x2346ef00, id(mp2) type(Audio)
2025-12-18 10:47:11.463588 I  AFD: codec ac3 has 2 channels
2025-12-18 10:47:11.463744 I  AFD: Opened codec 0x23482400, id(ac3) type(Audio)
2025-12-18 10:47:11.463764 I  AFD: Opened codec 0x23489dc0, id(dvb_subtitle) type(Subtitle)
2025-12-18 10:47:11.463874 I  AFD: Frame rate 25.00 rounded to nearest standard rate 25.00
2025-12-18 10:47:11.464004 I  VideoOutput: SetDeinterlacing (Doublerate 0): Single High|CPU|GLSL|DRIVER Double None
2025-12-18 10:47:11.482705 I  AFD: Using vaapi for video decoding
2025-12-18 10:47:11.482916 I  AFD: Opened codec 0x227cdb00, id(h264) type(Video)
2025-12-18 10:47:11.633585 I  AOBase: Opening audio device 'default' ch 2(2) sr 48000 sf signed 16 bit reenc 0
2025-12-18 10:47:11.806022 N  Player(0): Waited 102ms for video buffers AAAAAAAAAAAAAA
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
2025-12-18 10:47:11.864540 I  PlayerVideo: Queuing callback for VAAPI context creation
2025-12-18 10:47:11.869661 I  PlayerVideo: Executing VAAPI context creation
2025-12-18 10:47:11.875128 I  VAAPIInterop: Created VAAPI 1.22 display for GL-VAAPI-DRM (Intel iHD driver for Intel(R) Gen Graphics - 25.4.5 (73d56b4de))
2025-12-18 10:47:11.907799 N  Player(0): Waited 204ms for video buffers AAAAAAAAAAAAAA
2025-12-18 10:47:11.987032 E  AFD: Unknown audio decoding error
2025-12-18 10:47:11.987121 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 10:47:11.987313 I  Display: Using current mode 1920x1080@50Hz
2025-12-18 10:47:11.991177 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 10:47:12.029445 E  VAAPIInterop: avfilter_graph_create_filter failed for buffer source
2025-12-18 10:47:12.029606 E  VAAPIInterop: Failed to create VAAPI deinterlacer 2x VAAPI Compensated - disabling
2025-12-18 10:47:12.029911 I  GLVid: New frame format: None:None 1920x1080 (Tex: 2D) -> VAAPI:NV12 1920x1080 (Tex: 2D)
DRM_IOCTL_I915_GEM_CONTEXT_DESTROY failed: Bad file descriptor
2025-12-18 10:47:18.542378 I  OpenGLInterop: Deleted 28 textures in 14 groups
2025-12-18 10:47:20.726307 I  Player(0): Opening 'myth://mythtv/23806_20251218094719.ts'
2025-12-18 10:47:20.726384 W  RingBuf(myth://mythtv/23806_20251218094719.ts): Not starting read ahead thread - already running
2025-12-18 10:47:21.422761 W  avcodec_find_decoder fail for 98305
2025-12-18 10:47:21.422896 I  AFD: codec mp2 has 2 channels
2025-12-18 10:47:21.422929 I  AFD: Opened codec 0x2347f840, id(mp2) type(Audio)
2025-12-18 10:47:21.422943 I  AFD: codec mp2 has 2 channels
2025-12-18 10:47:21.422956 I  AFD: Opened codec 0x23490d80, id(mp2) type(Audio)
2025-12-18 10:47:21.422977 I  AFD: Opened codec 0x22869240, id(dvb_subtitle) type(Subtitle)
2025-12-18 10:47:21.423074 I  AFD: Frame rate 25.00 rounded to nearest standard rate 25.00
2025-12-18 10:47:21.423122 I  VideoOutput: SetDeinterlacing (Doublerate 0): Single High|CPU|GLSL|DRIVER Double None
2025-12-18 10:47:21.423144 I  AFD: Using vaapi for video decoding
2025-12-18 10:47:21.423320 I  AFD: Opened codec 0x22cb8dc0, id(h264) type(Video)
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
2025-12-18 10:47:21.683672 N  Player(0): Waited 103ms for video buffers AAAAAAAAAAAAAA
2025-12-18 10:47:21.740156 I  PlayerVideo: Queuing callback for VAAPI context creation
2025-12-18 10:47:21.742091 I  PlayerVideo: Executing VAAPI context creation
2025-12-18 10:47:21.744443 I  VAAPIInterop: Created VAAPI 1.22 display for GL-VAAPI-DRM (Intel iHD driver for Intel(R) Gen Graphics - 25.4.5 (73d56b4de))
2025-12-18 10:47:21.758626 E  AFD: Unknown audio decoding error
2025-12-18 10:47:21.766288 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 10:47:21.767233 E  VAAPIInterop: avfilter_graph_create_filter failed for buffer source
2025-12-18 10:47:21.767419 E  VAAPIInterop: Failed to create VAAPI deinterlacer 2x VAAPI Compensated - disabling
2025-12-18 10:47:21.896333 N  Player(0): Waited 101ms for video buffers AAAAApAAAAAAAL
2025-12-18 10:47:22.258033 N  Player(0): Waited 105ms for video buffers AAAAAfPpAAAAAL
2025-12-18 10:50:37.390159 N  Player(0): Waited 103ms for video buffers AAPAAALfAAApAA
2025-12-18 10:52:09.317818 I  Received notification 'System', timeout 12
2025-12-18 10:55:01.903872 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 10:55:01.903927 W  OpenGLInterop: Not a valid hardware frame
2025-12-18 10:55:01.904508 W  OpenGLInterop: Not a valid hardware frame
2025-12-18 10:55:01.935576 W  TV::ProcessNetworkControlCommand(): Ignoring network control command because ignoreKeys is set
2025-12-18 10:55:01.940972 W  TV::ProcessNetworkControlCommand(): Ignoring network control command because ignoreKeys is set
2025-12-18 10:55:02.026621 N  Player(0): Waited 102ms for video buffers A(ap)AAAAAAAAAAAL
2025-12-18 10:55:02.128331 N  Player(0): Waited 204ms for video buffers A(ap)AAAAAAAAAAAL
2025-12-18 10:55:02.229885 N  Player(0): Waited 305ms for video buffers A(ap)AAAAAAAAAAAL
2025-12-18 10:55:02.331626 N  Player(0): To see more buffering messages use -v playback
2025-12-18 10:55:02.668539 E  RingBuf(myth://mythtv/23806_20251218095500.ts): MythMediaBuffer::Reset() nonzero readpos.  toAdjust: 1 readpos: 325868 readAdjust: 276785444
2025-12-18 10:55:02.668966 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 10:57:12.185269 I  Received notification 'Konto E-Mail:', timeout 8
2025-12-18 10:57:26.704940 I  Received notification 'Konto E-Mail:', timeout 8
2025-12-18 11:00:01.294161 I  RingBuf(myth://mythtv/23806_20251218095500.ts): Checking to see if there's a new livetv program to switch to..
2025-12-18 11:00:01.296774 I  RingBuf(myth://mythtv/23806_20251218095500.ts): Checking to see if there's a new livetv program to switch to..
2025-12-18 11:00:01.298557 E  RingBuf(myth://mythtv/23806_20251218095500.ts): ReadPriv(..32768, normal) -- timed out waiting for data (1 ms)
2025-12-18 11:00:01.667492 E  decoding error End of file (-541478725)
2025-12-18 11:00:01.667562 N  PlayerUI: LiveTV forcing JumpTo 1
2025-12-18 11:00:01.700311 E  decoding error End of file (-541478725)
DRM_IOCTL_I915_GEM_CONTEXT_DESTROY failed: Bad file descriptor
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
2025-12-18 11:00:01.792686 I  PlayerVideo: Queuing callback for Destroy OpenGL interop
2025-12-18 11:00:01.795857 I  PlayerVideo: Executing Destroy OpenGL interop
2025-12-18 11:00:01.796223 I  OpenGLInterop: Deleted 28 textures in 14 groups
2025-12-18 11:00:01.797591 I  PlayerVideo: Queuing callback for VAAPI context creation
2025-12-18 11:00:01.802881 I  PlayerVideo: Executing VAAPI context creation
2025-12-18 11:00:01.805363 I  VAAPIInterop: Created VAAPI 1.22 display for GL-VAAPI-DRM (Intel iHD driver for Intel(R) Gen Graphics - 25.4.5 (73d56b4de))
2025-12-18 11:00:01.821828 I  VideoOutput: SetDeinterlacing (Doublerate 1): Single High|CPU|GLSL|DRIVER Double High|CPU|GLSL|DRIVER
2025-12-18 11:00:01.822068 E  AFD: Unknown audio decoding error
2025-12-18 11:00:01.822791 E  VAAPIInterop: avfilter_graph_create_filter failed for buffer source
2025-12-18 11:00:01.822912 E  VAAPIInterop: Failed to create VAAPI deinterlacer 2x VAAPI Compensated - disabling
2025-12-18 11:03:47.723616 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 11:03:47.723620 I  Qt: libpng warning: iCCP: cHRM chunk does not match sRGB
2025-12-18 11:03:47.723785 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 11:03:47.723788 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 11:03:47.723790 I  Qt: libpng warning: iCCP: cHRM chunk does not match sRGB
2025-12-18 11:03:47.723792 I  Qt: libpng warning: iCCP: cHRM chunk does not match sRGB
2025-12-18 11:03:47.723937 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 11:03:47.723965 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 11:03:47.723968 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 11:03:47.723986 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 11:03:47.724131 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 11:03:47.724165 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 11:03:47.725186 I  Qt: libpng warning: iCCP: known incorrect sRGB profile
2025-12-18 11:03:47.725192 I  Qt: libpng warning: iCCP: cHRM chunk does not match sRGB
2025-12-18 11:03:47.725657 I  Qt: libpng warning: known incorrect sRGB profile
2025-12-18 11:03:47.725699 I  Qt: libpng warning: profile matches sRGB but writing iCCP instead
2025-12-18 11:03:51.705354 I  PlayerFPS:   24.99 Mean: 40022 Std.Dev:  1009 CPUs: 8% 7% 9% 9% 
2025-12-18 11:03:52.719963 I  PlayerFPS:   24.65 Mean: 40573 Std.Dev:  3437 CPUs: 11% 23% 11% 10% 
2025-12-18 11:03:53.679968 I  PlayerFPS:   26.05 Mean: 38388 Std.Dev:  8286 CPUs: 15% 14% 5% 7% 
2025-12-18 11:03:54.700304 I  PlayerFPS:   24.51 Mean: 40801 Std.Dev:   680 CPUs: 4% 18% 5% 7% 
2025-12-18 11:03:55.704516 I  PlayerFPS:   24.90 Mean: 40157 Std.Dev:   418 CPUs: 8% 7% 6% 3% 
2025-12-18 11:03:56.705766 I  PlayerFPS:   24.98 Mean: 40039 Std.Dev:   296 CPUs: 6% 9% 5% 5%  

@ulmus-scott
Copy link
Contributor Author

@warpme The VAAPI deinterlacer is not being created so I would expect you to see interlacing artifacts depending on the source video. Although, it might just be the double rate deinterlacer that isn't working, since the single rate one looks like it didn't error.

Please attach the console output from a run with
mythfrontend --loglong -v audio:debug,libav:debug,playback:debug
. That should provide information for further investigation.

@warpme
Copy link
Contributor

warpme commented Dec 19, 2025

A sorry - i forgot switch to debug...
Pls find: https://termbin.com/wvr8
When playback starts - with ffmpeg8 - at beginning i have always 1..2 sec of green flickering onscreen.
Then playback becomes ok (with working di)
probably hint for us is at 2025-12-19 14:57:03.771026

@ulmus-scott
Copy link
Contributor Author

@warpme Piotr, the new commit should allow the creation of the VAAPI deinterlacer. Can you test it?

…alizing the AVFilter

FFmpeg now checks for a hardware context when using a hardware
frame format during initialization of the filter, so set all
parameters with av_buffersrc_parameters_set() before initializing.
Without this change, using an AMD Radeon RX 9060 XT, FFmpeg
gives the following error and will not create any VAAPI surfaces
for the deinterlacer:
Failed to create surface: 10 (attribute not supported).

Limit the workarounds to the specific driver they are for (i965).
FFmpeg says this will "Use the highest-numbered (and therefore
possibly most advanced) deinterlacing algorithm".

With my AMD Radeon RX 9060 XT, if deinterlacing is set to high
the VAAPI deinterlacer will not be created since it does not
support the motion_compensated deinterlacing mode.

By instead telling it to use default, it will select motion_adaptive.

Otherwise, see <va/va_vpp.h> and vaQueryVideoProcFilterCaps() to
actually get what VAAPI supports.
@ulmus-scott
Copy link
Contributor Author

I had to force push due to a destruction order bug I inadvertently introduced when setting hw_frames_ctx before initializing the buffer AVFilter. I think it might have been double freeing Source.

@warpme I could replicate the green flashing when the VAAPI deinterlacer fails to be created and the shader deinterlacer is then used. However, there is no green flashing if just the shader deinterlacer is used (i.e. the driver deinterlacer is disabled). I have no idea what would cause that, but I doubt it is related to anything in FFmpeg.

@warpme
Copy link
Contributor

warpme commented Dec 20, 2025

Scott,
All good now.
Thx!

@linuxdude42 linuxdude42 merged commit d8080dc into MythTV:master Jan 4, 2026
11 checks passed
@ulmus-scott ulmus-scott deleted the ffmpeg/8.0 branch January 4, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants