def _get_sample_muxing(self):
        stream = self._get_sample_stream()

        create_stream_response = self.bitmovin.encodings.Stream.create(
            object_=stream, encoding_id=self.sampleEncoding.id)
        self.assertIsNotNone(create_stream_response)
        self.assertIsNotNone(create_stream_response.resource)
        self.assertIsNotNone(create_stream_response.resource.id)

        muxing_stream = MuxingStream(
            stream_id=create_stream_response.resource.id)

        time_code = TimeCode(time_code_start='01:00:00:00')

        internal_chunk_length = InternalChunkLength(
            mode=InternalChunkLengthMode.CUSTOM, custom_chunk_length=3.0)

        muxing = MP4Muxing(
            streams=[muxing_stream],
            filename='myprogressive.mp4',
            outputs=stream.outputs,
            name='Sample MP4 Muxing',
            fragment_duration=5,
            time_code=time_code,
            stream_conditions_mode=StreamConditionsMode.DROP_MUXING,
            internal_chunk_length=internal_chunk_length)
        return muxing
def create_muxing(encoding, output, video_stream, audio_stream, filename):
    acl_entry = ACLEntry(permission=ACLPermission.PUBLIC_READ)

    video_muxing_output = EncodingOutput(output_id=output.id,
                                         output_path=OUTPUT_BASE_PATH,
                                         acl=[acl_entry])

    video_muxing_stream = MuxingStream(video_stream.id)
    audio_muxing_stream = MuxingStream(audio_stream.id)

    muxing = MP4Muxing(streams=[video_muxing_stream, audio_muxing_stream],
                       outputs=[video_muxing_output],
                       filename=filename)

    muxing = bitmovin.encodings.Muxing.MP4.create(
        object_=muxing, encoding_id=encoding.id).resource
Esempio n. 3
0
    def _get_sample_muxing(self):
        stream = self._get_sample_stream()

        create_stream_response = self.bitmovin.encodings.Stream.create(
            object_=stream, encoding_id=self.sampleEncoding.id)
        self.assertIsNotNone(create_stream_response)
        self.assertIsNotNone(create_stream_response.resource)
        self.assertIsNotNone(create_stream_response.resource.id)

        muxing_stream = MuxingStream(
            stream_id=create_stream_response.resource.id)

        muxing = MP4Muxing(streams=[muxing_stream],
                           filename='myprogressive.mp4',
                           outputs=stream.outputs,
                           name='Sample MP4 Muxing')
        return muxing
Esempio n. 4
0
    def _get_sample_muxing(self):
        stream = self._get_sample_stream()

        create_stream_response = self.bitmovin.encodings.Stream.create(
            object_=stream, encoding_id=self.sampleEncoding.id)
        self.assertIsNotNone(create_stream_response)
        self.assertIsNotNone(create_stream_response.resource)
        self.assertIsNotNone(create_stream_response.resource.id)

        muxing_stream = MuxingStream(
            stream_id=create_stream_response.resource.id)

        muxing = MP4Muxing(streams=[muxing_stream],
                           filename="myrendition.ismv",
                           fragment_duration=4000,
                           outputs=stream.outputs,
                           name='Sample MP4 Muxing')
        return muxing, create_stream_response.resource
Esempio n. 5
0
    def _get_sample_muxing(self):
        stream = self._get_sample_stream()

        create_stream_response = self.bitmovin.encodings.Stream.create(
            object_=stream, encoding_id=self.sampleEncoding.id)
        self.assertIsNotNone(create_stream_response)
        self.assertIsNotNone(create_stream_response.resource)
        self.assertIsNotNone(create_stream_response.resource.id)

        muxing_stream = MuxingStream(
            stream_id=create_stream_response.resource.id)

        time_code = TimeCode(time_code_start='01:00:00:00')

        muxing = MP4Muxing(streams=[muxing_stream],
                           filename='myprogressive.mp4',
                           outputs=stream.outputs,
                           name='Sample MP4 Muxing',
                           fragment_duration=5,
                           time_code=time_code)
        return muxing
Esempio n. 6
0
def create_mp4_muxing(encoding, s3_output, video_stream, audio_stream):
    """
    An MP4 muxing will be created for with the Per-Title video stream template and the audio stream.
    This muxing must define either {uuid} or {bitrate} in the output path.  These placeholders will be replaced during
    the generation of the Per-Title.
    :param encoding: The reference of the encoding
    :param s3_output: The output the files should be written to
    :param video_stream: The Per-Title template video stream
    :param audio_stream: The audio stream
    :return:
    """
    acl_entry = ACLEntry(permission=ACLPermission.PUBLIC_READ)
    mp4_muxing_output = EncodingOutput(output_id=s3_output.id,
                                       output_path=OUTPUT_BASE_PATH +
                                       "{width}_{bitrate}_{uuid}/",
                                       acl=[acl_entry])
    mp4_muxing = MP4Muxing(
        streams=[MuxingStream(video_stream.id),
                 MuxingStream(audio_stream.id)],
        filename='per_title_mp4.mp4',
        outputs=[mp4_muxing_output],
        name='MP4 Muxing')
    bitmovin.encodings.Muxing.MP4.create(object_=mp4_muxing,
                                         encoding_id=encoding.id)
Esempio n. 7
0
def main():
    bitmovin = Bitmovin(api_key=API_KEY)

    s3_input = S3Input(access_key=S3_INPUT_ACCESSKEY,
                       secret_key=S3_INPUT_SECRETKEY,
                       bucket_name=S3_INPUT_BUCKETNAME,
                       name='Sample S3 Output')
    s3_input = bitmovin.inputs.S3.create(s3_input).resource

    s3_output = S3Output(access_key=S3_OUTPUT_ACCESSKEY,
                         secret_key=S3_OUTPUT_SECRETKEY,
                         bucket_name=S3_OUTPUT_BUCKETNAME,
                         name='Sample S3 Output')
    s3_output = bitmovin.outputs.S3.create(s3_output).resource

    acl_entry = ACLEntry(permission=ACLPermission.PUBLIC_READ)

    encoding = Encoding(name='example mp4 encoding for smooth',
                        cloud_region=CloudRegion.GOOGLE_EUROPE_WEST_1)

    encoding = bitmovin.encodings.Encoding.create(encoding).resource

    encoding_configs = []

    # Iterate over all encoding profiles and create the H264 configuration with the defined height and bitrate.
    for idx, _ in enumerate(encoding_profiles_h264):
        profile_h264 = encoding_profiles_h264[idx]
        encoding_config = dict(profile_h264=profile_h264)
        h264_codec = H264CodecConfiguration(
            name='H264 Codec {}p {}k Configuration'.format(
                profile_h264.get('height'), profile_h264.get('bitrate')),
            bitrate=profile_h264.get('bitrate') * 1000,
            height=profile_h264.get('height'),
            profile=profile_h264.get('profile'),
            rate=profile_h264.get("fps"))
        encoding_config[
            'h264_codec'] = bitmovin.codecConfigurations.H264.create(
                h264_codec).resource
        encoding_configs.append(encoding_config)

    audio_codec_configuration = AACCodecConfiguration(
        name='example_audio_codec_configuration_english',
        bitrate=128000,
        rate=48000)
    audio_codec_configuration = bitmovin.codecConfigurations.AAC.create(
        audio_codec_configuration).resource

    video_input_stream = StreamInput(input_id=s3_input.id,
                                     input_path=S3_INPUT_PATH,
                                     selection_mode=SelectionMode.AUTO)

    audio_input_stream = StreamInput(input_id=s3_input.id,
                                     input_path=S3_INPUT_PATH,
                                     selection_mode=SelectionMode.AUTO)

    # With the configurations and the input file streams are now created and muxed later on.
    for encoding_config in encoding_configs:
        encoding_profile = encoding_config.get("profile_h264")
        video_stream_condition = Condition(attribute="HEIGHT",
                                           operator=">=",
                                           value=str(
                                               encoding_profile.get('height')))
        video_stream_h264 = Stream(
            codec_configuration_id=encoding_config.get("h264_codec").id,
            input_streams=[video_input_stream],
            conditions=video_stream_condition,
            name='Stream H264 {}p_{}k'.format(encoding_profile.get('height'),
                                              encoding_profile.get('bitrate')))

        encoding_config['h264_stream'] = bitmovin.encodings.Stream.create(
            object_=video_stream_h264, encoding_id=encoding.id).resource

    audio_stream_condition = Condition(attribute="INPUTSTREAM",
                                       operator="==",
                                       value="TRUE")
    audio_stream = Stream(codec_configuration_id=audio_codec_configuration.id,
                          input_streams=[audio_input_stream],
                          conditions=audio_stream_condition,
                          name='Sample Stream AUDIO')

    audio_stream = bitmovin.encodings.Stream.create(
        object_=audio_stream, encoding_id=encoding.id).resource

    for encoding_config in encoding_configs:
        encoding_profile = encoding_config.get("profile_h264")
        video_muxing_stream_h264 = MuxingStream(
            encoding_config.get("h264_stream").id)
        video_muxing_output_h264 = EncodingOutput(output_id=s3_output.id,
                                                  output_path=OUTPUT_BASE_PATH,
                                                  acl=[acl_entry])
        video_muxing_h264 = MP4Muxing(
            filename='video_{}p.ismv'.format(encoding_profile.get('height')),
            fragment_duration=4000,
            streams=[video_muxing_stream_h264],
            outputs=[video_muxing_output_h264],
            name='Sample Muxing {}p'.format(encoding_profile.get('height')))

        encoding_config['h264_muxing'] = bitmovin.encodings.Muxing.MP4.create(
            object_=video_muxing_h264, encoding_id=encoding.id).resource

    audio_muxing_stream = MuxingStream(audio_stream.id)
    audio_muxing_output = EncodingOutput(output_id=s3_output.id,
                                         output_path=OUTPUT_BASE_PATH,
                                         acl=[acl_entry])

    audio_muxing = MP4Muxing(filename='audio.isma',
                             fragment_duration=4000,
                             streams=[audio_muxing_stream],
                             outputs=[audio_muxing_output],
                             name='Sample Muxing AUDIO')

    audio_muxing = bitmovin.encodings.Muxing.MP4.create(
        object_=audio_muxing, encoding_id=encoding.id).resource

    bitmovin.encodings.Encoding.start(encoding_id=encoding.id)

    try:
        bitmovin.encodings.Encoding.wait_until_finished(
            encoding_id=encoding.id)
    except BitmovinError as bitmovin_error:
        print("Exception occurred while waiting for encoding to finish: {}".
              format(bitmovin_error))

    manifest_output = EncodingOutput(output_id=s3_output.id,
                                     output_path=OUTPUT_BASE_PATH,
                                     acl=[acl_entry])

    smooth_manifest = SmoothManifest(
        server_manifest_name='example_manifest_smooth.ism',
        client_manifest_name='example_manifest_smooth.ismc',
        outputs=[manifest_output],
        name='Sample SmoothStreaming Manifest')

    smooth_manifest = bitmovin.manifests.Smooth.create(
        object_=smooth_manifest).resource

    mp4_representation_audio = MP4Representation(encoding_id=encoding.id,
                                                 muxing_id=audio_muxing.id,
                                                 media_file='audio.isma')

    mp4_representation_audio = bitmovin.manifests.Smooth.MP4Representation.create(
        manifest_id=smooth_manifest.id, object_=mp4_representation_audio)

    for encoding_config in encoding_configs:
        encoding_profile = encoding_config.get("profile_h264")
        muxing = encoding_config.get('h264_muxing')
        mp4_representation = MP4Representation(
            encoding_id=encoding.id,
            muxing_id=muxing.id,
            media_file='video_{}p.ismv'.format(encoding_profile.get('height')))

        encoding_config[
            'h264_smooth'] = bitmovin.manifests.Smooth.MP4Representation.create(
                manifest_id=smooth_manifest.id, object_=mp4_representation)

    bitmovin.manifests.Smooth.start(manifest_id=smooth_manifest.id)

    try:
        bitmovin.manifests.Smooth.wait_until_finished(
            manifest_id=smooth_manifest.id)
    except BitmovinError as bitmovin_error:
        print(
            "Exception occurred while waiting for Smooth manifest creation to finish: {}"
            .format(bitmovin_error))
Esempio n. 8
0
def main():
    bitmovin = Bitmovin(api_key=API_KEY)

    https_input = HTTPSInput(host=HTTPS_INPUT_HOST,
                             name='multiple_audio_progressive_mp4 HTTPS input')
    https_input = bitmovin.inputs.HTTPS.create(https_input).resource

    s3_output = S3Output(access_key=S3_OUTPUT_ACCESSKEY,
                         secret_key=S3_OUTPUT_SECRETKEY,
                         bucket_name=S3_OUTPUT_BUCKETNAME,
                         name='Sample S3 Output')
    s3_output = bitmovin.outputs.S3.create(s3_output).resource

    encoding = Encoding(name="bitmovin-python example",
                        cloud_region=CloudRegion.GOOGLE_EUROPE_WEST_1)

    encoding = bitmovin.encodings.Encoding.create(encoding).resource

    video_codec_configuration = H264CodecConfiguration(
        name='example_video_codec_configuration_h264',
        bitrate=1000000,
        rate=50.0,
        width=1280,
        height=720,
        profile=H264Profile.HIGH)
    video_codec_configuration = bitmovin.codecConfigurations.H264.create(
        video_codec_configuration).resource

    audio_codec_configuration = AACCodecConfiguration(
        name='example_audio_codec_configuration_aac',
        bitrate=128000,
        rate=48000)
    audio_codec_configuration = bitmovin.codecConfigurations.AAC.create(
        audio_codec_configuration).resource

    audio_input_stream_1 = StreamInput(
        input_id=https_input.id,
        input_path=HTTPS_INPUT_PATH,
        selection_mode=SelectionMode.POSITION_ABSOLUTE,
        position=0)
    audio_input_stream_2 = StreamInput(
        input_id=https_input.id,
        input_path=HTTPS_INPUT_PATH,
        selection_mode=SelectionMode.POSITION_ABSOLUTE,
        position=1)
    video_input_stream = StreamInput(
        input_id=https_input.id,
        input_path=HTTPS_INPUT_PATH,
        selection_mode=SelectionMode.POSITION_ABSOLUTE,
        position=2)

    video_stream = Stream(codec_configuration_id=video_codec_configuration.id,
                          input_streams=[video_input_stream],
                          name='Sample Video Stream')
    video_stream = bitmovin.encodings.Stream.create(
        object_=video_stream, encoding_id=encoding.id).resource

    audio_stream_1 = Stream(
        codec_configuration_id=audio_codec_configuration.id,
        input_streams=[audio_input_stream_1],
        name='Sample Audio Stream 1')
    audio_stream_1 = bitmovin.encodings.Stream.create(
        object_=audio_stream_1, encoding_id=encoding.id).resource

    audio_stream_2 = Stream(
        codec_configuration_id=audio_codec_configuration.id,
        input_streams=[audio_input_stream_2],
        name='Sample Audio Stream 2')
    audio_stream_2 = bitmovin.encodings.Stream.create(
        object_=audio_stream_2, encoding_id=encoding.id).resource

    acl_entry = ACLEntry(permission=ACLPermission.PUBLIC_READ)
    encoding_output = EncodingOutput(output_id=s3_output.id,
                                     output_path=OUTPUT_BASE_PATH,
                                     acl=[acl_entry])

    video_muxing_stream = MuxingStream(video_stream.id)
    audio_muxing_stream_1 = MuxingStream(audio_stream_1.id)
    audio_muxing_stream_2 = MuxingStream(audio_stream_2.id)

    progressive_muxing = MP4Muxing(filename="example_progressive_muxing.mp4",
                                   streams=[
                                       video_muxing_stream,
                                       audio_muxing_stream_1,
                                       audio_muxing_stream_2
                                   ],
                                   outputs=[encoding_output],
                                   name='Sample Progressive Muxing')

    progressive_muxing = bitmovin.encodings.Muxing.MP4.create(
        object_=progressive_muxing, encoding_id=encoding.id)

    bitmovin.encodings.Encoding.start(encoding_id=encoding.id)

    try:
        bitmovin.encodings.Encoding.wait_until_finished(
            encoding_id=encoding.id)
    except BitmovinError as bitmovin_error:
        print("Exception occurred while waiting for encoding to finish: {}".
              format(bitmovin_error))
def main():
    bitmovin = Bitmovin(api_key=API_KEY)

    https_input = HTTPSInput(name='create_simple_encoding HTTPS input',
                             host=HTTPS_INPUT_HOST)
    https_input = bitmovin.inputs.HTTPS.create(https_input).resource

    s3_output = S3Output(access_key=S3_OUTPUT_ACCESSKEY,
                         secret_key=S3_OUTPUT_SECRETKEY,
                         bucket_name=S3_OUTPUT_BUCKETNAME,
                         name='Sample S3 Output')
    s3_output = bitmovin.outputs.S3.create(s3_output).resource

    encoding = Encoding(name='example encoding',
                        cloud_region=CloudRegion.GOOGLE_EUROPE_WEST_1,
                        encoder_version='BETA')

    encoding = bitmovin.encodings.Encoding.create(encoding).resource

    video_codec_configuration_1080p = H264CodecConfiguration(
        name='example_video_codec_configuration_1080p',
        bitrate=4800000,
        rate=25.0,
        width=1920,
        height=1080,
        profile=H264Profile.HIGH)
    video_codec_configuration_1080p = bitmovin.codecConfigurations.H264.create(
        video_codec_configuration_1080p).resource

    audio_codec_configuration = AACCodecConfiguration(
        name='example_audio_codec_configuration_english',
        bitrate=128000,
        rate=48000)
    audio_codec_configuration = bitmovin.codecConfigurations.AAC.create(
        audio_codec_configuration).resource

    video_input_stream = StreamInput(input_id=https_input.id,
                                     input_path=HTTPS_INPUT_PATH,
                                     selection_mode=SelectionMode.AUTO)
    audio_input_stream = StreamInput(input_id=https_input.id,
                                     input_path=HTTPS_INPUT_PATH,
                                     selection_mode=SelectionMode.AUTO)

    video_stream_1080p = Stream(
        codec_configuration_id=video_codec_configuration_1080p.id,
        input_streams=[video_input_stream],
        name='Sample Stream 1080p')
    video_stream_1080p = bitmovin.encodings.Stream.create(
        object_=video_stream_1080p, encoding_id=encoding.id).resource

    audio_stream = Stream(codec_configuration_id=audio_codec_configuration.id,
                          input_streams=[audio_input_stream],
                          name='Sample Stream AUDIO')
    audio_stream = bitmovin.encodings.Stream.create(
        object_=audio_stream, encoding_id=encoding.id).resource

    audio_muxing_stream = MuxingStream(audio_stream.id)

    video_muxing_stream_1080p = MuxingStream(video_stream_1080p.id)

    acl_entry = ACLEntry(permission=ACLPermission.PUBLIC_READ)
    mp4_muxing_output = EncodingOutput(output_id=s3_output.id,
                                       output_path=OUTPUT_BASE_PATH,
                                       acl=[acl_entry])

    mp4_muxing = MP4Muxing(
        streams=[video_muxing_stream_1080p, audio_muxing_stream],
        filename='myCoolMp4.mp4',
        outputs=[mp4_muxing_output],
        name='Sample MP4 Muxing 1080p',
        description='This is a MP4 muxing from which to retrieve info')

    mp4_muxing = bitmovin.encodings.Muxing.MP4.create(
        object_=mp4_muxing, encoding_id=encoding.id).resource

    bitmovin.encodings.Encoding.start(encoding_id=encoding.id)

    try:
        bitmovin.encodings.Encoding.wait_until_finished(
            encoding_id=encoding.id)
    except BitmovinError as bitmovin_error:
        print("Exception occurred while waiting for encoding to finish: {}".
              format(bitmovin_error))

    mp4_muxing_information = bitmovin.encodings.Muxing.MP4.retrieve_information(
        encoding_id=encoding.id, muxing_id=mp4_muxing.id).resource

    print_muxing_information(mp4_muxing_information)