コード例 #1
0
ファイル: proxy.py プロジェクト: isabella232/pitivi
    def __get_encoding_profile(self,
                               encoding_target_file,
                               asset=None,
                               width=None,
                               height=None):
        encoding_target = GstPbutils.EncodingTarget.load_from_file(
            os.path.join(get_gstpresets_dir(), encoding_target_file))
        encoding_profile = encoding_target.get_profile("default")

        if not encoding_profile:
            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_format, Gst.PadDirection.SRC, False):
                return None
            if height and width and profile.get_type_nick() == "video":
                profile.set_restriction(
                    Gst.Caps.from_string("video/x-raw, width=%d, height=%d" %
                                         (width, height)))

            if not Gst.ElementFactory.list_filter(
                    Gst.ElementFactory.list_get_elements(
                        Gst.ELEMENT_FACTORY_TYPE_DECODER, Gst.Rank.MARGINAL),
                    profile_format, Gst.PadDirection.SINK, False):
                return None

        if asset:
            # If we have an asset, we force audioconvert to keep
            # the number of channels
            # TODO: remove once https://bugzilla.gnome.org/show_bug.cgi?id=767226
            # is fixed
            info = asset.get_info()
            try:
                # TODO Be smarter about multiple streams
                audio_stream = info.get_audio_streams()[0]
                channels = audio_stream.get_channels()
                audio_profile = [
                    profile for profile in encoding_profile.get_profiles()
                    if isinstance(profile, GstPbutils.EncodingAudioProfile)
                ][0]
                audio_profile.set_restriction(
                    Gst.Caps.from_string("audio/x-raw,channels=%d" % channels))
            except IndexError:
                pass

        return encoding_profile
コード例 #2
0
    def __getEncodingProfile(self, encoding_target_file, asset=None):
        encoding_target = GstPbutils.EncodingTarget.load_from_file(
            os.path.join(get_gstpresets_dir(), encoding_target_file)
        )
        encoding_profile = encoding_target.get_profile("default")

        if not encoding_profile:
            return None

        for profile in encoding_profile.get_profiles():
            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,
            ):
                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,
            ):
                return None

        if asset:
            # If we have an asset, we force audioconvert to keep
            # the number of channels
            # TODO: remove once https://bugzilla.gnome.org/show_bug.cgi?id=767226
            # is fixed
            info = asset.get_info()
            try:
                # TODO Be smarter about multiple streams
                audio_stream = info.get_audio_streams()[0]
                channels = audio_stream.get_channels()
                audio_profile = [
                    profile
                    for profile in encoding_profile.get_profiles()
                    if isinstance(profile, GstPbutils.EncodingAudioProfile)
                ][0]
                audio_profile.set_restriction(Gst.Caps.from_string("audio/x-raw,channels=%d" % channels))
            except IndexError:
                pass

        return encoding_profile
コード例 #3
0
ファイル: proxy.py プロジェクト: dimart/pitivi
    def __getEncodingProfile(self, encoding_target_file):
        encoding_target = GstPbutils.EncodingTarget.load_from_file(
            os.path.join(get_gstpresets_dir(), encoding_target_file))
        encoding_profile = encoding_target.get_profile("default")

        if not encoding_profile:
            return None

        for profile in encoding_profile.get_profiles():
            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):
                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):
                return None
        return encoding_profile
コード例 #4
0
ファイル: proxy.py プロジェクト: jnetzhou/pitivi
    def __getEncodingProfile(self, encoding_target_file, asset=None):
        encoding_target = GstPbutils.EncodingTarget.load_from_file(
            os.path.join(get_gstpresets_dir(), encoding_target_file))
        encoding_profile = encoding_target.get_profile("default")

        if not encoding_profile:
            return None

        for profile in encoding_profile.get_profiles():
            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):
                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):
                return None

        if asset:
            # If we have an asset, we force audioconvert to keep
            # the number of channels
            # TODO: remove once https://bugzilla.gnome.org/show_bug.cgi?id=767226
            # is fixed
            info = asset.get_info()
            try:
                # TODO Be smarter about multiple streams
                audio_stream = info.get_audio_streams()[0]
                channels = audio_stream.get_channels()
                audio_profile = [
                    profile for profile in encoding_profile.get_profiles()
                    if isinstance(profile, GstPbutils.EncodingAudioProfile)
                ][0]
                audio_profile.set_restriction(
                    Gst.Caps.from_string("audio/x-raw,channels=%d" % channels))
            except IndexError:
                pass

        return encoding_profile
コード例 #5
0
ファイル: proxy.py プロジェクト: isabella232/pitivi
from gi.repository import GstPbutils
from gi.repository import GstTranscoder

from pitivi.check import GstDependency
from pitivi.configure import get_gstpresets_dir
from pitivi.dialogs.prefs import PreferencesDialog
from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import ASSET_DURATION_META
from pitivi.utils.misc import asset_get_duration
# Remove check when we depend on Gst >= 1.20
HAS_GST_1_19 = GstDependency("Gst", apiversion="1.0",
                             version_required="1.19").check()

# Make sure gst knowns about our own GstPresets
Gst.preset_set_app_dir(get_gstpresets_dir())


class ProxyingStrategy:
    AUTOMATIC = "automatic"
    ALL = "all"
    NOTHING = "nothing"


GlobalSettings.add_config_section("proxy")
GlobalSettings.add_config_option('proxying_strategy',
                                 section='proxy',
                                 key='proxying-strategy',
                                 default=ProxyingStrategy.AUTOMATIC)

GlobalSettings.add_config_option('num_transcoding_jobs',
コード例 #6
0
import time

from gi.repository import GES
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gst
from gi.repository import GstPbutils
from gi.repository import GstTranscoder

from pitivi.configure import get_gstpresets_dir
from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable

# Make sure gst knowns about our own GstPresets
Gst.preset_set_app_dir(get_gstpresets_dir())


class ProxyingStrategy:
    AUTOMATIC = "automatic"
    ALL = "all"
    NOTHING = "nothing"


GlobalSettings.addConfigSection("proxy")
GlobalSettings.addConfigOption('proxyingStrategy',
                               section='proxy',
                               key='proxying-strategy',
                               default=ProxyingStrategy.AUTOMATIC)
GlobalSettings.addConfigOption('numTranscodingJobs',
                               section='proxy',