Edit: Removed a patch that is now included in the repo, and added a checkout command to select the right branch.
As I have fiddled with this in the last days and finally had some success, I am writing down some notes here in case others want to reproduce hardware decoded H.264 playback on MNT Reform / i.MX8MQ with mpv:
git clone https://github.com/martinetd/FFmpeg
cd FFmpeg
git checkout v4l2-request
./configure --enable-v4l2-request --enable-libdrm --enable-libudev --enable-shared --enable-hwaccel=h264_v4l2request
Before you can successfully build, a few changes have to be made. First, make sure that the line declaring EXTRALIBS-avcodec
in ffbuild/config.mak
includes -ludev
.
Then, you need to have some newer video-related Linux UAPI headers than Debian ships. I did the following brutal things:
wget https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/v4l2-controls.h
sudo cp v4l2-controls.h /usr/include/linux/
And added the following line after line 736 in /usr/include/linux/videodev2.h
:
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
Afterwards, you can build ffmpeg and install it to /usr/local
:
make -j4
sudo make install
ldconfig /usr/local/lib
Then, clone and build mpv:
git clone https://github.com/mpv-player/mpv
cd mpv
./bootstrap.py
./waf configure
./waf
./waf install
And play a video like this:
mpv --hwdec=auto ~/Videos/video.mp4
Check if the HW decoder was in use:
cat /proc/interrupts
The following line should have a positive number in the second column:
58: 2983 0 0 0 GPCv2 7 Level 38300000.video-codec