[pitivi/1.0] proxy: Use raw audio instead of opus as audio format



commit 262041846f43b863c7d9cabea97c43338178c9d2
Author: Thibault Saunier <tsaunier igalia com>
Date:   Sun Jan 27 17:09:30 2019 -0300

    proxy: Use raw audio instead of opus as audio format
    
    Opus might lead to some clipping on the raw samples and will lower
    the audio Quality, the asset size is not considered to be an issue
    and keeping the exact audio format is nicer in general.
    
    Moreover the stream duration differences can lead to ugly bugs and
    this makes that issue much less probable (and something would be
    really wrong if it still happens with raw audio).
    
    Closes https://gitlab.gnome.org/GNOME/pitivi/issues/2248
    (it doesn't really fixes the issue for the files that are broken,
    those need manual fixing sadly)

 data/gstpresets/jpeg-raw-in-matroska.gep   | 25 +++++++++++++++++++++++++
 data/gstpresets/prores-raw-in-matroska.gep | 24 ++++++++++++++++++++++++
 pitivi/utils/proxy.py                      | 24 ++++++++++++++++++++----
 3 files changed, 69 insertions(+), 4 deletions(-)
---
diff --git a/data/gstpresets/jpeg-raw-in-matroska.gep b/data/gstpresets/jpeg-raw-in-matroska.gep
new file mode 100644
index 00000000..fbcaaf79
--- /dev/null
+++ b/data/gstpresets/jpeg-raw-in-matroska.gep
@@ -0,0 +1,25 @@
+[GStreamer Encoding Target]
+name=matroska
+category=device
+description=Standard config for jpeg and raw audio in matroska
+
+[profile-default]
+name=default
+type=container
+description[c]=Matroska muxer with default configs
+format=video/x-matroska
+
+[streamprofile-raw]
+parent=default
+type=audio
+format=audio/x-raw
+presence=0
+
+[streamprofile-jpeg]
+parent=default
+type=video
+format=image/jpeg
+presence=0
+pass=0
+variableframerate=false
+preset=Quality High
diff --git a/data/gstpresets/prores-raw-in-matroska.gep b/data/gstpresets/prores-raw-in-matroska.gep
new file mode 100644
index 00000000..d2e13db6
--- /dev/null
+++ b/data/gstpresets/prores-raw-in-matroska.gep
@@ -0,0 +1,24 @@
+[GStreamer Encoding Target]
+name=matroskaproresraw
+category=device
+description=Standard config for prores and raw audio in matroska
+
+[profile-default]
+name=default
+type=container
+description[c]=Matroska muxer with default configs
+format=video/x-matroska
+
+[streamprofile-raw]
+parent=default
+type=audio
+format=audio/x-raw
+presence=0
+
+[streamprofile-prores]
+parent=default
+type=video
+format=video/x-prores
+presence=0
+pass=0
+variableframerate=false
diff --git a/pitivi/utils/proxy.py b/pitivi/utils/proxy.py
index b51ca3ec..623ae1a1 100644
--- a/pitivi/utils/proxy.py
+++ b/pitivi/utils/proxy.py
@@ -56,8 +56,8 @@ GlobalSettings.addConfigOption("max_cpu_usage",
                                default=10)
 
 
-ENCODING_FORMAT_PRORES = "prores-opus-in-matroska.gep"
-ENCODING_FORMAT_JPEG = "jpeg-opus-in-matroska.gep"
+ENCODING_FORMAT_PRORES = "prores-raw-in-matroska.gep"
+ENCODING_FORMAT_JPEG = "jpeg-raw-in-matroska.gep"
 
 
 def createEncodingProfileSimple(container_caps, audio_caps, video_caps):
@@ -179,15 +179,21 @@ class ProxyManager(GObject.Object, Loggable):
             return None
 
         for profile in encoding_profile.get_profiles():
+            profile_format = profile.get_format()
+            # Do not verify we have an encoder/decoder for raw audio/video,
+            # as they are not required.
+            if profile_format.intersect(Gst.Caps("audio/x-raw(ANY)")) or \
+                    profile_format.intersect(Gst.Caps("audio/x-video(ANY)")):
+                continue
             if not Gst.ElementFactory.list_filter(
                 Gst.ElementFactory.list_get_elements(
                     Gst.ELEMENT_FACTORY_TYPE_ENCODER, Gst.Rank.MARGINAL),
-                    profile.get_format(), Gst.PadDirection.SRC, False):
+                    profile_format, Gst.PadDirection.SRC, False):
                 return None
             if not Gst.ElementFactory.list_filter(
                 Gst.ElementFactory.list_get_elements(
                     Gst.ELEMENT_FACTORY_TYPE_DECODER, Gst.Rank.MARGINAL),
-                    profile.get_format(), Gst.PadDirection.SINK, False):
+                    profile_format, Gst.PadDirection.SINK, False):
                 return None
 
         if asset:
@@ -318,6 +324,16 @@ class ProxyManager(GObject.Object, Loggable):
 
             del transcoder
 
+        if asset.get_info().get_duration() != proxy.get_info().get_duration():
+            self.error(
+                "Asset %s (duration=%s) and created proxy %s (duration=%s) do not"
+                " have the same duration this should *never* happen, please file"
+                " a bug with the media files." % (
+                    asset.get_id(), Gst.TIME_ARGS(asset.get_info().get_duration()),
+                    proxy.get_id(), Gst.TIME_ARGS(proxy.get_info().get_duration())
+                )
+            )
+
         self.emit("proxy-ready", asset, proxy)
         self.__emitProgress(proxy, 100)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]