[Cin] Fwd: [FFmpeg-devel] qsvenc.c & AV_CODEC_FLAG_INTERLACED_DCT

Andrew Randrianasulu randrianasulu at gmail.com
Sun Nov 24 22:22:07 CET 2024


вс, 24 нояб. 2024 г., 19:45 Terje J. Hanssen <terjejhanssen at gmail.com>:

>
>
>
> Den 23.11.2024 13:24, skrev Andrew Randrianasulu:
>
>
>
> сб, 23 нояб. 2024 г., 15:15 Terje Hanssen <terjejhanssen at gmail.com>:
>
>>
>>
>>
>> On 11/22/24 18:54, Andrew Randrianasulu wrote:
>>
>>
>>
>> пт, 22 нояб. 2024 г., 20:37 Terje Hanssen <terjejhanssen at gmail.com>:
>>
>>>
>>>
>>>
>>> On 11/22/24 18:12, Andrew Randrianasulu wrote:
>>>
>>>
>>>
>>> пт, 22 нояб. 2024 г., 20:07 Terje Hanssen <terjejhanssen at gmail.com>:
>>>
>>>>
>>>>
>>>>
>>>> On 11/22/24 17:58, Andrew Randrianasulu wrote:
>>>>
>>>>
>>>>
>>>> пт, 22 нояб. 2024 г., 19:55 Terje Hanssen <terjejhanssen at gmail.com>:
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 11/22/24 18:41, Andrew Randrianasulu wrote:
>>>>>
>>>>> On Fri, Nov 22, 2024 at 2:52 PM Terje Hanssen <terjejhanssen at gmail.com> <terjejhanssen at gmail.com> wrote:
>>>>>
>>>>> On 11/22/24 08:45, Andrew Randrianasulu wrote:
>>>>>
>>>>>
>>>>>
>>>>> ---------- Forwarded message ---------
>>>>> От: Wang, Fei W <fei.w.wang-at-intel.com at ffmpeg.org> <fei.w.wang-at-intel.com at ffmpeg.org>
>>>>> Date: пт, 22 нояб. 2024 г., 09:10
>>>>> Subject: Re: [FFmpeg-devel] qsvenc.c & AV_CODEC_FLAG_INTERLACED_DCT
>>>>> To: ffmpeg-devel at ffmpeg.org <ffmpeg-devel at ffmpeg.org> <ffmpeg-devel at ffmpeg.org>
>>>>>
>>>>>
>>>>> On Thu, 2024-11-21 at 11:50 +0300, Andrew Randrianasulu wrote:
>>>>>
>>>>> Hello.
>>>>>
>>>>>
>>>>> Recently I teached cinelerra-gg to use qsv encoders in ffmpeg
>>>>> (libavcodec)
>>>>> and some test were working but some not.
>>>>>
>>>>> We nailed it down to top-field first  material, like HDV files. bff
>>>>> files
>>>>> like consumer version of DV and progressive worked fine.
>>>>>
>>>>> I looked at source and ... I thought condition at
>>>>> http://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavcodec/qsvenc.c#l852
>>>>>
>>>>>
>>>>> must contain case for bff, but I tried this and it was reportedly not
>>>>> helping?
>>>>>
>>>>>
>>>>> We currently set flags = ildct+ilme on interlaced streams, I hope to
>>>>> avoid
>>>>> special-casing qsv encoders, but may be we have no other choice?
>>>>>
>>>>> I asked user (Terje) to add +ildct flag to his normal system ffmpeg
>>>>> line
>>>>> and it started to fail too:
>>>>> https://lists.cinelerra-gg.org/pipermail/cin/2024-November/009123.html
>>>>>
>>>>> AV1 doesn't support interlaced frame.
>>>>>
>>>>> Tried also the cmd as suggested from Fei Wang:
>
> ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -hwaccel_output_format
> qsv -i hdv09_04.m2t -pix_fmt nv12 -vf vpp_qsv=deinterlace=advanced -c:v
> av1_qsv -f null -
> libva info: VA-API version 1.22.0
> libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
> libva info: Found init function __vaDriverInit_1_22
> libva info: va_openDriver() returns 0
> libva info: VA-API version 1.22.0
> libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
> libva info: Found init function __vaDriverInit_1_22
> libva info: va_openDriver() returns 0
> [mpeg2video @ 0x55908d205300] Invalid frame dimensions 0x0.
>     Last message repeated 3 times
> [mpegts @ 0x55908d1aa480] PES packet size mismatch
> [mpegts @ 0x55908d1aa480] Packet corrupt (stream = 1, dts = 258142320).
> [mpegts @ 0x55908d1aa480] Could not find codec parameters for stream 2
> (Unknown: none ([160][0][0][0] / 0x00A0)): unknown codec
> Consider increasing the value for the 'analyzeduration' (0) and
> 'probesize' (5000000) options
> [mpegts @ 0x55908d1aa480] Could not find codec parameters for stream 3
> (Unknown: none ([161][0][0][0] / 0x00A1)): unknown codec
> Consider increasing the value for the 'analyzeduration' (0) and
> 'probesize' (5000000) options
> Input #0, mpegts, from 'hdv09_04.m2t':
>   Duration: 00:03:59.06, start: 2629.496000, bitrate: 26110 kb/s
>   Program 100
>   Stream #0:0[0x810]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
> yuv420p(tv, bt709, top first), 1440x1080 [SAR 4:3 DAR 16:9], 25000 kb/s, 25
> fps, 25 tbr, 90k tbn
>       Side data:
>         cpb: bitrate max/min/avg: 25000000/0/0 buffer size: 7340032
> vbv_delay: N/A
>   Stream #0:1[0x814]: Audio: mp2 (mp3float) ([3][0][0][0] / 0x0003), 48000
> Hz, stereo, fltp, 384 kb/s
>   Stream #0:2[0x815]: Unknown: none ([160][0][0][0] / 0x00A0)
>   Stream #0:3[0x811]: Unknown: none ([161][0][0][0] / 0x00A1)
> Stream mapping:
>   Stream #0:0 -> #0:0 (mpeg2video (native) -> av1 (av1_qsv))
>   Stream #0:1 -> #0:1 (mp2 (native) -> pcm_s16le (native))
> Press [q] to stop, [?] for help
> [av1_qsv @ 0x55908d2dd280] Using the constant quantization parameter (CQP)
> by default. Please use the global_quality option and other options for a
> quality-based mode or the b option and other options for a bitrate-based
> mode if the default is not the desired choice.
> Output #0, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf61.7.100
>   Stream #0:0: Video: av1, nv12(tv, bt709, top coded first (swapped)),
> 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 25 fps, 25 tbn
>       Metadata:
>         encoder         : Lavc61.19.100 av1_qsv
>   Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
>       Metadata:
>         encoder         : Lavc61.19.100 pcm_s16le
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 167 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 183 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 194 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 196 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 198 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 199 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 208 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 199 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 207 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 220 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 199 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 207 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 202 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 207 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 205 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 182 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 202 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 183 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 194 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 208 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 202 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 191 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 187 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 190 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 212 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 220 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 200 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 197 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 204 times
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 125 times
> [mpegts @ 0x55908d1aa480] PES packet size mismatch
> [mpegts @ 0x55908d1aa480] Packet corrupt (stream = 1, dts = 258142320).
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 8 times
> [mpeg2video @ 0x55908d232400] ac-tex damaged at 10 61
> [mpeg2video @ 0x55908d232400] Warning MVs not available
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
> [mpeg2video @ 0x55908d232400] concealing 630 DC, 630 AC, 630 MV errors in
> P frame
> [vist#0:0/mpeg2video @ 0x55908d354b40] [dec:mpeg2video @ 0x55908d320d00]
> corrupt decoded frame
> [null @ 0x55908d355c00] Application provided invalid, non monotonically
> increasing dts to muxer in stream 0: -140737488355328 >= -140737488355328
>     Last message repeated 33 times
> [out#0/null @ 0x55908d261140] video:45168KiB audio:44770KiB subtitle:0KiB
> other streams:0KiB global headers:0KiB muxing overhead: unknown
> frame= 5963 fps=399 q=-0.0 Lsize=N/A time=-1563749870:36:53.12 bitrate=N/A
> speed=N/A
>
>
>> I wonder if AV1 generic doesn't support interlaced input video, then
>> neither AV1 software encoders like av1_svt should be able to do it. Or may
>> this mean interlaced output?
>>
>
>
> *i think* specification allow it, just current hw implementation via qsv
> does not exist (yet?).
>
>
> You better ask some intel engineers about that.
>
> ............snip
>
>
>>>> But unhappily, the HDV --> av1_qsv transcoding I previous did on
>>>> i17-12700/DG2 WS
>>>> https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg08314.html
>>>>
>>>> HDV --> av1_qsv -global_quality 25
>>>> -----------------------------------
>>>> ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -i hdv09_04.m2t
>>>> -pix_fmt nv12 -c:v av1_qsv -global_quality 25
>>>> hdv09_04_av1_qsv_format_nv12_gq25.mp4
>>>>
>>>> ffprobe -hide_banner hdv09_04_av1_qsv_format_nv12_gq25.mp4
>>>>   Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 /
>>>> 0x31307661), yuv420p(tv, bt709, top coded first (swapped)), 1440x1080, 7902
>>>> kb/s, SAR 4:3 DAR 16:9, 24.99 fps, 25 tbr, 12800 tbn (default)
>>>>
>>>> is not possible on my legacy KBL i7-8550U Intel UHD Graphics 620
>>>>
>>>> [av1_qsv @ 0x5641dd0f5440] This version of runtime doesn't support AV1
>>>> encoding
>>>>
>>>> .........................snip
>
>
>>>>> By the way, neither this attempt claims about unsupported or wrong
>>>>> image structure format !?
>>>>>
>>>>
>>>>
>>>> may be it not even come to this line and abort earlier? (in compiled
>>>> languages functions can be executed out of order they appear in file)
>>>>
>>>>
>>>> HDV --> av1_qsv transcoded as referenced above on the newer
>>>> i17-12700/DG2
>>>>
>>>
>>> ??
>>>
>>> you mean why default ffmpeg does not trip over this line?
>>>
>>> it silently ignores interlace and makes something flagged as interlaced
>>> but actually not?
>>>
>>>
>>> We can have a closer look at the av1_qsv output, possibly with loglevel
>>> verbose or debug on that WS, when I'm back again. I don't know what ffmpeg
>>> really does here, but as far it is accelerated (fps=561 for cfhd.mkv),
>>> viewable and playable, it will be good?
>>>
>>
>>
>> welll ..may be?
>>
>>
> Tried my own tff 1080i50 HDV input with FFmpeg on i7-12700/DG2 again and
> got No av1_qsv errors:
>
> HDV --> av1_qsv nv12 -global_quality 25
> -----------------------------------
> ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -i hdv09_04.m2t
> -pix_fmt nv12 -c:v av1_qsv -global_quality 25
> hdv09_04_av1_qsv_format_nv12_gq25.mp4
>    frame= 5963 fps=561 q=-0.0 Lsize=  234099KiB time=00:03:58.77
> bitrate=8031.5kbits/s speed=22.5x
>
> ffprobe -hide_banner hdv09_04_av1_qsv_format_nv12_gq25.mp4
>   Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 / 0x31307661),
> yuv420p(tv, bt709, top coded first (swapped)), 1440x1080, 7902 kb/s, SAR
> 4:3 DAR 16:9, 24.99 fps, 25 tbr, 12800 tbn (default)
>
> mediainfo hdv09_04_av1_qsv_format_nv12_gq25.mp4 | egrep -i
> "scan|bit|format"
> Complete name                            :
> hdv09_04_av1_qsv_format_nv12_gq25.mp4
> Format                                   : MPEG-4
> Format profile                           : Base Media
> Overall bit rate                         : 8 021 kb/s
> Format                                   : AV1
> Format/Info                              : AOMedia Video 1
> Format profile                           : Main at L4.0
> Bit rate                                 : 7 903 kb/s
> Bit depth                                : 8 bits
> Scan type                                : Interlaced
> Scan type, store method                  : Interleaved fields
> Scan order                               : Top Field First
> Bits/(Pixel*Frame)                       : 0.203
> Format                                   : AAC LC
> Format/Info                              : Advanced Audio Codec Low
> Complexity
> Bit rate mode                            : Constant
> Bit rate                                 : 132 kb/s
>
>
> Also FHD --> av1_qsv with p010le works
>
>
>
>> If it works good enough for  those goals may be you can just set cingg's
>> format to progressive even if autodetect says interlaced, and try to render.
>>
>>
>> I'll try that also.
>>
>> I can't notice differences at playback with VLC and FFplay (other than
> 16:9 vs 4:3 format as usual). And both visually with good qualities in my
> eyes.
>
> Cingg Set Format Interlace Mode: Not interlaced
> did the trick and both hdv and hd could be rendered
> FFprobe reported it is pgogressiv, while native FFmpeg transcoding still
> say interlaced.
>


But do files rendered by cingg set to progressive and ffmpeg from same tff
source differ visually?



> HDV --> av1_qsv
>
> av1_qsv_8b420.mp4
> mp4 av1_qsv
> # av1_qsv_8b420
> cin_pix_fmt=nv12
> profile=main
> # global_quality=25
>
> ** rendered 5972 frames in 10.026 secs, 595.651 fps
>
> ----------
>
> ffprobe -hide_banner hdv09_04_av1_qsv.mp4
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hdv09_04_av1_qsv.mp4':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomav01iso2mp41
>     encoder         : Lavf61.1.100
>   Duration: 00:03:58.88, start: 0.000000, bitrate: 1533 kb/s
>   Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 / 0x31307661),
> yuv420p(tv, bt709/unknown/unknown, progressive), 1440x1080, 1532 kb/s, SAR
> 4:3 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
>
> =====================
>
> FHD --> av1_qsv
>
> av1_qsv_10b420.mp4
> mp4 av1_qsv
> # av1_qsv_10b420
> cin_pix_fmt=p010le
> profile=main
> # global_quality=25
>
> ** rendered 1780 frames in 42.035 secs, 42.346 fps
>
> -------------------
>
> ffprobe -hide_banner hd01_av1_qsv.mp4
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hd01_av1_qsv.mp4':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomav01iso2mp41
>     encoder         : Lavf61.1.100
>   Duration: 00:01:11.20, start: 0.000000, bitrate: 1070 kb/s
>   Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 / 0x31307661),
> yuv420p10le(tv, bt709/unknown/unknown, progressive), 1920x1080, 1070 kb/s,
> SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20241125/f1f6912b/attachment-0001.htm>


More information about the Cin mailing list