[Cin] test patch for 7.0 ffmpeg
Terje J. Hanssen
terjejhanssen at gmail.com
Thu Nov 21 00:53:19 CET 2024
Den 21.11.2024 03:07, skrev Andrew Randrianasulu:
> On Thu, Nov 21, 2024 at 1:43 AM Terje J. Hanssen
> <terjejhanssen at gmail.com> wrote:
>>
>>
>>
>> Den 20.11.2024 22:50, skrev Andrew Randrianasulu:
>>
>>
>>
>> чт, 21 нояб. 2024 г., 00:47 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>
>>>
>>>
>>> Den 20.11.2024 22:31, skrev Andrew Randrianasulu:
>>>
>>>
>>>
>>> чт, 21 нояб. 2024 г., 00:27 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>>
>>>>
>>>>
>>>> Den 20.11.2024 21:38, skrev Andrew Randrianasulu:
>>>>
>>>>
>>>>
>>>> ср, 20 нояб. 2024 г., 23:31 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>>>
>>>>>
>>>>>
>>>>> Den 20.11.2024 20:54, skrev Andrew Randrianasulu:
>>>>>
>>>>>
>>>>>
>>>>> ср, 20 нояб. 2024 г., 22:46 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>>>>
>>>>>>
>>>>>>
>>>>>> Den 20.11.2024 16:53, skrev Andrew Randrianasulu:
>>>>>>
>>>>>>
>>>>>>
>>>>>> ср, 20 нояб. 2024 г., 18:26 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>>>>> Den 20.11.2024 06:23, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>> On Tue, Nov 19, 2024 at 6:59 PM Terje J. Hanssen
>>>>>>> <terjejhanssen at gmail.com> wrote:
>>>>>>>
>>>>>>> Den 19.11.2024 15:08, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Nov 19, 2024 at 1:56 PM Terje J. Hanssen <terjejhanssen at gmail.com> wrote:
>>>>>>>
>>>>>>> Den 19.11.2024 14:53, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Nov 19, 2024 at 1:28 PM Terje J. Hanssen <terjejhanssen at gmail.com> wrote:
>>>>>>>
>>>>>>> Den 19.11.2024 06:58, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> вт, 19 нояб. 2024 г., 03:47 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>>>>>>
>>>>>>> Den 18.11.2024 10:52, skrev Andrew Randrianasulu:
>>>>>>>
>>>>>>> It may work or break it completely ...
>>>>>>>
>>>>>>> apply by normal patch command from inside thirdparty/ffmpeg (may be "cat pathname | patch -p1", may be "cat patchname | patch -p0") or edit libavcodec/qsvenc.c by hand.
>>>>>>>
>>>>>>> rebuild ffmpeg, do not do make clean,
>>>>>>> cd ../../
>>>>>>> so you again in main directory with ./autogen.sh and bin directory with cinelerra.
>>>>>>>
>>>>>>> touch cinelerra/ffmpeg.C
>>>>>>> make
>>>>>>>
>>>>>>> Hopefully this rebuild cin so on next start from bin/cin you will have something to test with tff sources.
>>>>>>>
>>>>>>> Unfortunately, netBSD does not support hardware virtualization on AMD cpus, so for now I do not have my virtual machines. I also forgot type of cable from PSU to disks, so now I can only power up one of two sata drives.
>>>>>>>
>>>>>>> It will be fixed eventually, but for now I hope to live up this netBSD install a bit ...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> To prepare for tomorrow, because else I am stuck:
>>>>>>>
>>>>>>> apply by normal patch command from inside thirdparty/ffmpeg (may be "cat pathname | patch -p1", may be "cat patchname | patch -p0") or edit libavcodec/qsvenc.c by hand.
>>>>>>>
>>>>>>>
>>>>>>> Should here be a patch attached to be able to use "git am patch"?
>>>>>>>
>>>>>>> I installed Fedora 40 in qemu on NetBSD (thankfully only booting from iso as cdrom was not working on hw virtualization - 4*3.9 {amd fx4300 } Ghz was barely enough for gnome-based (?) installer to just show up) so hopefully there will be!
>>>>>>>
>>>>>>>
>>>>>>> cd /Cin/thirdparty/ffmpeg-7.0 ?
>>>>>>>
>>>>>>> may be "cat pathname | patch -p1", may be "cat patchname | patch -p0" ?
>>>>>>>
>>>>>>> or edit libavcodec/qsvenc.c by hand. - possibly what to edit there?
>>>>>>>
>>>>>>> cd ../../
>>>>>>> localhost:/Cin #
>>>>>>>
>>>>>>> When possible, I need more explanation to my questions above ..,
>>>>>>>
>>>>>>> ? If you are not comfortable applying it by hand to internal ffmpeg I'll prepare normal git am patch, just wait a bit, ok?
>>>>>>>
>>>>>>>
>>>>>>> Yes, fine and ok. But I didn't even understand what and how to edit libavcodec/qsvenc.c by hand above ;)
>>>>>>>
>>>>>>> Normally you just delete lines marked with "-" at very beginning, and replace them with lines marked with "+" sign in patch. Line numbers and line endings extremely important for patch, so sometimes 'innocent' patch editing resulted in no-working patch :(
>>>>>>>
>>>>>>> for simple patches you can just edit file they normally modify by doing patch's work.
>>>>>>>
>>>>>>>
>>>>>>> Yet, I prefer to wait for the normal git am patch ;)
>>>>>>>
>>>>>>> try attached ?
>>>>>>>
>>>>>>>
>>>>>>> Thanks for the patch, but unhappily no success so far. Still the same errors.
>>>>>>>
>>>>>>> In case I did something wrong, I have preserved my steps as follow for verification:
>>>>>>>
>>>>>>> # cd /Cin/thirdparty/ffmpeg-7.0
>>>>>>>
>>>>>>> # git am 0001-experimental-add-qsv-field-info-to-qsv-encoder-in-ff.patch
>>>>>>> Applying: experimental: add qsv field info to qsv encoder in ffmpeg
>>>>>>>
>>>>>>> # cd ../..
>>>>>>>
>>>>>>> # /Cin
>>>>>>>
>>>>>>> # touch cinelerra/ffmpeg.C
>>>>>>>
>>>>>>> # make
>>>>>>>
>>>>>>> (no additonal "make install" step mentioned!?)
>>>>>>
>>>>>> well, just remaking cinelerra put resulting binary in bin, and plugins and stuff should already be there from previous build.
>>>>>>
>>>>>> BUT in this case we need to rebuild ffmpeg itself, not just our interface to it.
>>>>>>
>>>>>> rm -rf thirdparty/ffmpeg-7.0
>>>>>>
>>>>>> rm thirdparty/build/ffmpeg.*
>>>>>>
>>>>>> make
>>>>>>
>>>>>>
>>>>>> /Cin/bin/cin
>>>>>> with a new render test here, got the same qsv errors.
>>>>>>
>>>>>>
>>>>>> or you can do full rebuild just in case, but do not forgot to save profiles you worked on for so many days ...
>>>>>>
>>>>>>
>>>>>> Additional "make install" step and another render test had the same qsv errors.
>>>>>> I checked that my presets in /Cin/bin/ffmpeg/video were not overwritten. Should they?
>>>>>>
>>>>>> Or did you mean something else with a "full rebuild" ?
>>>>>
>>>>> by full rebuild i mean running
>>>>>
>>>>> make clean
>>>>>
>>>>> ./autogen.sh
>>>>>
>>>>> ./configure with switches for single user and libvpl
>>>>>
>>>>> make
>>>>>
>>>>> make install.
>>>>>
>>>>> by partial rebuild i mean
>>>>>
>>>>> rm thirdparty/build/ffmpeg.* - files indicating that was already built
>>>>>
>>>>> rm -rf thirdparty/ffmpeg-7.0
>>>>>
>>>>> so on next top level make it will unpack and patch ffmpeg sources anew, build .a static libraries, and only then you do
>>>>>
>>>>> touch cinelerra/ffmpeg.C
>>>>>
>>>>> make
>>>>>
>>>>> so cinelerra herself rebuilt with updated ffmpeg libraries.
>>>>>
>>>>> depend on how cpu power you have. I often do partial rebuild because I use qemu-based virtual machines with limited number of vCPUs assigned to them, or build on my android tablet.
>>>>>
>>>>>
>>>>>
>>>>> Yes I see. Surely smart and effective to do partial rebuild whenever possible.
>>>>> But in this case as I didn't get "it" to work, it is no problem try a full rebuild lastly on my local ws w/i7-12700KF.
>>>>>
>>>>> My noticed steps last time I rebuild this Cingg were:
>>>>> ---------------
>>>>> # /Cin
>>>>> # make clean
>>>>> # ./configure --with-single-user --with-onevpl
>>>>> # make
>>>>> # make install
>>>>
>>>> Hm. Still no success with regards to the qsv rendering errors:
>>>>
>>>> [av1_qsv @ 0x7f61b4d67c00] Current picture structure is unsupported
>>>>
>>>>> copied back my setup profiles from backup to bin/ffmpeg/video
>>>>
>>>> No need. I had expected that my setup profiles were deleted now, but not. They looked to have outlived the full rebuild!
>>>> Should they really?
>>>
>>> no, "make clean" deletes bin folder and everything there...
>>>
>>> unless you put them in ffmpeg (not bin/ffmpeg)
>>>
>>>
>>> I had also saved a backup in ./ffmpeg/video/
>>>
>>> Therefore they were copied automatic back to ./bin/ffmpeg/video/ ?
>>
>> on 'make install', yes.
>>
>> can you visually inspect that patch altered file as intended?
>>
>>
>> As written above, I was in /Cin/thirdparty/ffmpeg-7.0 when using "git am patch"
> should be ok, as we do not use ffmpeg.git for this attempt, and git
> goes up until it finds .git directory ....
>
>> Not quite sure what key to look for in qsvenc.c
>> fx. no search hit for "patch",
>> but this is a copied if section from line no 849 - 868 that is similar like some of the patch content:
>>
>> if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
>> // it is important that PicStruct be setup correctly from the
>> // start--otherwise, encoding doesn't work and results in a bunch
>> // of incompatible video parameter errors
>> if (avctx->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
>> q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
>> else
>> q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
>> // height alignment always must be 32 for interlaced video
>> q->height_align = 32;
>> } else {
>> q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
>> // for progressive video, the height should be aligned to 16 for
>> // H.264. For HEVC, depending on the version of MFX, it should be
>> // either 32 or 16. The lower number is better if possible.
>> // For AV1, it is 32
>> q->height_align = (avctx->codec_id == AV_CODEC_ID_HEVC ||
>> avctx->codec_id == AV_CODEC_ID_AV1) ? 32 : 16;
>> }
>> q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, q->height_align);
>>
>>
> correctly applied patch usually do not leave "patch" string, unless
> it was spelled in patch :}
>
> but yes, looks correct.
>
> May be I just barking at wrong tree.
>
> I think we can continue tomorrow
To-morrow my wife and me will be winter travelling visit with car for a
long weekend the next four days. I will have access to just my ultrabook
(KabyLake) limited to my normal os, email, ffmpeg and normal cingg
(without build system..
So for now I just test transcoding with my system ffmpeg 7.1 below,
which confirms break, yes.
Full output this time below:
>
> I suggest to add
>
> flags +ildct to your working ffmpeg with tff source example and see if it breaks
ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -i hdv09_04.m2t
-pix_fmt nv12 -c:v av1_qsv -flags +ildct hdv09_04_av1_qsv_format_nv12.mp4
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 @ 0x5587f1def400] Invalid frame dimensions 0x0.
Last message repeated 3 times
[mpegts @ 0x5587f1e35800] PES packet size mismatch
[mpegts @ 0x5587f1e35800] Packet corrupt (stream = 1, dts = 258142320).
[mpegts @ 0x5587f1e35800] 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 @ 0x5587f1e35800] 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)
File 'hdv09_04_av1_qsv_format_nv12.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> av1 (av1_qsv))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[av1_qsv @ 0x5587f1e2ad40] 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.
[av1_qsv @ 0x5587f1e2ad40] Current picture structure is unsupported
[av1_qsv @ 0x5587f1e2ad40] some encoding parameters are not supported by
the QSV runtime. Please double check the input parameters.
[vost#0:0/av1_qsv @ 0x5587f1db4280] Error while opening encoder - maybe
incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0x5587f1e27f00] Error sending frames to consumers: Function
not implemented
[vf#0:0 @ 0x5587f1e27f00] Task finished with error code: -38 (Function
not implemented)
[vf#0:0 @ 0x5587f1e27f00] Terminating thread with return code -38
(Function not implemented)
[vost#0:0/av1_qsv @ 0x5587f1db4280] Could not open encoder before EOF
[vost#0:0/av1_qsv @ 0x5587f1db4280] Task finished with error code: -22
(Invalid argument)
[vost#0:0/av1_qsv @ 0x5587f1db4280] Terminating thread with return code
-22 (Invalid argument)
[out#0/mp4 @ 0x5587f1d81440] Nothing was written into output file,
because at least one of its streams received no packets.
frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A
[aac @ 0x5587f1eef080] Qavg: 438.139
Conversion failed!
>
> and remove said flag from codec parameters in cinelerra's gui settings
> (i hope you know where to look, I can send you picture as fast as my
> termux copy finishes building)
>
> we can also apply big hammer and just delete this error branch (but it
> probably will ruin output as warned?)
>
>>
>>>
>>>
>>>
>>>> (another thing as CPU was mentioned. I had top running beside running make and noticed CPU was on just 100%
>>>> That seemingly tells that make uses only a single core, not multi-core utilization like BD rendering used)
>>>
>>>
>>> normally buildsystem makes good use of all cores .. some things like x265 build not really parallel for now but they take relatively small portion of time.
>>>>
>>>>
>>>>> ------------
>>>>>
>>>>> What about patches in this new case, are they already taken care of without extra steps?
>>>>
>>>> hopefully yes, as I tried to build with my patch and it was building w/o error so I made it into git am-compatible patch and you applied that already.
>>>>
>>>>> Will it still be need to start Cinelerra with
>>>>>
>>>>> CIN_10BIT_ENC=p010le bin/cin
>>>>>
>>>>> to get 10bit vaapi?
>>>>
>>>>
>>>> no, previous patch should take care of this, no need to use this variable anymore .
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> # bin/cin
>>>>>>> Loaded a tff hdv.m2t file
>>>>>>>
>>>>>>> Attempt to render with preset av1_qsv_8b420.mp4
>>>>>>>
>>>>>>> # av1_qsv_8b420
>>>>>>> # usable with Pixels: nv12
>>>>>>> profile=main
>>>>>>> # global_quality=25
>>>>>>>
>>>>>>> failed with the previous output error:
>>>>>>>
>>>>>>> [av1_qsv @ 0x7fc850e4f280] Current picture structure is unsupported
>>>>>>> [av1_qsv @ 0x7fc850e4f280] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
>>>>>>> FFMPEG::open_encoder err: Function not implemented
>>>>>>> int FFMPEG::open_encoder(const char*, const char*):
>>>>>>> open failed av1_qsv:/Videoklipp/QSV/hdv09_04_av1_qsv.mp4
>>>>>>> Render::render_single: Session finished.
>>>>>>>
>>>>>>>
>>>>>>>
More information about the Cin
mailing list