w23
New Member
So I really wanted to stream Clustertruck in 1440p60, so I spent a whole weekend reading ffmpeg sources instead.
As a result, there's a very naive ffmpeg-vaapi plugin (basically is a copy of ffmpeg-nvenc with vaapi-specific hw frame upload added) in the obs-ffmpeg module in this branch: https://github.com/w23/obs-studio/tree/ffmpeg-vaapi
The exact commit adding it: https://github.com/w23/obs-studio/commit/9c70ee2347285c4d7e087106c565ba5b5bbe16a6
It is in a rather early stage:
I'd appreciate any kind of feedback if anyone is interested.
My experience playing with it for a few hours so far:
Thing is that this jitter is not obs-specific. For example, running a screen capture with ffmpeg itself produces the same (if not actually worse) result:
Testing instructions.
0. libva is obviously needed.
1. Rather fresh ffmpeg with h264_vaapi encoding support is required. I took latest master (and I probably shouldn't have done that! This would be ironic if the issues above are due to an dev-unstable ffmpeg).
If you need to compile ffmpeg yourself, then you'd need it to have at least the following options for its ./configure:
Also for cmdline ffmpeg testing:
Also also, don't forget to set envvar PKG_CONFIG_PATH=<where-you-installed-ffmpeg>/lib/pkgconfig before you run cmake on OBS.
2. Build OBS and run it as usual. Go to advanced and pick VAAPI encoder.
As a result, there's a very naive ffmpeg-vaapi plugin (basically is a copy of ffmpeg-nvenc with vaapi-specific hw frame upload added) in the obs-ffmpeg module in this branch: https://github.com/w23/obs-studio/tree/ffmpeg-vaapi
The exact commit adding it: https://github.com/w23/obs-studio/commit/9c70ee2347285c4d7e087106c565ba5b5bbe16a6
It is in a rather early stage:
- no GUI controls
- display/device name is hardcoded to ":0"
- memory management/leaks were not considered at all
- actual performance wasn't measured
I'd appreciate any kind of feedback if anyone is interested.
My experience playing with it for a few hours so far:
- FFmpeg@master, Mesa 13.0.3, VA-API 0.39 (libva 1.7.3), kernel 4.8.12 on AMD Radeon R9 Fury X: there are weird issues with the video it produces. Basically it looks like ffmpeg+h264_vaapi emits packets very rarely, only a couple per second. Which could be fine otherwise, but the thing is that this packet rate equals apparent framerate of the produced video (1440p2 is not what I wanted!). Also, I don't visually see any P-frames at all. Tuning gop_size or other parameters doesn't make this packet rate better. This HW also requires b-frames to be set to zero, and VAAPI_DISABLE_INTERLACE=1 envvar set.
- On another hw (some intel on dell xps'13 from 2015) that I've tested very-very briefly, the stream is also low-fps and jittery, but not that much (likely the vaapi is fine, but the machine itself is rather weak). And p-frames are clearly visible.
Thing is that this jitter is not obs-specific. For example, running a screen capture with ffmpeg itself produces the same (if not actually worse) result:
Code:
ffmpeg \
-loglevel debug \
-f x11grab -video_size 2560x1440 -framerate 60 -x 1920 -i :0.0 \
-vaapi_device ":0" \
-vf 'format=nv12,hwupload' -map 0:0 -threads 8 -aspect 16:9 -y -f mp4 \
-bf 0 -qp 42 -quality 8 \
-vcodec h264_vaapi -profile 100 \
test-vaapi.mp4
Testing instructions.
0. libva is obviously needed.
1. Rather fresh ffmpeg with h264_vaapi encoding support is required. I took latest master (and I probably shouldn't have done that! This would be ironic if the issues above are due to an dev-unstable ffmpeg).
If you need to compile ffmpeg yourself, then you'd need it to have at least the following options for its ./configure:
Code:
--enable-shared --enable-pic --disable-static \
--enable-hwaccel=h264_vaapi \
--enable-filter=hwupload,scale \
--enable-encoder=h264_vaapi,aac \
--enable-muxer=h264,mp4,flv,md5 \
--enable-protocol=file,rtmp \
--enable-decoder=rawvideo
Also for cmdline ffmpeg testing:
Code:
--enable-indev=v4l2,x11grab_xcb,xcbgrab \
--enable-parser=mjpeg \
--enable-decoder=mjpeg
Also also, don't forget to set envvar PKG_CONFIG_PATH=<where-you-installed-ffmpeg>/lib/pkgconfig before you run cmake on OBS.
2. Build OBS and run it as usual. Go to advanced and pick VAAPI encoder.
Last edited: