1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.