Hwaccel for mpeg-2 4:2:2

Hello!

I have 2 test videos, mpg:

General
Complete name                            : test.mpg
Format                                   : MPEG-PS
File size                                : 2.03 GiB
Duration                                 : 5 min 40 s
Overall bit rate mode                    : Constant
Overall bit rate                         : 51.2 Mb/s

Video
ID                                       : 224 (0xE0)
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : 4:2:2@High
Format settings                          : BVOP
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Default
Format settings, picture structure       : Frame
Duration                                 : 5 min 40 s
Bit rate mode                            : Constant
Bit rate                                 : 50.0 Mb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.965
Time code of first frame                 : 00:00:00:00
Time code source                         : Group of pictures header
Stream size                              : 1.98 GiB (98%)
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 192 (0xC0)
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 2
Format settings                          : 50/15ms
Duration                                 : 5 min 40 s
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Frame rate                               : 41.667 FPS (1152 SPF)
Compression mode                         : Lossy
Delay relative to video                  : 40 ms
Stream size                              : 7.79 MiB (0%)

and mxf

General
Complete name                            : test.mxf
Format                                   : MXF
Commercial name                          : IMX 50
Format version                           : 1.2
Format profile                           : OP-1a
Format settings                          : Closed / Complete
File size                                : 27.3 GiB
Duration                                 : 1 h 2 min
Overall bit rate                         : 62.6 Mb/s
Package name                             : Material Package for A-K2SVR3/V:/default/08RO0006M / Source Package for A-K2SVR3/V:/default/08RO0006M
Encoded date                             : 2013-12-29 10:40:00.000
Writing application                      : Grass Valley K2 1.0.0.0.0
Writing library                          : K2 1.0.0.0.0

Video
ID                                       : 2
Format                                   : MPEG Video
Commercial name                          : IMX 50
Format version                           : Version 2
Format profile                           : 4:2:2@Main
Format settings, BVOP                    : No
Format settings, Matrix                  : Default
Format settings, GOP                     : N=1
Format settings, picture structure       : Frame
Format settings, wrapping mode           : Frame (D-10)
Codec ID                                 : 0D01030102010101-0401020201020101
Duration                                 : 1 h 2 min
Bit rate mode                            : Constant
Bit rate                                 : 50.0 Mb/s
Width                                    : 720 pixels
Height                                   : 576 pixels
Original height                          : 608 pixels
Display aspect ratio                     : 4:3
Active Format Description                : Letterbox image with an aspect ratio greater than 16:9
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 4.823
Time code of first frame                 : 00:00:00:00
Time code source                         : Group of pictures header
GOP, Open/Closed                         : Closed
Stream size                              : 21.9 GiB (80%)
Title                                    : SP: Video Track #2
Color range                              : Limited
Transfer characteristics                 : BT.601

Audio
ID                                       : 3
Format                                   : PCM
Format settings, wrapping mode           : Frame (D-10)
Codec ID                                 : 0D01030102010101
Duration                                 : 1 h 2 min
Bit rate mode                            : Constant
Bit rate                                 : 6 144 kb/s
Channel(s)                               : 8 channels
Sampling rate                            : 48.0 kHz
Frame rate                               : 25.000 FPS (1920 SPF)
Bit depth                                : 16 bits
Stream size                              : 2.68 GiB (10%)
Title                                    : SP: BWAV Audio Track#3
Locked                                   : Yes

Other #1
ID                                       : 1-Material
Type                                     : Time code
Format                                   : MXF TC
Frame rate                               : 25.000 FPS
Time code of first frame                 : 00:02:57:24
Time code settings                       : Material Package
Time code, striped                       : Yes
Title                                    : MP: SMPTE 12M Timecode track #1 with no user bits

Other #2
ID                                       : 1-Source
Type                                     : Time code
Format                                   : MXF TC
Frame rate                               : 25.000 FPS
Time code of first frame                 : 00:02:57:24
Time code settings                       : Source Package
Time code, striped                       : Yes
Title                                    : SP: SMPTE 12M Timecode track #1 with no user bits

Other #3
Type                                     : Time code
Format                                   : SMPTE TC
Muxing mode                              : SDTI
Frame rate                               : 25.000 FPS
Time code of first frame                 : 00:02:57:24

Both of them

Format                                   : MPEG Video
Format version                           : Version 2

According to matrix Video Encode and Decode GPU Support Matrix | NVIDIA Developer my tesla t4 must work with mpeg-2 (but im not sure about 4:2:2)

Anyway, whan i launch

ffmpeg -debug_ts -vsync 0 -hwaccel cuda -i test.mpg -vf blackdetect=d=5 -f rawvideo -y /dev/null -progress progressbar11
or
ffmpeg -debug_ts -vsync 0 -hwaccel cuda -i test.mxf -vf blackdetect=d=5 -f rawvideo -y /dev/null -progress progressbar11

*-debug_ts - is for detecting bad nal units and etc
*-vf blackdetect=d=5 - for detecting black scenes

i dont get any accelaration, only cpu is working.

When i do the same with mp4(avc but 4:2:0) - i get abot 50% of dec and 5-10% of sm and enc loading

Where is my mistake?

This appears to be a questions about hardware acceleration for processing video streams, not CUDA programming. If so, wouldn’t the following sub-forum be a better place to ask?

1 Like

Downloaded some dsample from internet https://filesamples.com/samples/video/m2ts/sample_1280x720_surfing_with_audio.m2ts and it is mpeg-2 4:2:0 - works like a sharm, seems to be that 4:2:2 now working, but i cannot find official proof for that

Or i need to add some additional keys to work with 4:2:2

if to run directly via
ffmpeg -debug_ts -vsync 0 -c:v mpeg2_cuvid -i test.mpg ...

this errors i got:

[mpeg2_cuvid @ 0x55d5c282b7c0] ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo) failed -> CUDA_ERROR_NOT_SUPPORTED: operation not supported
[mpeg2_cuvid @ 0x55d5c282b7c0] cuvid decode callback error
Error while decoding stream #0:0: Generic error in an external library


4:2:2 is not natively supported on HW

but it is 2019, seems to be nothing changed…