From c8e0808ea5ff4b8db073f0c7256ff58d42bbbdcc Mon Sep 17 00:00:00 2001 From: Andrey Skvortsov Date: Tue, 1 Apr 2025 10:30:49 +0300 Subject: [PATCH] flatpak: auto-detect x264 gstreamer plugin due to patent and licensing problems x264 gstreamer plugin isn't included in flatpak runtime. Use openh264 encoder is x264 encoder is missing. openh264 takes bitrate in bits per second and x264 takes bitrate in kbits per second. --- mpegize.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mpegize.py b/mpegize.py index 3f72044..a9464e5 100755 --- a/mpegize.py +++ b/mpegize.py @@ -263,6 +263,13 @@ def gst_convert(mega_dir, out_file, use_jpeg): movie.start_time = tm audio.start_time = tm + def pipeline_264enc(): + if Gst.Registry.get().find_plugin("x264"): + s = "x264enc bitrate=3072 speed-preset=ultrafast" + else: + s = "openh264enc bitrate=3145728 ! h264parse" + return s + def pipeline_video(): if True: s = "appsrc name=source" @@ -277,7 +284,7 @@ def gst_convert(mega_dir, out_file, use_jpeg): elif True: s += " ! videoconvert ! autovideosink" else: - s += " ! videoconvert ! x264enc bitrate=3072 speed-preset=ultrafast ! matroskamux ! filesink location=" + out_file + s += " ! videoconvert ! " + pipeline_264enc() + " ! matroskamux ! filesink location=" + out_file pipeline = Gst.parse_launch(s) @@ -331,7 +338,7 @@ def gst_convert(mega_dir, out_file, use_jpeg): s += "videotestsrc" s += " ! video/x-raw,width=(int)640,height=(int)480,format=(string)RGB " - s += " ! videoconvert ! x264enc bitrate=3072 speed-preset=ultrafast ! matroskamux name=mux" + s += " ! videoconvert ! " + pipeline_264enc() + " ! matroskamux name=mux" if False: s += " ! decodebin ! playsink" else: