mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.52k stars 202 forks source link

Simple patch to enable GPU-based h264_omx encoding on Raspberry Pi #1009

Closed fortiko closed 5 years ago

fortiko commented 5 years ago

Simple change in sickbeard_mp4_automator/converter/avcodecs.py to enable GPU-based encoding on Raspberry Pi using h264_omx, based on this https://stackoverflow.com/questions/50693934/different-h264-encoders-in-ffmpeg

diff --git a/converter/avcodecs.py b/converter/avcodecs.py
index a509089..f73a17f 100644
--- a/converter/avcodecs.py
+++ b/converter/avcodecs.py
@@ -745,6 +745,12 @@ class NVEncH264(H264Codec):
     codec_name = 'h264_nvenc'
     ffmpeg_codec_name = 'h264_nvenc'

+class OMXH264(H264Codec):
+    """
+    OMX H.264/AVC video codec.
+    """
+    codec_name = 'h264_omx'
+    ffmpeg_codec_name = 'h264_omx'

 class H264VAAPI(H264Codec):
     """
@@ -994,7 +1000,7 @@ audio_codec_list = [

 video_codec_list = [
     VideoNullCodec, VideoCopyCodec, TheoraCodec, H264Codec, H264QSV, HEVCQSV, H265Codec,
-    DivxCodec, Vp8Codec, H263Codec, FlvCodec, Mpeg1Codec, NVEncH264, NVEncH265,
+    DivxCodec, Vp8Codec, H263Codec, FlvCodec, Mpeg1Codec, NVEncH264, NVEncH265, OMXH264,
     Mpeg2Codec, H264VAAPI
 ]

To use in autoProcess.ini, just make it the default codec: video-codec = h264_omx,h264,x264,h.264

This also works with current Stretch package 3.2.10-1~deb9u1+rpt3 from here:

https://archive.raspberrypi.org/debian/pool/main/f/ffmpeg/ffmpeg_3.2.10-1~deb9u1+rpt3_armhf.deb

which you should use in any case because of these bugs:

https://github.com/raspberrypi/firmware/issues/1087 https://trac.ffmpeg.org/ticket/6586

mdhiggins commented 5 years ago

Added

nov1n commented 1 year ago

I assume this is faster than the CPU codec? I tried adding the line to the autoProcess.ini, but I still see -vcodec libx264 in the logs. Is this expected, or did I miss something / need to install something? (raspberry pi 4B)