コード例 #1
0
ファイル: settings.py プロジェクト: dparker18/Pitivi
 def __init__(self, encoder=None, input_stream=None, output_stream=None,
              encodersettings={}):
     """
     @param encoder: The encoder to use. If None, no encoder is used and the
     incoming stream will be outputted directly.
     @type encoder: C{str}.
     @param input_stream: The type of streams accepted by this settings. If
     None are specified, the stream type will be extracted from the encoder.
     If one is specified, then a L{StreamModifierFactory} will be use to
     conform the incoming stream to the specified L{Stream}.
     @type input_stream: L{MultimediaStream}
     @param output_stream: The type of streams accepted by this settings. If
     None are specified, the stream type will be extracted from the encoder.
     @type output_stream: L{MultimediaStream}
     @param encodersettings: Encoder-specific settings.
     @type encodersettings: C{dict}
     """
     # FIXME : What if we need parsers after the encoder ??
     self.encoder = encoder
     self.input_stream = input_stream
     self.output_stream = output_stream
     self.encodersettings = encodersettings
     self.modifyinput = (input_stream != None)
     self.modifyoutput = (output_stream != None)
     if not self.input_stream or not self.output_stream:
         # extract stream from factory
         for p in gst.registry_get_default().lookup_feature(self.encoder).get_static_pad_templates():
             if p.direction == gst.PAD_SINK and not self.input_stream:
                 self.input_stream = get_stream_for_caps(p.get_caps().copy())
                 self.input_stream.pad_name = p.name_template
             elif p.direction == gst.PAD_SRC and not self.output_stream:
                 self.output_stream = get_stream_for_caps(p.get_caps().copy())
                 self.output_stream.pad_name = p.name_template
コード例 #2
0
ファイル: settings.py プロジェクト: dparker18/Pitivi
def export_settings_to_render_settings(export,
        have_video=True, have_audio=True):
    """Convert the specified ExportSettings object to a RenderSettings object.
    """
    # Get the audio and video caps/encoder/settings
    astream = get_stream_for_caps(export.getAudioCaps())
    vstream = get_stream_for_caps(export.getVideoCaps(render=True))

    encoder_settings = []
    if export.vencoder is not None and have_video:
        vset = StreamEncodeSettings(encoder=export.vencoder,
                                    input_stream=vstream,
                                    encodersettings=export.vcodecsettings)
        encoder_settings.append(vset)

    if export.aencoder is not None and have_audio:
        aset = StreamEncodeSettings(encoder=export.aencoder,
                                    input_stream=astream,
                                    encodersettings=export.acodecsettings)
        encoder_settings.append(aset)

    settings = RenderSettings(settings=encoder_settings,
                              muxer=export.muxer,
                              muxersettings=export.containersettings)
    return settings
コード例 #3
0
def export_settings_to_render_settings(export,
                                       have_video=True,
                                       have_audio=True):
    """Convert the specified ExportSettings object to a RenderSettings object.
    """
    # Get the audio and video caps/encoder/settings
    astream = get_stream_for_caps(export.getAudioCaps())
    vstream = get_stream_for_caps(export.getVideoCaps(render=True))

    encoder_settings = []
    if export.vencoder is not None and have_video:
        vset = StreamEncodeSettings(encoder=export.vencoder,
                                    input_stream=vstream,
                                    encodersettings=export.vcodecsettings)
        encoder_settings.append(vset)

    if export.aencoder is not None and have_audio:
        aset = StreamEncodeSettings(encoder=export.aencoder,
                                    input_stream=astream,
                                    encodersettings=export.acodecsettings)
        encoder_settings.append(aset)

    settings = RenderSettings(settings=encoder_settings,
                              muxer=export.muxer,
                              muxersettings=export.containersettings)
    return settings
コード例 #4
0
ファイル: settings.py プロジェクト: qlf/Pitivi
 def __init__(self, encoder=None, input_stream=None, output_stream=None,
              encodersettings={}):
     """
     @param encoder: The encoder to use. If None, no encoder is used and the
     incoming stream will be outputted directly.
     @type encoder: C{str}.
     @param input_stream: The type of streams accepted by this settings. If
     None are specified, the stream type will be extracted from the encoder.
     If one is specified, then a L{StreamModifierFactory} will be use to
     conform the incoming stream to the specified L{Stream}.
     @type input_stream: L{MultimediaStream}
     @param output_stream: The type of streams accepted by this settings. If
     None are specified, the stream type will be extracted from the encoder.
     @type output_stream: L{MultimediaStream}
     @param encodersettings: Encoder-specific settings.
     @type encodersettings: C{dict}
     """
     # FIXME : What if we need parsers after the encoder ??
     self.encoder = encoder
     self.input_stream = input_stream
     self.output_stream = output_stream
     self.encodersettings = encodersettings
     self.modifyinput = (input_stream != None)
     self.modifyoutput = (output_stream != None)
     if not self.input_stream or not self.output_stream:
         # extract stream from factory
         for p in gst.registry_get_default().lookup_feature(self.encoder).get_static_pad_templates():
             if p.direction == gst.PAD_SINK and not self.input_stream:
                 self.input_stream = get_stream_for_caps(p.get_caps().copy())
                 self.input_stream.pad_name = p.name_template
             elif p.direction == gst.PAD_SRC and not self.output_stream:
                 self.output_stream = get_stream_for_caps(p.get_caps().copy())
                 self.output_stream.pad_name = p.name_template
コード例 #5
0
ファイル: pipeline.py プロジェクト: dparker18/Pitivi
    def _binPadAddedCb(self, bin, pad):
        # Our (semi)automatic linking logic is based on caps.
        # gst_pad_get_caps returns all the caps a pad can handle, not
        # necessarily those set with gst_pad_set_caps.
        # Some of our utility elements (like ImageFreeze and FixSeekStart) have
        # template caps ANY but they do caps negotiation (call gst_pad_set_caps)
        # asap, before pushing anything. Therefore we try to get the negotiated
        # caps first here, and fallback on the template caps.
        caps = pad.props.caps
        if caps is None:
            caps = pad.get_caps()

        if caps.is_any():
            self.error("got ANY caps, this should never happen")

        self.debug("bin:%r, pad:%r (%s)", bin, pad, caps.to_string())
        self._lock.acquire()

        try:
            factory = None
            stream = None
            stream_entry = None
            for factory_entry in self.factories.itervalues():
                for stream_entry in factory_entry.streams.itervalues():
                    if stream_entry.bin == bin:
                        factory = factory_entry.factory
                        stream = stream_entry.stream
                        break
                if factory is not None:
                    break

            if factory is None:
                raise PipelineError("New pad on an element we don't control ??")

            stream = get_stream_for_caps(caps, pad)
            if stream not in factory_entry.streams:
                stream_entry = StreamEntry(factory_entry,
                        stream, parent=stream_entry)
                factory_entry.streams[stream] = stream_entry

            self._stream_entry_from_pad[pad] = stream_entry

            # ask all actions using this producer if they handle it
            compatactions = [action for action in self.actions
                             if factory in action.producers]
            self.debug("Asking all actions (%d/%d) using that producer [%r] if they can handle it",
                      len(compatactions), len(self.actions), factory)
            for a in self.actions:
                self.debug("Action %r, producers %r", a, a.producers)
            handled = False
            for action in compatactions:
                handled |= action.handleNewStream(factory, stream)

            if not handled:
                self.debug("No action handled this Stream")
                self.emit('unhandled-stream', stream)
        finally:
            self.debug("Done handling new pad")
            self._lock.release()
コード例 #6
0
    def _binPadAddedCb(self, bin, pad):
        # Our (semi)automatic linking logic is based on caps.
        # gst_pad_get_caps returns all the caps a pad can handle, not
        # necessarily those set with gst_pad_set_caps.
        # Some of our utility elements (like ImageFreeze and FixSeekStart) have
        # template caps ANY but they do caps negotiation (call gst_pad_set_caps)
        # asap, before pushing anything. Therefore we try to get the negotiated
        # caps first here, and fallback on the template caps.
        caps = pad.props.caps
        if caps is None:
            caps = pad.get_caps()

        if caps.is_any():
            self.error("got ANY caps, this should never happen")

        self.debug("bin:%r, pad:%r (%s)", bin, pad, caps.to_string())
        self._lock.acquire()

        try:
            factory = None
            stream = None
            stream_entry = None
            for factory_entry in self.factories.itervalues():
                for stream_entry in factory_entry.streams.itervalues():
                    if stream_entry.bin == bin:
                        factory = factory_entry.factory
                        stream = stream_entry.stream
                        break
                if factory is not None:
                    break

            if factory is None:
                raise PipelineError("New pad on an element we don't control ??")

            stream = get_stream_for_caps(caps, pad)
            if stream not in factory_entry.streams:
                factory_entry.streams[stream] = StreamEntry(factory_entry,
                        stream, parent=stream_entry)
                stream_entry = factory_entry.streams[stream]

            self._stream_entry_from_pad[pad] = stream_entry

            # ask all actions using this producer if they handle it
            compatactions = [action for action in self.actions
                             if factory in action.producers]
            self.debug("Asking all actions (%d/%d) using that producer [%r] if they can handle it",
                      len(compatactions), len(self.actions), factory)
            for a in self.actions:
                self.debug("Action %r, producers %r", a, a.producers)
            handled = False
            for action in compatactions:
                handled |= action.handleNewStream(factory, stream)

            if handled == False:
                self.debug("No action handled this Stream")
                self.emit('unhandled-stream', stream)
        finally:
            self.debug("Done handling new pad")
            self._lock.release()
コード例 #7
0
def export_settings_to_render_settings(export):
    # Get the audio and video caps/encoder/settings
    astream = get_stream_for_caps(export.getAudioCaps())
    vstream = get_stream_for_caps(export.getVideoCaps())

    encoder_settings = []
    if export.vencoder is not None:
        vset = StreamEncodeSettings(encoder=export.vencoder,
                                    input_stream=vstream,
                                    encodersettings=export.vcodecsettings)
        encoder_settings.append(vset)

    if export.aencoder is not None:
        aset = StreamEncodeSettings(encoder=export.aencoder,
                                    input_stream=astream,
                                    encodersettings=export.acodecsettings)
        encoder_settings.append(aset)

    settings = RenderSettings(settings=encoder_settings,
                              muxer=export.muxer,
                              muxersettings=export.containersettings)
    return settings