No GPU acceleration in ffmpeg

Discussion in 'UDOO QUAD' started by schmidtbag, Jun 11, 2017.

Tags:
  1. schmidtbag

    schmidtbag New Member

    Joined:
    Dec 14, 2013
    Messages:
    23
    Likes Received:
    0
    I'm working on this personal project involving a couple identical 1080p webcams. I want to record the 1080p 30FPS MJPEG stream (so, not the raw YUYV stream) to a file.

    Using ffmpeg, I can access the MJPEG stream with the resolution and theoretical framerate I want, but the quality is weirdly bad and even at 720p the CPU gets maxed-out, causing frame drops. I haven't even attempted using the 2nd camera yet. Here's the command I've been using:
    Code:
    ffmpeg -f v4l2 -s 1280x720 -input_format mjpeg -i /dev/video0 -c:v mjpeg -r 30 -b:v 256k -threads 4 output.mp4
    Removing things like the "-c:v" or "-threads" flags haven't really changed the outcome. If I use the YUYV stream, I get somewhere between 2-5FPS and the CPU is still under 100% load.

    Meanwhile, I also tried using gstreamer. This seems to use very little CPU which is great - I'm not sure if this is due to the imx-gstreamer plugin. However, the problem is it seems to be skipping frames. The video output is 30FPS, but the recording framerate seems to be maybe 5FPS. In other words, it looks like a fast-forward timelapse, and I can't figure out how to make it stop doing this. This is the command I've been using:
    Code:
    gst-launch-1.0 v4l2src device="/dev/video0" ! image/jpeg,width=1280,height=720,framerate=30/1 ! filesink location=output.avi
    I can't seem to figure out if "image/jpeg" is actually utilizing the MJPEG stream or not. The output is pretty much the same if I use "video/x-raw", except that doesn't work if I specify the framerate. It doesn't work if I try using "video/x-jpeg".

    The ffmpeg command works smoothly on an x86 PC, but still taxes the CPU a lot. The gstreamer command operates exactly the same way as it does on the UDOO. Also, both VLC and qv4l2 are perfectly capable of viewing the webcam with 1080p@60Hz with very little CPU overhead, so I know for a fact the camera is capable of doing what I want.

    So what I'm wondering is only one of the following:
    1. How can I get ffmpeg to utilize less than 50% CPU without depending on transcoders?
    2. How can I get gstreamer to record at 1080p@30FPS?
    3. Is there something else that can do what I want?
     
    Last edited: Jun 11, 2017
  2. schmidtbag

    schmidtbag New Member

    Joined:
    Dec 14, 2013
    Messages:
    23
    Likes Received:
    0
    So I managed to mostly solve my problem:

    Using the following command:
    gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,framerate=30/1,width=1920,height=1080 ! videorate ! avimux ! filesink location=output.avi
    This will give me the 1080p output at 30FPS with pretty good quality, roughly 18% max CPU usage total (on the ARM system), and doesn't seem to get bottlenecked by the disk. But, there's some weird issue where either the first roughly 15 seconds is a mostly black screen, or, doesn't start the recording. This happens on both systems.

    Any idea why this is happening?
     

Share This Page