Issue: FFMPEG GPU/Hardware acceleration is not enabled on RPI. FFPlay is jittery, patchy and takes close to 100% CPU.

Description: The video streaming of mpeg4 files is very slow (the video streaming is playing like a slide show) as well as consumes between 95% and 97%. The CPU consumption increases with increase in screen size. Other tools on RPI such as built in Webbrowser shows the same MPEG4 files smooth, infact the Webbrowser shows HD (720p) quality video well and with about 30-35% CPU.

Environment: RPI3, FFMPEG. FFMEG is compiled with MMAL decoder enabled and confirmed. Steps from Johnanath https://john.ly/rpi-h264-hw-acceleration/#comment-723" are used.

Rationale: The reason need to speed up FFMEG MMAL decoder on RPI 3 is that we are using PJSIP video call. PJSIP uses FFMPEG and is too is slow s(we believe for same reason FFMEG is slow) for a video call.

Setup and Tests: As per johnathan comments, I have enabled h264_mmal and h264_omx for decoding and encoding video respectively while configuring ffmpeg. Here below are the procedures followed on rpi3:

Downloaded mp4 video file 1080P resolution. Followed the above procedure for installing ffmpeg Executed the following commands:

  1. ffmpeg -f -i test.mp4 -s 320*240 -c:v h264_omx test_h264_mmal.mp4

  2. ffplay -vcodec h264_mmal test.mp4

  3. ffplay -vcodec h264_mmal test_h264_mmal.mp4 ( with different resolution such as 320*240, 640*480 )

  4. Set the gpu_mem value to 128 and 256 Below is the configuration on ffmpeg:

    $ ffmpeg -decoders | grep h264
    ffmpeg version git-2017-05-05-3c085c1 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-decoder=mpeg2_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-nonfree --enable-gpl --enable-avresample --enable-shared --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libzvbi
      libavutil      55. 61.100 / 55. 61.100
      libavcodec     57. 94.101 / 57. 94.101
      libavformat    57. 72.101 / 57. 72.101
      libavdevice    57.  7.100 / 57.  7.100
      libavfilter     6. 88.100 /  6. 88.100
      libavresample   3.  6.  0 /  3.  6.  0
      libswscale      4.  7.101 /  4.  7.101
      libswresample   2.  8.100 /  2.  8.100
      libpostproc    54.  6.100 / 54.  6.100
     VFS..D h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
     V..... h264_mmal            h264 (mmal) (codec h264)
     V....D h264_vdpau           H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration) (codec h264)

Test Results: When ffplay is used we see Jittery Video image slide a slide show with close to 100% CPU.

Note: When streaming of HD video on RPI3 using default browser and chrome works well with 30-35% CPU.

Is there anything else needs to be taken care, or any help is highly appreciated as I am stuck on this issue for more than a week.


After working some frustrating days on same problem, I came to a conclusion:

It seems that ffmpeg-versions > 3.1.x are not able to use accelerated (mmal) decoding anymore!

I compiled on rpi3 with Rasberian Stretch different versions with configure settings:

./configure --enable-gpl --enable-mmal --enable-gnutls && make -j4 && sudo make install

Result with: ffplay -vcodec h264_mmal /opt/vc/src/hello_pi/hello_video/test.h264

  • ffmpeg 3.0.3 => ok ~40% CPU
  • ffmpeg 3.0.9 => ok ~40% CPU
  • ffmpeg 3.1.10 => ok ~40% CPU
  • ffmpeg 3.2.7 => no hwaccel 100% CPU
  • ffmpeg 3.3.3 => no hwaccel 100% CPU
  • ffmpeg-master => no hwaccel 100% CPU

A ffplay -vcodec h264_mmal -loglevel debug /opt/vc/src/hello_pi/hello_video/test.h264

did not give any usefull informations.

The default browser (Chromium) use his own ffmpeg implementation. So it is not comparable.

I will post a bugreport to ffmpeg after some more tests.

Kind regards

  • As stretch was only released this month, this is not likely the cause of the OP's problem. – Steve Robillard Aug 24 '17 at 9:26
  • 1
    I try to share my experience as precise it is possible for me, cause I get the same problem with jessie. Maybe it is helpful, maybe not. But I am shure it is more constructive than your comment! Have a nice day! – sagiadinos Aug 24 '17 at 10:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.