def _create_broadcast_ts_muxing(encoding, output, output_path, video_stream,
                                audio_streams):
    # type: (Encoding, Output, str, Stream, dict) -> BroadcastTsMuxing
    """
    Creates a BroadcastTS muxing with one video and multiple audio streams

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/sections/encodings#/Encoding/PostEncodingEncodingsMuxingsBroadcastTsByEncodingId

    :param encoding: The encoding to which the muxing will be added
    :param output: The output resource to which the unencrypted segments will be written to
    :param output_path: The output path where the unencrypted segments will be written to
    :param video_stream: The video stream to be included in the muxing
    :param audio_streams: A map of audio streams to be included in the muxing, with the key value
                          specifying their language tag
    """

    audio_muxing_streams = []

    for key in audio_streams:
        audio_muxing_streams.append(
            MuxingStream(stream_id=audio_streams[key].id))

    video_muxing_stream = MuxingStream(stream_id=video_stream.id)

    pid = 2000

    audio_input_stream_configurations = []

    for lang in audio_streams:
        audio_input_stream_configurations.append(
            BroadcastTsAudioInputStreamConfiguration(
                stream_id=audio_streams[lang].id,
                packet_identifier=pid,
                language=lang))
        pid += 1

    streams = [video_muxing_stream]
    streams.extend(audio_muxing_streams)
    muxing = BroadcastTsMuxing(
        name=EXAMPLE_NAME,
        filename="broadcast.ts",
        segment_length=4.0,
        outputs=[
            _build_encoding_output(output=output, output_path=output_path)
        ],
        streams=streams,
        configuration=BroadcastTsMuxingConfiguration(
            video_streams=[
                BroadcastTsVideoInputStreamConfiguration(
                    stream_id=video_stream.id)
            ],
            audio_streams=audio_input_stream_configurations))

    return bitmovin_api.encoding.encodings.muxings.broadcast_ts.create(
        encoding_id=encoding.id, broadcast_ts_muxing=muxing)
Пример #2
0
def _create_mp4_muxing(encoding, output, output_path, streams, file_name):
    # type: (Encoding, Output, str, list[Stream], str) -> Mp4Muxing
    """
    Creates a fragmented MP4 muxing. This will generate segments with a given segment length for
    adaptive streaming.

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/all#/Encoding/PostEncodingEncodingsMuxingsFmp4ByEncodingId

    :param encoding: The encoding where to add the muxing to
    :param output: The output that should be used for the muxing to write the segments to
    :param output_path: The output path where the fragmented segments will be written to
    :param streams: The stream that is associated with the muxing
    :param file_name: The name of the file that will be written to the output
    """

    muxing = Mp4Muxing(outputs=[
        _build_encoding_output(output=output, output_path=output_path)
    ],
                       filename=file_name)

    for stream in streams:
        muxing_stream = MuxingStream(stream_id=stream.id)
        muxing.streams.append(muxing_stream)

    return bitmovin_api.encoding.encodings.muxings.mp4.create(
        encoding_id=encoding.id, mp4_muxing=muxing)
Пример #3
0
def _create_ts_muxing(encoding, output, output_path, stream):
    # type: (Encoding, Output, str, Stream) -> TsMuxing
    """
    Creates a fragmented TS muxing. This will generate segments with a given segment length for
    adaptive streaming.

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/all#/Encoding/PostEncodingEncodingsMuxingsFmp4ByEncodingId

    :param encoding: The encoding where to add the muxing to
    :param output: The output that should be used for the muxing to write the segments to
    :param output_path: The output path where the segments will be written to
    :param stream: The stream that is associated with the muxing
    """

    muxing_stream = MuxingStream(stream_id=stream.id)

    muxing = TsMuxing(outputs=[
        _build_encoding_output(output=output, output_path=output_path)
    ],
                      segment_length=4.0,
                      streams=[muxing_stream])

    return bitmovin_api.encoding.encodings.muxings.ts.create(
        encoding_id=encoding.id, ts_muxing=muxing)
Пример #4
0
def _create_mp4_muxing(encoding, output, output_path, filename, fragment_duration, stream):
    # type: (Encoding, Output, str, str, Stream) -> Mp4Muxing
    """
    Creates an MP4 muxing.

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/sections/encodings#/Encoding/PostEncodingEncodingsMuxingsMp4ByEncodingId

    :param encoding: The encoding to add the MP4 muxing to
    :param output: The output that should be used for the muxing to write the segments to
    :param output_path: The output path where the fragments will be written to
    :param filename: The filename for the MP4 file
    :param stream: The stream to be added to the muxing
    """

    muxing = Mp4Muxing(
        filename=filename,
        outputs=[Utils.build_encoding_output(output_id=output.id,
                                             asset_name=Config.ASSET_NAME,
                                             output_path=output_path)],
        streams=[MuxingStream(stream_id=stream.id)],
        fragment_duration=fragment_duration,
        fragmented_mp4_muxing_manifest_type=FragmentedMp4MuxingManifestType.DASH_ON_DEMAND
    )

    return encoding_api.encodings.muxings.mp4.create(encoding_id=encoding.id, mp4_muxing=muxing)
def _create_progressive_ts_muxing(encoding, output, output_path, streams,
                                  file_name):
    # type: (Encoding, Output, str, list, str) -> ProgressiveTsMuxing
    """
    Creates an progressive TS muxing.

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/sections/encodings#/Encoding/PostEncodingEncodingsMuxingsTsByEncodingId

    :param encoding: The encoding to add the muxing to
    :param output: The output that should be used for the muxing to write the segments to
    :param output_path: The output path where the fragments will be written to
    :param streams: A list of streams to be added to the muxing
    :param file_name: The name of the file that will be written to the output
    """

    muxing = ProgressiveTsMuxing(
        filename=file_name,
        outputs=[
            _build_encoding_output(output=output, output_path=output_path)
        ],
        streams=[MuxingStream(stream_id=stream.id) for stream in streams])

    return bitmovin_api.encoding.encodings.muxings.progressive_ts.create(
        encoding_id=encoding.id, progressive_ts_muxing=muxing)
def _create_fmp4_muxing(encoding, stream):
    # type: (Encoding, Stream) -> Fmp4Muxing
    """
    Creates a fragmented MP4 muxing. This will generate segments with a given segment length for
    adaptive streaming.
    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/all#/Encoding/PostEncodingEncodingsMuxingsFmp4ByEncodingId
    @param encoding The encoding where to add the muxing to
    @param stream The stream that is associated with the muxing
    """

    muxing = Fmp4Muxing(segment_length=4.0,
                        streams=[MuxingStream(stream_id=stream.id)])

    return bitmovin_api.encoding.encodings.muxings.fmp4.create(
        encoding_id=encoding.id, fmp4_muxing=muxing)
Пример #7
0
def _create_ts_muxing(encoding, output, output_path, stream):
    # type: (Encoding, Output, str, Stream) -> TsMuxing
    """
    Creates a fragmented MP4 muxing. This will generate segments with a given segment length for
    adaptive streaming.

    <p>API endpoint:
    https://bitmovin.com/docs/encoding/api-reference/all#/Encoding/PostEncodingEncodingsMuxingsFmp4ByEncodingId

    @param encoding The encoding where to add the muxing to
    @param output The output that should be used for the muxing to write the segments to
    @param output_path The output path where the fragmented segments will be written to
    @param stream The stream that is associated with the muxing
    """

    muxing = TsMuxing(
        segment_length=4.0,
        outputs=[Utils.build_encoding_output(output_id=output.id,
                                             asset_name=Config.ASSET_NAME,
                                             output_path=output_path)],
        streams=[MuxingStream(stream_id=stream.id)]
    )

    return bitmovin_api.encoding.encodings.muxings.ts.create(encoding_id=encoding.id, ts_muxing=muxing)