Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime issues encountered with FFmpeg's VSR integration with software-based encoders #26

Open
Brainiarc7 opened this issue Feb 25, 2025 · 4 comments

Comments

@Brainiarc7
Copy link

Hello there,

I've built Intel's VSR from the reisr4nas branch of ffmpeg cartwheel, and can likewise confirm that it works as expected; at least in GPU modes where OpenCL is available.

However, the same cannot be said of the out-of-the-box ASM modes with software-based encoding via libx264 and libx265, as documented on the wiki.

These trivial examples simply fail/exit with no output(s) on the console:

With `libx264:

ffmpeg -init_hw_device qsv=hw \
-init_hw_device opencl=cl@hw \
-filter_hw_device cl \
-noautorotate -i "bbb.mp4" \
-vf "raisr=filterfolder=/filters_2x/filters_highres:asm=opencl" \
-c:v libx264 -pix_fmt yuv420p -x264-params "scenecut=0" -maxrate:v 5000k -bufsize:v 1250k \
-keyint_min 120 -g:v 120 -preset:v faster -tune:v fastdecode -bf:v 0 \
-flags +global_header+cgop -f mp4 -y libx264_highres.mp4

With `libx265:

ffmpeg -init_hw_device qsv=hw \
-init_hw_device opencl=cl@hw \
-filter_hw_device cl \
-noautorotate -i "bbb.mp4" \
-vf "raisr=filterfolder=/filters_2x/filters_highres:asm=opencl" \
-c:v libx265 -pix_fmt yuv420p -x265-params "scenecut=0" -maxrate:v 5000k -bufsize:v 1250k \
-keyint_min 120 -g:v 120 -preset:v faster -tune:v fastdecode -bf:v 0 \
-flags +global_header+cgop -f mp4 -y libx265_highres.mp4

Now, if an OpenCL hardware context is provided as with the trivial example below for libx264, and asm=opencl is set, the filter runs/executes as expected:

ffmpeg -init_hw_device qsv=hw \
-init_hw_device opencl=cl@hw \
-filter_hw_device cl \
-noautorotate -i "bbb.mp4" \
-vf "raisr=filterfolder=/filters_2x/filters_highres:asm=opencl" \
-c:v libx264 -pix_fmt yuv420p -x264-params "scenecut=0" -maxrate:v 5000k -bufsize:v 1250k \
-keyint_min 120 -g:v 120 -preset:v faster -tune:v fastdecode -bf:v 0 \
-flags +global_header+cgop -f mp4 -y libx264_highres.mp4

However, attempting the same with libx265 fails with the error:

[libx265 @ 0x556433417c80] Unknown picture type encountered.
[vost#0:0/libx265 @ 0x5564333c5d40] Error submitting video frame to the encoder
[vost#0:0/libx265 @ 0x5564333c5d40] Error encoding a frame: Generic error in an external library
[vost#0:0/libx265 @ 0x5564333c5d40] Task finished with error code: -542398533 (Generic error in an external library)
[vost#0:0/libx265 @ 0x5564333c5d40] Terminating thread with return code -542398533 (Generic error in an external library)
[out#0/mp4 @ 0x5564333fb8c0] video:0KiB audio:135KiB subtitle:0KiB other streams:0KiB global headers:3KiB muxing overhead: 1.210572%
frame=    0 fps=0.0 q=0.0 Lsize=     137KiB time=N/A bitrate=N/A dup=2 drop=0 speed=N/A    
x265 [info]: frame I:      1, Avg QP:35.82  kb/s: 923.52  

encoded 1 frames in 2.38s (0.42 fps), 923.52 kb/s, Avg QP:35.82

Regardless of the OpenCL device type/context created.

In brief: The filter is virtually unusable with the software-based libx264 and libx265 encoders, as-is, out of the box.

@xiaoxial
Copy link
Contributor

xiaoxial commented Mar 3, 2025

Hi @Brainiarc7 if you want to use Opencl acceleration and encode with software -based libx264 or libx265, can use the following command line:
ffmpeg -i "bbb.mp4" -vf "raisr=filterfolder=/filters_2x/filters_highres:asm=opencl" -pix_fmt yuv420p -c:v libx264/libx265 encoder_parameters_xxx -f mp4 ./output.mp4

@Brainiarc7
Copy link
Author

I tried that too and it still segfaults.

@xiaoxial
Copy link
Contributor

xiaoxial commented Mar 6, 2025

Hi @Brainiarc7

  1. If using lix264 can work but x265 cannot work with the same or similar codec parameters, you can first check if it can do transcode only(mean removing raisr filter) with libx265. Please check libx265 environment if the transcoding only with libx265 can't work.
  2. Please check OpenCL environment install opencl if the transcoding only with libx265 work well.

@Brainiarc7
Copy link
Author

With (1), yes, libx265 works as expected.
And with (2), OpenCL is readily available for both Intel and NVIDIA in the environment, verified with clinfo.

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

No branches or pull requests

2 participants