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.
This commit is contained in:
Andrey Skvortsov
2025-04-01 10:30:49 +03:00
committed by Martijn Braam
parent d851344fc0
commit c8e0808ea5

View File

@@ -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: