2

I'm currently trying to use FFMPEG with Hardware/GPU Encoding with the H264 Codec.

What I do is, I pipe raw data direclty into ffmpeg to output them to a udp stream. Those are my settings:

var ffmpegArgs = [
    '-c:v', 'rawvideo',// input container
    '-f', 'rawvideo',
    '-pix_fmt', 'rgba', // input pixel format
    '-s', '600x600', //input size
    '-video_size', '600x600',
    '-i', 'pipe:0', // input source
    '-f', 'mpegts', // output container format
    '-s', '600x600',
    '-video_size', '600x600',
    '-c:v', 'libx264', // output video codec
    '-b:v', '1m', // output bitrate
    'udp://239.255.123.46:1234' // output destination
];

And in generally it is working, but with really miserable quality and latency. The frames are like 5 seconds behind and then have lots of bugs in them so it takes at least 10 or 15 seconds to see the hole frame (the video is a "live stream" from a canvas).

However I thought that GPU Encoding might help here, but I don't get this working. I'm trying to use VAAPI, but no matter which command from ffmpeg I'm trying to use (descirbed here), it's not working....

I'm trying to run this on a Intel NUC (this one) on an Ubuntu 16.04.

Are there any tips on how I can get this running?

nameless
  • 1,483
  • 5
  • 32
  • 78
  • well so I don't think you get hardware encoding with libx264... and you can never have "live" exactly because it needs a temporal sampling in order to do compression... you can use kepler / pascal nvidia cards with the nvenc through ffmpeg, which will reduce latency somewhate.... but really x264 is a pretty fast software encoder, and if you can control your x264 "preset", setting it to `"faster"` will probably make your encoding faster. – Grady Player Jul 28 '17 at 12:24
  • @GradyPlayer where can I set this preset? – nameless Jul 28 '17 at 12:25
  • I don't know what your clump of args even means... it would just be one of the options set on the avcontext when you opened the codec... I am not sure how that works from the cli, if that is what those represent (and it looks like they do) – Grady Player Jul 28 '17 at 12:27
  • @GradyPlayer yes, I found the `preset` option in the documentation now, but it seems like the faster the encoding is then, the more quality issues are coming up.. so not sure if this what I need. To get back to the thing you said... In general, it doesn't have to be libx264, it can also be another codec, but with a good quality, for exmaple I tried `mpeg2video`, and encoding is a little faster, but the quality is just not good.... – nameless Jul 28 '17 at 12:30
  • use `ffmpeg -f rawvideo -vcodec rawvideo -pixel_format bgr24 -framerate 10...` – Vahagn Avagyan Jul 28 '17 at 14:42

1 Answers1

3

The encoder you're using, libx264, does not implement hardware-accelerated encoding. Only (some) OpenCL-accelerated look-ahead function(s) are available, and performance gains from that are at best, marginal, especially on high-end systems. To expose look-ahead accelerated look-ahead in that library, ensure that an OpenCL ICD and OpenCL headers are present on the system and that the option --disable-opencl is omitted at x264's configuration phase. Likewise, for FFmpeg, ensure that --enable-opencl is enabled at the configuration phase.

Take a look at similar answers provided on queries regarding hardware-accelerated encoding with FFmpeg.

  1. With NVENC.

  2. With QuickSync (which requires the Intel Media SDK to be installed when configuring and building FFmpeg).

  3. With VAAPI.

And the FFmpeg wiki on hardware acceleration.

Dennis Mungai
  • 1,579
  • 1
  • 15
  • 28