From ef134b86fb062d63e5a16a254286f159cc719570 Mon Sep 17 00:00:00 2001 From: Georg Fu <38907544+fuetgeo@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:13:02 +0200 Subject: [PATCH] be more explicit on source stream selection (#43) set 'selectionMode' to AUTO (instead of relying on the default) to be more explicit; do not set 'position' when using selectionMode AUTO as it has no effect; minor improvements regarding creation and naming of codec configurations --- .../ConcatenationMultipleInputs.cs | 11 ++--- .../PerTitleEncoding.cs | 3 +- .../RtmpLiveEncoding.cs | 9 ++-- .../java/ConcatenationMultipleInputs.java | 11 ++--- java/src/main/java/HdrConversions.java | 15 ++---- java/src/main/java/RtmpLiveEncoding.java | 48 +++++++------------ .../tutorials/RedundantRtmpLiveEncoding.java | 48 +++++++------------ .../main/java/tutorials/SrtLiveEncoding.java | 47 +++++++----------- javascript/src/CencDrmContentProtection.ts | 4 +- javascript/src/ConcatenationMultipleInputs.ts | 12 ++--- javascript/src/DefaultManifest.ts | 4 +- javascript/src/EncodingWithCdnOutput.ts | 2 + javascript/src/Filters.ts | 4 +- javascript/src/FixedBitrateLadder.ts | 4 +- javascript/src/MultiCodecEncoding.ts | 4 +- javascript/src/PerTitleEncoding.ts | 4 +- javascript/src/RtmpLiveEncoding.ts | 11 ++--- javascript/src/ServerSideAdInsertion.ts | 4 +- php/src/BatchEncoding.php | 2 + php/src/CencDrmContentProtection.php | 2 + php/src/DefaultManifest.php | 2 + php/src/Filters.php | 2 + php/src/FixedBitrateLadder.php | 2 + php/src/MultiCodecEncoding.php | 2 + php/src/RtmpLiveEncoding.php | 9 ++-- python/src/cenc_drm_content_protection.py | 5 +- python/src/concatenation_multiple_inputs.py | 16 +++---- python/src/default_manifest.py | 5 +- python/src/encoding_with_cdn_output.py | 20 +++++--- python/src/filters.py | 6 ++- python/src/fixed_bitrate_ladder.py | 5 +- python/src/hdr_conversions.py | 17 +++---- python/src/multi_codec_encoding.py | 7 +-- python/src/per_title_encoding.py | 7 +-- python/src/rtmp_live_encoding.py | 15 +++--- 35 files changed, 178 insertions(+), 191 deletions(-) diff --git a/dotnet/Bitmovin.Api.Sdk.Examples/ConcatenationMultipleInputs.cs b/dotnet/Bitmovin.Api.Sdk.Examples/ConcatenationMultipleInputs.cs index 86c9212..880c954 100644 --- a/dotnet/Bitmovin.Api.Sdk.Examples/ConcatenationMultipleInputs.cs +++ b/dotnet/Bitmovin.Api.Sdk.Examples/ConcatenationMultipleInputs.cs @@ -111,9 +111,9 @@ public async Task RunExample(string[] args) _configProvider.GetS3OutputSecretKey()); // Define a video and audio stream as an IngestInputStream to represent each input file (main, bumper, and promo) - var main = await CreateIngestInputStream(encoding, httpInput, mainFilePath, StreamSelectionMode.AUTO); - var bumper = await CreateIngestInputStream(encoding, httpInput, bumperFilePath, StreamSelectionMode.AUTO); - var promo = await CreateIngestInputStream(encoding, httpInput, promoFilePath, StreamSelectionMode.AUTO); + var main = await CreateIngestInputStream(encoding, httpInput, mainFilePath); + var bumper = await CreateIngestInputStream(encoding, httpInput, bumperFilePath); + var promo = await CreateIngestInputStream(encoding, httpInput, promoFilePath); // In this example, we trim the main input file and create two separated streams as TimeBasedTrimmingInputStream var mainPart1 = await CreateTimeBasedTrimmingInputStream(encoding, main, 10.0, 90.0); @@ -294,14 +294,13 @@ private Task CreateS3Output(string bucketName, string accessKey, strin /// The input resource providing the input file /// The path to the input file. /// The algorithm how the stream in the input file will be selected. - private Task CreateIngestInputStream(Models.Encoding encoding, Input input, String inputPath, - StreamSelectionMode streamSelectionMode) + private Task CreateIngestInputStream(Models.Encoding encoding, Input input, String inputPath) { var ingestInputStream = new IngestInputStream() { InputId = input.Id, InputPath = inputPath, - SelectionMode = streamSelectionMode + SelectionMode = StreamSelectionMode.AUTO }; return _bitmovinApi.Encoding.Encodings.InputStreams.Ingest.CreateAsync(encoding.Id, ingestInputStream); } diff --git a/dotnet/Bitmovin.Api.Sdk.Examples/PerTitleEncoding.cs b/dotnet/Bitmovin.Api.Sdk.Examples/PerTitleEncoding.cs index 0dc4341..5cfce91 100644 --- a/dotnet/Bitmovin.Api.Sdk.Examples/PerTitleEncoding.cs +++ b/dotnet/Bitmovin.Api.Sdk.Examples/PerTitleEncoding.cs @@ -314,7 +314,8 @@ private Task CreateStream(Models.Encoding encoding, Input input, string var streamInput = new StreamInput() { InputId = input.Id, - InputPath = inputPath + InputPath = inputPath, + SelectionMode = StreamSelectionMode.AUTO }; var stream = new Stream() diff --git a/dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveEncoding.cs b/dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveEncoding.cs index e36d3d2..df95833 100644 --- a/dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveEncoding.cs +++ b/dotnet/Bitmovin.Api.Sdk.Examples/RtmpLiveEncoding.cs @@ -100,11 +100,11 @@ public async Task RunExample(string[] args) // Add an H.264 video stream to the encoding var h264VideoConfig = await CreateH264VideoConfiguration(); - var h264VideoStream = await CreateStream(encoding, input, inputFilePath, h264VideoConfig, 0); + var h264VideoStream = await CreateStream(encoding, input, inputFilePath, h264VideoConfig); // Add an AAC audio stream to the encoding var aacConfig = await CreateAacAudioConfiguration(); - var aacAudioStream = await CreateStream(encoding, input, inputFilePath, aacConfig, 1); + var aacAudioStream = await CreateStream(encoding, input, inputFilePath, aacConfig); await CreateFmp4Muxing(encoding, output, $"/video/${h264VideoConfig.Height}p", h264VideoStream); await CreateFmp4Muxing(encoding, output, $"/audio/${aacConfig.Bitrate! / 1000}kbps", aacAudioStream); @@ -369,15 +369,14 @@ private Task CreateS3Output(string bucketName, string accessKey, strin /// The input that should be used /// The path to the input file /// The codec configuration to be applied to the stream - /// The position of the input stream that is associated with the generated stream private Task CreateStream(Models.Encoding encoding, Input input, string inputPath, - CodecConfiguration configuration, int position) + CodecConfiguration configuration) { var streamInput = new StreamInput() { InputId = input.Id, InputPath = inputPath, - Position = position + SelectionMode = StreamSelectionMode.AUTO }; var stream = new Stream() diff --git a/java/src/main/java/ConcatenationMultipleInputs.java b/java/src/main/java/ConcatenationMultipleInputs.java index c533968..3235d95 100644 --- a/java/src/main/java/ConcatenationMultipleInputs.java +++ b/java/src/main/java/ConcatenationMultipleInputs.java @@ -106,9 +106,9 @@ public static void main(String[] args) throws Exception { configProvider.getS3OutputSecretKey() ); - IngestInputStream main = createIngestInputStream(encoding, input, mainFilePath, StreamSelectionMode.AUTO); - IngestInputStream bumper = createIngestInputStream(encoding, input, bumperFilePath, StreamSelectionMode.AUTO); - IngestInputStream promo = createIngestInputStream(encoding, input, promoFilePath, StreamSelectionMode.AUTO); + IngestInputStream main = createIngestInputStream(encoding, input, mainFilePath); + IngestInputStream bumper = createIngestInputStream(encoding, input, bumperFilePath); + IngestInputStream promo = createIngestInputStream(encoding, input, promoFilePath); TimeBasedTrimmingInputStream mainPart1 = createTimeBasedTrimmingInputStream(encoding, main, 10.0, 90.0); TimeBasedTrimmingInputStream mainPart2= createTimeBasedTrimmingInputStream(encoding, main, 109.0, 60.0); @@ -242,13 +242,12 @@ private static S3Output createS3Output(String bucketName, String accessKey, Stri * @param encoding The encoding to be started * @param input The input resource providing the input file * @param inputPath The path to the input file - * @param streamSelectionMode The algorithm how the stream in the input file will be selected */ - private static IngestInputStream createIngestInputStream(Encoding encoding, Input input, String inputPath, StreamSelectionMode streamSelectionMode) { + private static IngestInputStream createIngestInputStream(Encoding encoding, Input input, String inputPath) { IngestInputStream ingestInputStream = new IngestInputStream(); ingestInputStream.setInputId(input.getId()); ingestInputStream.setInputPath(inputPath); - ingestInputStream.setSelectionMode(streamSelectionMode); + ingestInputStream.setSelectionMode(StreamSelectionMode.AUTO); return bitmovinApi.encoding.encodings.inputStreams.ingest.create(encoding.getId(), ingestInputStream); } diff --git a/java/src/main/java/HdrConversions.java b/java/src/main/java/HdrConversions.java index 1ee9285..a655a72 100644 --- a/java/src/main/java/HdrConversions.java +++ b/java/src/main/java/HdrConversions.java @@ -134,13 +134,10 @@ public static void main(String[] args) throws Exception { videoInputStream = createDolbyVisionInputStream(encoding, httpsInput, videoInputPath, inputMetadataPath); } else { - videoInputStream = - createIngestInputStream( - encoding, httpsInput, videoInputPath, StreamSelectionMode.AUTO, 0); + videoInputStream = createIngestInputStream(encoding, httpsInput, videoInputPath); } - InputStream audioInputStream = - createIngestInputStream(encoding, httpsInput, audioInputPath, StreamSelectionMode.AUTO, 0); + InputStream audioInputStream = createIngestInputStream(encoding, httpsInput, audioInputPath); createH265AndAacEncoding(encoding, videoInputStream, audioInputStream, output); executeEncoding(encoding); @@ -423,7 +420,6 @@ private static HttpsInput createHttpsInput(String host) throws BitmovinException */ private static S3Output createS3Output(String bucketName, String accessKey, String secretKey) throws BitmovinException { - S3Output s3Output = new S3Output(); s3Output.setBucketName(bucketName); s3Output.setAccessKey(accessKey); @@ -447,15 +443,12 @@ private static S3Output createS3Output(String bucketName, String accessKey, Stri private static IngestInputStream createIngestInputStream( Encoding encoding, Input input, - String inputPath, - StreamSelectionMode streamSelectionMode, - int position) + String inputPath) throws BitmovinException { IngestInputStream ingestInputStream = new IngestInputStream(); ingestInputStream.setInputId(input.getId()); ingestInputStream.setInputPath(inputPath); - ingestInputStream.setSelectionMode(streamSelectionMode); - ingestInputStream.setPosition(position); + ingestInputStream.setSelectionMode(StreamSelectionMode.AUTO); return bitmovinApi.encoding.encodings.inputStreams.ingest.create( encoding.getId(), ingestInputStream); diff --git a/java/src/main/java/RtmpLiveEncoding.java b/java/src/main/java/RtmpLiveEncoding.java index 344b4c4..ee286be 100644 --- a/java/src/main/java/RtmpLiveEncoding.java +++ b/java/src/main/java/RtmpLiveEncoding.java @@ -90,13 +90,13 @@ public class RtmpLiveEncoding { /** This list defines the video renditions that will be generated */ private static List videoProfile = Arrays.asList( - new VideoConfig("480p", 800_000L, 480, "/video/480p", 0), - new VideoConfig("720p", 1_200_000L, 720, "/video/720p", 0), - new VideoConfig("1080p", 3_000_000L, 1080, "/video/1080p", 0)); + new VideoConfig("H.264 480p live", 800_000L, 480, "/video/480p"), + new VideoConfig("H.264 720p live", 1_200_000L, 720, "/video/720p"), + new VideoConfig("H.264 1080p live", 3_000_000L, 1080, "/video/1080p")); /** This list defines the audio renditions that will be generated */ private static List audioProfile = - Collections.singletonList(new AudioConfig("128kbit", 128_000L, "/audio/128kb", 1)); + Collections.singletonList(new AudioConfig("AAC 128 kbit/s", 128_000L, "/audio/128kb")); private static String streamKey = "bitmovin"; @@ -121,18 +121,16 @@ public static void main(String[] args) throws Exception { configProvider.getS3OutputSecretKey()); for (VideoConfig videoConfig : videoProfile) { - H264VideoConfiguration h264Configuration = - createH264VideoConfig(videoConfig.height, videoConfig.bitRate); - Stream stream = - createStream(encoding, input, h264Configuration, videoConfig.inputStreamPosition); + H264VideoConfiguration h264Config = + createH264VideoConfig(videoConfig.name, videoConfig.height, videoConfig.bitRate); + Stream stream = createStream(encoding, input, h264Config); createFmp4Muxing(encoding, stream, output, videoConfig.outputPath); } for (AudioConfig audioConfig : audioProfile) { - AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.bitrate); - Stream audioStream = - createStream(encoding, input, aacConfig, audioConfig.inputStreamPosition); + AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.name, audioConfig.bitrate); + Stream audioStream = createStream(encoding, input, aacConfig); createFmp4Muxing(encoding, audioStream, output, audioConfig.outputPath); } @@ -444,16 +442,14 @@ private static Encoding createEncoding(String name, String description) throws B * https://bitmovin.com/docs/encoding/api-reference/sections/encodings#/Encoding/PostEncodingEncodingsStreamsByEncodingId * * @param encoding The encoding where to add the stream to - * @param input The input where the input file is located * @param codecConfiguration The codec configuration to be applied to the stream */ private static Stream createStream( - Encoding encoding, Input input, CodecConfiguration codecConfiguration, int position) + Encoding encoding, Input input, CodecConfiguration codecConfiguration) throws BitmovinException { StreamInput streamInput = new StreamInput(); streamInput.setInputId(input.getId()); streamInput.setInputPath("live"); - streamInput.setPosition(position); streamInput.setSelectionMode(StreamSelectionMode.AUTO); Stream stream = new Stream(); @@ -471,13 +467,14 @@ private static Stream createStream( * href="https://bitmovin.com/docs/encoding/tutorials/how-to-optimize-your-h264-codec-configuration-for-different-use-cases">How * to optimize your H264 codec configuration for different use-cases for alternative presets. * + * @param name The name of the configuration resource being created * @param height The height of the output video * @param bitrate The target bitrate of the output video */ - private static H264VideoConfiguration createH264VideoConfig(int height, long bitrate) + private static H264VideoConfiguration createH264VideoConfig(String name, int height, long bitrate) throws BitmovinException { H264VideoConfiguration config = new H264VideoConfiguration(); - config.setName(String.format("H.264 %dp live", height)); + config.setName(name); config.setPresetConfiguration(PresetConfiguration.LIVE_STANDARD); config.setHeight(height); config.setWidth((int) Math.ceil(aspectRatio * height)); @@ -492,61 +489,52 @@ private static H264VideoConfiguration createH264VideoConfig(int height, long bit *

API endpoint: * https://bitmovin.com/docs/encoding/api-reference/sections/configurations#/Encoding/PostEncodingConfigurationsAudioAac * + * @param name The name of the configuration resource being created * @param bitrate The target bitrate for the encoded audio */ - private static AacAudioConfiguration createAacAudioConfig(long bitrate) throws BitmovinException { + private static AacAudioConfiguration createAacAudioConfig(String name, long bitrate) throws BitmovinException { AacAudioConfiguration config = new AacAudioConfiguration(); - config.setName(String.format("AAC %d kbit/s", bitrate / 1000)); + config.setName(name); config.setBitrate(bitrate); return bitmovinApi.encoding.configurations.audio.aac.create(config); } private static class VideoConfig { - private String name; private Long bitRate; private Integer height; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the video configuration * @param bitRate The target output bitrate of the video configuration * @param height The target output height of the video configuration * @param outputPath The output path for this video configuration - * @param inputStreamPosition The input stream position that is used for this video - * configuration */ private VideoConfig( - String name, Long bitRate, Integer height, String outputPath, int inputStreamPosition) { + String name, Long bitRate, Integer height, String outputPath) { this.name = name; this.bitRate = bitRate; this.height = height; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } private static class AudioConfig { - private String name; private Long bitrate; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the audio configuration * @param bitrate The target output bitrate of the audio configuration * @param outputPath The output path for this audio configuration - * @param inputStreamPosition The input stream position that is used for this audio - * configuration */ - public AudioConfig(String name, Long bitrate, String outputPath, int inputStreamPosition) { + public AudioConfig(String name, Long bitrate, String outputPath) { this.name = name; this.bitrate = bitrate; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } } diff --git a/java/src/main/java/tutorials/RedundantRtmpLiveEncoding.java b/java/src/main/java/tutorials/RedundantRtmpLiveEncoding.java index ad31ecf..f9f6788 100644 --- a/java/src/main/java/tutorials/RedundantRtmpLiveEncoding.java +++ b/java/src/main/java/tutorials/RedundantRtmpLiveEncoding.java @@ -93,13 +93,13 @@ public class RedundantRtmpLiveEncoding { /** This list defines the video renditions that will be generated */ private static List videoProfile = Arrays.asList( - new VideoConfig("480p", 800_000L, 480, "/video/480p", 0), - new VideoConfig("720p", 1_200_000L, 720, "/video/720p", 0), - new VideoConfig("1080p", 3_000_000L, 1080, "/video/1080p", 0)); + new VideoConfig("H.264 480p live", 800_000L, 480, "/video/480p"), + new VideoConfig("H.264 720p live", 1_200_000L, 720, "/video/720p"), + new VideoConfig("H.264 1080p live", 3_000_000L, 1080, "/video/1080p")); /** This list defines the audio renditions that will be generated */ private static List audioProfile = - Collections.singletonList(new AudioConfig("128kbit", 128_000L, "/audio/128kb", 1)); + Collections.singletonList(new AudioConfig("128kbit", 128_000L, "/audio/128kb")); public static void main(String[] args) throws Exception { configProvider = new ConfigProvider(args); @@ -130,18 +130,16 @@ public static void main(String[] args) throws Exception { configProvider.getS3OutputSecretKey()); for (VideoConfig videoConfig : videoProfile) { - H264VideoConfiguration h264Configuration = - createH264VideoConfig(videoConfig.height, videoConfig.bitRate); - Stream stream = - createStream(encoding, input, h264Configuration, videoConfig.inputStreamPosition); + H264VideoConfiguration h264Config = + createH264VideoConfig(videoConfig.name, videoConfig.height, videoConfig.bitRate); + Stream stream = createStream(encoding, input, h264Config); createFmp4Muxing(encoding, stream, output, videoConfig.outputPath); } for (AudioConfig audioConfig : audioProfile) { - AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.bitrate); - Stream audioStream = - createStream(encoding, input, aacConfig, audioConfig.inputStreamPosition); + AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.name, audioConfig.bitrate); + Stream audioStream = createStream(encoding, input, aacConfig); createFmp4Muxing(encoding, audioStream, output, audioConfig.outputPath); } @@ -513,12 +511,11 @@ private static Encoding createEncoding(String name, String description) throws B * @param codecConfiguration The codec configuration to be applied to the stream */ private static Stream createStream( - Encoding encoding, Input input, CodecConfiguration codecConfiguration, int position) + Encoding encoding, Input input, CodecConfiguration codecConfiguration) throws BitmovinException { StreamInput streamInput = new StreamInput(); streamInput.setInputId(input.getId()); streamInput.setInputPath("live"); - streamInput.setPosition(position); streamInput.setSelectionMode(StreamSelectionMode.AUTO); Stream stream = new Stream(); @@ -536,13 +533,14 @@ private static Stream createStream( * href="https://bitmovin.com/docs/encoding/tutorials/how-to-optimize-your-h264-codec-configuration-for-different-use-cases">How * to optimize your H264 codec configuration for different use-cases for alternative presets. * + * @param name The name of the configuration resource being created * @param height The height of the output video * @param bitrate The target bitrate of the output video */ - private static H264VideoConfiguration createH264VideoConfig(int height, long bitrate) + private static H264VideoConfiguration createH264VideoConfig(String name, int height, long bitrate) throws BitmovinException { H264VideoConfiguration config = new H264VideoConfiguration(); - config.setName(String.format("H.264 %dp live", height)); + config.setName(name); config.setPresetConfiguration(PresetConfiguration.LIVE_STANDARD); config.setBitrate(bitrate); config.setHeight(height); @@ -557,61 +555,51 @@ private static H264VideoConfiguration createH264VideoConfig(int height, long bit *

API endpoint: * https://bitmovin.com/docs/encoding/api-reference/sections/configurations#/Encoding/PostEncodingConfigurationsAudioAac * + * @param name The name of the configuration resource being created * @param bitrate The target bitrate for the encoded audio */ - private static AacAudioConfiguration createAacAudioConfig(long bitrate) throws BitmovinException { + private static AacAudioConfiguration createAacAudioConfig(String name, long bitrate) throws BitmovinException { AacAudioConfiguration config = new AacAudioConfiguration(); - config.setName(String.format("AAC %d kbit/s", bitrate / 1000)); + config.setName(name); config.setBitrate(bitrate); return bitmovinApi.encoding.configurations.audio.aac.create(config); } private static class VideoConfig { - private String name; private Long bitRate; private Integer height; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the video configuration * @param bitRate The target output bitrate of the video configuration * @param height The target output height of the video configuration - * @param outputPath The output path for this video configuration - * @param inputStreamPosition The input stream position that is used for this video - * configuration */ private VideoConfig( - String name, Long bitRate, Integer height, String outputPath, int inputStreamPosition) { + String name, Long bitRate, Integer height, String outputPath) { this.name = name; this.bitRate = bitRate; this.height = height; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } private static class AudioConfig { - private String name; private Long bitrate; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the audio configuration * @param bitrate The target output bitrate of the audio configuration * @param outputPath The output path for this audio configuration - * @param inputStreamPosition The input stream position that is used for this audio - * configuration */ - public AudioConfig(String name, Long bitrate, String outputPath, int inputStreamPosition) { + public AudioConfig(String name, Long bitrate, String outputPath) { this.name = name; this.bitrate = bitrate; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } } diff --git a/java/src/main/java/tutorials/SrtLiveEncoding.java b/java/src/main/java/tutorials/SrtLiveEncoding.java index 6f84c43..72b30a7 100644 --- a/java/src/main/java/tutorials/SrtLiveEncoding.java +++ b/java/src/main/java/tutorials/SrtLiveEncoding.java @@ -93,13 +93,13 @@ public class SrtLiveEncoding { /** This list defines the video renditions that will be generated */ private static List videoProfile = Arrays.asList( - new VideoConfig("480p", 800_000L, 480, "/video/480p", 0), - new VideoConfig("720p", 1_200_000L, 720, "/video/720p", 0), - new VideoConfig("1080p", 3_000_000L, 1080, "/video/1080p", 0)); + new VideoConfig("H.264 480p live", 800_000L, 480, "/video/480p"), + new VideoConfig("H.264 720p live", 1_200_000L, 720, "/video/720p"), + new VideoConfig("H.264 1080p live", 3_000_000L, 1080, "/video/1080p")); /** This list defines the audio renditions that will be generated */ private static List audioProfile = - Collections.singletonList(new AudioConfig("128kbit", 128_000L, "/audio/128kb", 1)); + Collections.singletonList(new AudioConfig("128kbit", 128_000L, "/audio/128kb")); public static void main(String[] args) throws Exception { configProvider = new ConfigProvider(args); @@ -124,18 +124,16 @@ public static void main(String[] args) throws Exception { configProvider.getS3OutputSecretKey()); for (VideoConfig videoConfig : videoProfile) { - H264VideoConfiguration h264Configuration = - createH264VideoConfig(videoConfig.height, videoConfig.bitRate); - Stream stream = - createStream(encoding, input, h264Configuration, videoConfig.inputStreamPosition); + H264VideoConfiguration h264Config = + createH264VideoConfig(videoConfig.name, videoConfig.height, videoConfig.bitRate); + Stream stream = createStream(encoding, input, h264Config); createFmp4Muxing(encoding, stream, output, videoConfig.outputPath); } for (AudioConfig audioConfig : audioProfile) { - AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.bitrate); - Stream audioStream = - createStream(encoding, input, aacConfig, audioConfig.inputStreamPosition); + AacAudioConfiguration aacConfig = createAacAudioConfig(audioConfig.name, audioConfig.bitrate); + Stream audioStream = createStream(encoding, input, aacConfig); createFmp4Muxing(encoding, audioStream, output, audioConfig.outputPath); } @@ -465,12 +463,11 @@ private static Encoding createEncoding(String name, String description) throws B * @param codecConfiguration The codec configuration to be applied to the stream */ private static Stream createStream( - Encoding encoding, Input input, CodecConfiguration codecConfiguration, int position) + Encoding encoding, Input input, CodecConfiguration codecConfiguration) throws BitmovinException { StreamInput streamInput = new StreamInput(); streamInput.setInputId(input.getId()); streamInput.setInputPath("live"); - streamInput.setPosition(position); streamInput.setSelectionMode(StreamSelectionMode.AUTO); Stream stream = new Stream(); @@ -488,13 +485,14 @@ private static Stream createStream( * href="https://bitmovin.com/docs/encoding/tutorials/how-to-optimize-your-h264-codec-configuration-for-different-use-cases">How * to optimize your H264 codec configuration for different use-cases for alternative presets. * + * @param name The name of the configuration resource being created * @param height The height of the output video * @param bitrate The target bitrate of the output video */ - private static H264VideoConfiguration createH264VideoConfig(int height, long bitrate) + private static H264VideoConfiguration createH264VideoConfig(String name, int height, long bitrate) throws BitmovinException { H264VideoConfiguration config = new H264VideoConfiguration(); - config.setName(String.format("H.264 %dp live", height)); + config.setName(name); config.setPresetConfiguration(PresetConfiguration.LIVE_STANDARD); config.setHeight(height); config.setWidth((int) Math.ceil(aspectRatio * height)); @@ -509,61 +507,52 @@ private static H264VideoConfiguration createH264VideoConfig(int height, long bit *

API endpoint: * https://bitmovin.com/docs/encoding/api-reference/sections/configurations#/Encoding/PostEncodingConfigurationsAudioAac * + * @param name The name of the configuration resource being created * @param bitrate The target bitrate for the encoded audio */ - private static AacAudioConfiguration createAacAudioConfig(long bitrate) throws BitmovinException { + private static AacAudioConfiguration createAacAudioConfig(String name, long bitrate) throws BitmovinException { AacAudioConfiguration config = new AacAudioConfiguration(); - config.setName(String.format("AAC %d kbit/s", bitrate / 1000)); + config.setName(name); config.setBitrate(bitrate); return bitmovinApi.encoding.configurations.audio.aac.create(config); } private static class VideoConfig { - private String name; private Long bitRate; private Integer height; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the video configuration * @param bitRate The target output bitrate of the video configuration * @param height The target output height of the video configuration * @param outputPath The output path for this video configuration - * @param inputStreamPosition The input stream position that is used for this video - * configuration */ private VideoConfig( - String name, Long bitRate, Integer height, String outputPath, int inputStreamPosition) { + String name, Long bitRate, Integer height, String outputPath) { this.name = name; this.bitRate = bitRate; this.height = height; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } private static class AudioConfig { - private String name; private Long bitrate; private String outputPath; - private int inputStreamPosition; /** * @param name The name of the audio configuration * @param bitrate The target output bitrate of the audio configuration * @param outputPath The output path for this audio configuration - * @param inputStreamPosition The input stream position that is used for this audio - * configuration */ - public AudioConfig(String name, Long bitrate, String outputPath, int inputStreamPosition) { + public AudioConfig(String name, Long bitrate, String outputPath) { this.name = name; this.bitrate = bitrate; this.outputPath = outputPath; - this.inputStreamPosition = inputStreamPosition; } } } diff --git a/javascript/src/CencDrmContentProtection.ts b/javascript/src/CencDrmContentProtection.ts index 110a7ef..d69e788 100644 --- a/javascript/src/CencDrmContentProtection.ts +++ b/javascript/src/CencDrmContentProtection.ts @@ -34,6 +34,7 @@ import BitmovinApi, { Status, Stream, StreamInput, + StreamSelectionMode, Task } from '@bitmovin/api-sdk'; @@ -163,7 +164,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO }); const stream = new Stream({ diff --git a/javascript/src/ConcatenationMultipleInputs.ts b/javascript/src/ConcatenationMultipleInputs.ts index dd83687..139dc64 100644 --- a/javascript/src/ConcatenationMultipleInputs.ts +++ b/javascript/src/ConcatenationMultipleInputs.ts @@ -92,9 +92,9 @@ async function main() { const bumperFilePath = configProvider.getHttpInputBumperFilePath(); const promoFilePath = configProvider.getHttpInputPromoFilePath(); - const main = await createIngestInputStream(encoding, input, mainFilePath, StreamSelectionMode.AUTO); - const bumper = await createIngestInputStream(encoding, input, bumperFilePath, StreamSelectionMode.AUTO); - const promo = await createIngestInputStream(encoding, input, promoFilePath, StreamSelectionMode.AUTO); + const main = await createIngestInputStream(encoding, input, mainFilePath); + const bumper = await createIngestInputStream(encoding, input, bumperFilePath); + const promo = await createIngestInputStream(encoding, input, promoFilePath); const mainPart1 = await createTimeBasedTrimmingInputStream(encoding, main, 10.0, 90.0); const mainPart2 = await createTimeBasedTrimmingInputStream(encoding, main, 109.0, 60.0); @@ -176,18 +176,16 @@ function createEncoding(name: string, description: string): Promise { * @param encoding The encoding to be started * @param input The input resource providing the input file * @param inputPath The path to the input file - * @param streamSelectionMode The algorithm how the stream in the input file will be selected */ function createIngestInputStream( encoding: Encoding, input: Input, - inputPath: string, - streamSelectionMode: StreamSelectionMode + inputPath: string ): Promise { const ingestInputStream = new IngestInputStream({ inputId: input.id, inputPath: inputPath, - selectionMode: streamSelectionMode, + selectionMode: StreamSelectionMode.AUTO, }); return bitmovinApi.encoding.encodings.inputStreams.ingest.create(encoding.id!, ingestInputStream); diff --git a/javascript/src/DefaultManifest.ts b/javascript/src/DefaultManifest.ts index bdf7915..c670132 100644 --- a/javascript/src/DefaultManifest.ts +++ b/javascript/src/DefaultManifest.ts @@ -30,6 +30,7 @@ import BitmovinApi, { Status, Stream, StreamInput, + StreamSelectionMode, Task } from '@bitmovin/api-sdk'; @@ -159,7 +160,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO }); const stream = new Stream({ diff --git a/javascript/src/EncodingWithCdnOutput.ts b/javascript/src/EncodingWithCdnOutput.ts index 3f45914..cb77a16 100644 --- a/javascript/src/EncodingWithCdnOutput.ts +++ b/javascript/src/EncodingWithCdnOutput.ts @@ -27,6 +27,7 @@ import BitmovinApi, { Status, Stream, StreamInput, + StreamSelectionMode, Task, } from '@bitmovin/api-sdk'; @@ -147,6 +148,7 @@ function createStream( const streamInput = new StreamInput({ inputId: input.id, inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/Filters.ts b/javascript/src/Filters.ts index ea5f334..e474cc7 100644 --- a/javascript/src/Filters.ts +++ b/javascript/src/Filters.ts @@ -24,6 +24,7 @@ import BitmovinApi, { StreamFilter, StreamFilterList, StreamInput, + StreamSelectionMode, Task, TextFilter, WatermarkFilter @@ -211,7 +212,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/FixedBitrateLadder.ts b/javascript/src/FixedBitrateLadder.ts index 61c424c..f74cf98 100644 --- a/javascript/src/FixedBitrateLadder.ts +++ b/javascript/src/FixedBitrateLadder.ts @@ -20,6 +20,7 @@ import BitmovinApi, { Status, Stream, StreamInput, + StreamSelectionMode, Task } from '@bitmovin/api-sdk'; @@ -136,7 +137,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/MultiCodecEncoding.ts b/javascript/src/MultiCodecEncoding.ts index 978802d..cd69a93 100644 --- a/javascript/src/MultiCodecEncoding.ts +++ b/javascript/src/MultiCodecEncoding.ts @@ -36,6 +36,7 @@ import BitmovinApi, { Stream, StreamInfo, StreamInput, + StreamSelectionMode, Task, TsMuxing, VideoAdaptationSet, @@ -819,7 +820,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/PerTitleEncoding.ts b/javascript/src/PerTitleEncoding.ts index dcecc9d..9b9467d 100644 --- a/javascript/src/PerTitleEncoding.ts +++ b/javascript/src/PerTitleEncoding.ts @@ -33,6 +33,7 @@ import BitmovinApi, { Stream, StreamInput, StreamMode, + StreamSelectionMode, Task } from '@bitmovin/api-sdk'; import {join} from 'path'; @@ -258,7 +259,8 @@ function createStream( ) { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/RtmpLiveEncoding.ts b/javascript/src/RtmpLiveEncoding.ts index 3f388e8..a935a58 100644 --- a/javascript/src/RtmpLiveEncoding.ts +++ b/javascript/src/RtmpLiveEncoding.ts @@ -28,6 +28,7 @@ import BitmovinApi, { Status, Stream, StreamInput, + StreamSelectionMode, Task } from '@bitmovin/api-sdk'; @@ -94,8 +95,8 @@ async function main() { const h264VideoConfiguration = await createH264VideoConfig(1080, 3000000); const aacAudioConfiguration = await createAacAudioConfig(128000); - const videoStream = await createStream(encoding, input, 'live', h264VideoConfiguration, 0); - const audioStream = await createStream(encoding, input, 'live', aacAudioConfiguration, 1); + const videoStream = await createStream(encoding, input, 'live', h264VideoConfiguration); + const audioStream = await createStream(encoding, input, 'live', aacAudioConfiguration); await createFmp4Muxing(encoding, output, `/video/${h264VideoConfiguration.height}p`, videoStream); await createFmp4Muxing(encoding, output, `/audio/${aacAudioConfiguration.bitrate! / 1000}kbps`, audioStream); @@ -350,19 +351,17 @@ function createAacAudioConfig(bitrate): Promise { * @param input The input resource providing the input file * @param inputPath The path to the input file * @param codecConfiguration The codec configuration to be applied to the stream - * @param position The position of the input stream that is associated with the generated stream */ function createStream( encoding: Encoding, input: Input, inputPath: string, - codecConfiguration: CodecConfiguration, - position: number + codecConfiguration: CodecConfiguration ): Promise { const streamInput = new StreamInput({ inputId: input.id, inputPath: inputPath, - position + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/javascript/src/ServerSideAdInsertion.ts b/javascript/src/ServerSideAdInsertion.ts index 1f63153..735d7aa 100644 --- a/javascript/src/ServerSideAdInsertion.ts +++ b/javascript/src/ServerSideAdInsertion.ts @@ -30,6 +30,7 @@ import BitmovinApi, { Stream, StreamInfo, StreamInput, + StreamSelectionMode, Task, VideoConfiguration } from '@bitmovin/api-sdk'; @@ -177,7 +178,8 @@ function createStream( ): Promise { const streamInput = new StreamInput({ inputId: input.id, - inputPath: inputPath + inputPath: inputPath, + selectionMode: StreamSelectionMode.AUTO, }); const stream = new Stream({ diff --git a/php/src/BatchEncoding.php b/php/src/BatchEncoding.php index a6ab558..3a5c59e 100644 --- a/php/src/BatchEncoding.php +++ b/php/src/BatchEncoding.php @@ -30,6 +30,7 @@ use BitmovinApiSdk\Models\Status; use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; use BitmovinApiSdk\Models\VideoConfiguration; @@ -353,6 +354,7 @@ function createStream(Encoding $encoding, Input $input, string $inputPath, Codec $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/CencDrmContentProtection.php b/php/src/CencDrmContentProtection.php index 814f084..fae4459 100644 --- a/php/src/CencDrmContentProtection.php +++ b/php/src/CencDrmContentProtection.php @@ -40,6 +40,7 @@ use BitmovinApiSdk\Models\Status; use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; /** @@ -304,6 +305,7 @@ function createStream(Encoding $encoding, Input $input, string $inputPath, Codec $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/DefaultManifest.php b/php/src/DefaultManifest.php index bb5a644..f7f8ede 100644 --- a/php/src/DefaultManifest.php +++ b/php/src/DefaultManifest.php @@ -36,6 +36,7 @@ use BitmovinApiSdk\Models\Status; use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; /** @@ -272,6 +273,7 @@ function createStream(Encoding $encoding, Input $input, string $inputPath, Codec $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/Filters.php b/php/src/Filters.php index 17bccc0..2f17b53 100644 --- a/php/src/Filters.php +++ b/php/src/Filters.php @@ -30,6 +30,7 @@ use BitmovinApiSdk\Models\StreamFilter; use BitmovinApiSdk\Models\StreamFilterList; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; use BitmovinApiSdk\Models\TextFilter; use BitmovinApiSdk\Models\WatermarkFilter; @@ -342,6 +343,7 @@ function createStream(Encoding $encoding, Input $input, string $inputPath, Codec $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/FixedBitrateLadder.php b/php/src/FixedBitrateLadder.php index 00684b6..a415da4 100644 --- a/php/src/FixedBitrateLadder.php +++ b/php/src/FixedBitrateLadder.php @@ -26,6 +26,7 @@ use BitmovinApiSdk\Models\Status; use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; /** @@ -244,6 +245,7 @@ function createStream(Encoding $encoding, Input $input, string $inputPath, Codec $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/MultiCodecEncoding.php b/php/src/MultiCodecEncoding.php index 57b5f5c..d4d5264 100644 --- a/php/src/MultiCodecEncoding.php +++ b/php/src/MultiCodecEncoding.php @@ -42,6 +42,7 @@ use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInfo; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; use BitmovinApiSdk\Models\TsMuxing; use BitmovinApiSdk\Models\VideoAdaptationSet; @@ -1154,6 +1155,7 @@ function createStream( $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/php/src/RtmpLiveEncoding.php b/php/src/RtmpLiveEncoding.php index a13b37e..2181dce 100644 --- a/php/src/RtmpLiveEncoding.php +++ b/php/src/RtmpLiveEncoding.php @@ -34,6 +34,7 @@ use BitmovinApiSdk\Models\Status; use BitmovinApiSdk\Models\Stream; use BitmovinApiSdk\Models\StreamInput; +use BitmovinApiSdk\Models\StreamSelectionMode; use BitmovinApiSdk\Models\Task; /** @@ -101,8 +102,8 @@ $h264Config = createH264Config(); $aacConfig = createAacConfig(); - $h264Stream = createStream($encoding, $input, 'live', $h264Config, 0); - $aacStream = createStream($encoding, $input, 'live', $aacConfig, 1); + $h264Stream = createStream($encoding, $input, 'live', $h264Config); + $aacStream = createStream($encoding, $input, 'live', $aacConfig); createFmp4Muxing($encoding, $output, 'video/' . $h264Config->height . 'p', $h264Stream); createFmp4Muxing($encoding, $output, 'audio/' . ($aacConfig->bitrate / 1000) . "kbps", $aacStream); @@ -369,14 +370,14 @@ function createAacConfig() * @return Stream * @throws BitmovinApiException */ -function createStream(Encoding $encoding, Input $input, string $inputPath, CodecConfiguration $codecConfiguration, int $position) +function createStream(Encoding $encoding, Input $input, string $inputPath, CodecConfiguration $codecConfiguration) { global $bitmovinApi; $streamInput = new StreamInput(); $streamInput->inputId($input->id); $streamInput->inputPath($inputPath); - $streamInput->position($position); + $streamInput->selectionMode(StreamSelectionMode::AUTO()); $stream = new Stream(); $stream->inputStreams([$streamInput]); diff --git a/python/src/cenc_drm_content_protection.py b/python/src/cenc_drm_content_protection.py index dc20c49..3c9f915 100644 --- a/python/src/cenc_drm_content_protection.py +++ b/python/src/cenc_drm_content_protection.py @@ -6,7 +6,7 @@ DashManifestDefault, DashManifestDefaultVersion, Encoding, EncodingOutput, Fmp4Muxing, \ H264VideoConfiguration, HlsManifest, HlsManifestDefault, HlsManifestDefaultVersion, HttpInput, \ Input, ManifestGenerator, ManifestResource, MessageType, Muxing, MuxingStream, Output, \ - PresetConfiguration, S3Output, StartEncodingRequest, Status, Stream, StreamInput, Task + PresetConfiguration, S3Output, StartEncodingRequest, Status, Stream, StreamInput, StreamSelectionMode, Task from common import ConfigProvider @@ -300,7 +300,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration): stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/concatenation_multiple_inputs.py b/python/src/concatenation_multiple_inputs.py index a2a4da4..b80c507 100644 --- a/python/src/concatenation_multiple_inputs.py +++ b/python/src/concatenation_multiple_inputs.py @@ -76,20 +76,17 @@ def main(): main = _create_ingest_input_stream( encoding=encoding, input=https_input, - input_path=main_file_path, - stream_selection_mode=StreamSelectionMode.AUTO + input_path=main_file_path ) bumper = _create_ingest_input_stream( encoding=encoding, input=https_input, - input_path=bumper_file_path, - stream_selection_mode=StreamSelectionMode.AUTO + input_path=bumper_file_path ) promo = _create_ingest_input_stream( encoding=encoding, input=https_input, - input_path=promo_file_path, - stream_selection_mode=StreamSelectionMode.AUTO + input_path=promo_file_path ) # In this example, we trim the main input file and create two separated streams as TimeBasedTrimmingInputStream @@ -292,8 +289,8 @@ def _create_s3_output(bucket_name, access_key, secret_key): return bitmovin_api.encoding.outputs.s3.create(s3_output=s3_output) -def _create_ingest_input_stream(encoding, input, input_path, stream_selection_mode): - # type: (Encoding, Input, str, StreamSelectionMode) -> IngestInputStream +def _create_ingest_input_stream(encoding, input, input_path): + # type: (Encoding, Input, str) -> IngestInputStream """ Creates an IngestInputStream and adds it to an encoding. The IngestInputStream is used to define where a file to read a stream from is located. @@ -304,13 +301,12 @@ def _create_ingest_input_stream(encoding, input, input_path, stream_selection_mo :param encoding: The encoding to be started :param input: The input resource providing the input file :param input_path: The path to the input file - :param stream_selection_mode: The algorithm how the stream in the input file will be selected """ ingest_input_stream = IngestInputStream( input_id=input.id, input_path=input_path, - selection_mode=stream_selection_mode + selection_mode=StreamSelectionMode.AUTO ) return bitmovin_api.encoding.encodings.input_streams.ingest.create( diff --git a/python/src/default_manifest.py b/python/src/default_manifest.py index 4ac3241..957507b 100644 --- a/python/src/default_manifest.py +++ b/python/src/default_manifest.py @@ -5,7 +5,7 @@ DashManifestDefaultVersion, Encoding, EncodingOutput, Fmp4Muxing, H264VideoConfiguration, \ HlsManifest, HlsManifestDefault, HlsManifestDefaultVersion, HttpInput, Input, ManifestGenerator, \ ManifestResource, MessageType, MuxingStream, Output, PresetConfiguration, S3Output, \ - StartEncodingRequest, Status, Stream, StreamInput, Task + StartEncodingRequest, Status, Stream, StreamInput, StreamSelectionMode, Task from os import path @@ -298,7 +298,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration): stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/encoding_with_cdn_output.py b/python/src/encoding_with_cdn_output.py index afe7f78..1c8b565 100644 --- a/python/src/encoding_with_cdn_output.py +++ b/python/src/encoding_with_cdn_output.py @@ -160,11 +160,14 @@ def _create_fmp4_muxing(encoding: Encoding, output: Output, output_path: str, st @param output_path The output path where the fragmented segments will be written to @param stream The stream to be muxed """ - muxing_stream = MuxingStream(stream_id=stream.id) + muxing_stream = MuxingStream( + stream_id=stream.id + ) muxing = Fmp4Muxing( outputs=[_build_encoding_output(output, output_path)], streams=[muxing_stream], - segment_length=4.0) + segment_length=4.0 + ) return bitmovin_api.encoding.encodings.muxings.fmp4.create(encoding.id, muxing) @@ -183,11 +186,16 @@ def _create_stream(encoding: Encoding, input: Input, input_path: str, @param input_path The path to the input file @param codec_configuration The codec configuration to be applied to the stream """ - stream_input = StreamInput(input_id=input.id, - input_path=input_path, - selection_mode=StreamSelectionMode.AUTO) + stream_input = StreamInput( + input_id=input.id, + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO + ) - stream = Stream(input_streams=[stream_input], codec_config_id=codec_configuration.id) + stream = Stream( + input_streams=[stream_input], + codec_config_id=codec_configuration.id + ) return bitmovin_api.encoding.encodings.streams.create(encoding.id, stream) diff --git a/python/src/filters.py b/python/src/filters.py index 6fe3db8..36f2800 100644 --- a/python/src/filters.py +++ b/python/src/filters.py @@ -2,7 +2,8 @@ from bitmovin_api_sdk import AacAudioConfiguration, AclEntry, AclPermission, BitmovinApi, BitmovinApiLogger, \ DeinterlaceFilter, Encoding, EncodingOutput, H264VideoConfiguration, HttpInput, MessageType, Mp4Muxing, \ - MuxingStream, PresetConfiguration, S3Output, Status, Stream, StreamInput, StreamFilter, TextFilter, WatermarkFilter + MuxingStream, PresetConfiguration, S3Output, Status, Stream, StreamInput, StreamSelectionMode StreamFilter, \ + TextFilter, WatermarkFilter from common.config_provider import ConfigProvider from os import path @@ -348,7 +349,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration): stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/fixed_bitrate_ladder.py b/python/src/fixed_bitrate_ladder.py index 8b2efab..0d0b426 100644 --- a/python/src/fixed_bitrate_ladder.py +++ b/python/src/fixed_bitrate_ladder.py @@ -2,7 +2,7 @@ from bitmovin_api_sdk import AacAudioConfiguration, AclEntry, AclPermission, BitmovinApi, BitmovinApiLogger, Encoding, \ EncodingOutput, H264VideoConfiguration, HttpInput, MessageType, Mp4Muxing, MuxingStream, PresetConfiguration, \ - S3Output, Status, Stream, StreamInput + S3Output, Status, Stream, StreamInput, StreamSelectionMode from os import path @@ -258,7 +258,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration): stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/hdr_conversions.py b/python/src/hdr_conversions.py index 9d8ccf1..2d84899 100644 --- a/python/src/hdr_conversions.py +++ b/python/src/hdr_conversions.py @@ -177,17 +177,13 @@ def main(): video_input_stream = _create_ingest_input_stream( encoding=encoding, input=https_input, - input_path=video_input_path, - stream_selection_mode=StreamSelectionMode.AUTO, - position=0 + input_path=video_input_path ) audio_input_stream = _create_ingest_input_stream( encoding=encoding, input=https_input, - input_path=audio_input_path, - stream_selection_mode=StreamSelectionMode.AUTO, - position=0 + input_path=audio_input_path ) _create_h265_and_aac_encoding( @@ -309,8 +305,8 @@ def _create_dolby_vision_input_stream(encoding, input, dolby_vision_input_path, dolby_vision_input_stream=dolby_vision_input_stream) -def _create_ingest_input_stream(encoding, input, input_path, stream_selection_mode, position): - # type: (Encoding, Input, str, StreamSelectionMode, int) -> IngestInputStream +def _create_ingest_input_stream(encoding, input, input_path): + # type: (Encoding, Input, str) -> IngestInputStream """ Creates an IngestInputStream and adds it to an encoding.

The IngestInputStream is used to define where a file to read a stream from is located. @@ -326,8 +322,7 @@ def _create_ingest_input_stream(encoding, input, input_path, stream_selection_mo ingest_input_stream = IngestInputStream( input_id=input.id, input_path=input_path, - selection_mode=stream_selection_mode, - position=position + selection_mode=StreamSelectionMode.AUTO ) return bitmovin_api.encoding.encodings.input_streams.ingest.create( @@ -815,4 +810,4 @@ def _log_task_errors(task): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/python/src/multi_codec_encoding.py b/python/src/multi_codec_encoding.py index e87b92a..396c21a 100644 --- a/python/src/multi_codec_encoding.py +++ b/python/src/multi_codec_encoding.py @@ -9,8 +9,8 @@ DashCmafRepresentation, DashFmp4Representation, DashManifest, DashProfile, DashRepresentationType, \ DolbyDigitalAudioConfiguration, DolbyDigitalChannelLayout, Encoding, EncodingOutput, Fmp4Muxing, \ H264VideoConfiguration, H265VideoConfiguration, HlsManifest, HttpInput, Input, MessageType, Muxing, MuxingStream, \ - Output, Period, PresetConfiguration, S3Output, Status, Stream, StreamInfo, StreamInput, Task, TsMuxing, \ - VideoAdaptationSet, VorbisAudioConfiguration, Vp9VideoConfiguration, WebmMuxing + Output, Period, PresetConfiguration, S3Output, Status, Stream, StreamInfo, StreamInput, StreamSelectionMode Task, \ + TsMuxing, VideoAdaptationSet, VorbisAudioConfiguration, Vp9VideoConfiguration, WebmMuxing from common.config_provider import ConfigProvider @@ -1003,7 +1003,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration): stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/per_title_encoding.py b/python/src/per_title_encoding.py index 141039c..0f45e53 100644 --- a/python/src/per_title_encoding.py +++ b/python/src/per_title_encoding.py @@ -6,8 +6,8 @@ DashManifestDefaultVersion, Encoding, EncodingOutput, Fmp4Muxing, H264PerTitleConfiguration, \ H264VideoConfiguration, HlsManifest, HlsManifestDefault, HlsManifestDefaultVersion, HttpInput, \ Input, ManifestGenerator, ManifestResource, MessageType, MuxingStream, Output, PerTitle, \ - PresetConfiguration, S3Output, StartEncodingRequest, Status, Stream, StreamInput, StreamMode, \ - Task + PresetConfiguration, S3Output, StartEncodingRequest, Status, Stream, StreamInput, StreamSelectionMode, \ + StreamMode, Task from common.config_provider import ConfigProvider @@ -298,7 +298,8 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration, st stream_input = StreamInput( input_id=encoding_input.id, - input_path=input_path + input_path=input_path, + selection_mode=StreamSelectionMode.AUTO ) stream = Stream( diff --git a/python/src/rtmp_live_encoding.py b/python/src/rtmp_live_encoding.py index ff45cbe..bd17e7c 100644 --- a/python/src/rtmp_live_encoding.py +++ b/python/src/rtmp_live_encoding.py @@ -3,7 +3,8 @@ from bitmovin_api_sdk import AacAudioConfiguration, AclEntry, AclPermission, BitmovinApi, BitmovinApiLogger, \ BitmovinError, DashManifestDefault, DashManifestDefaultVersion, Encoding, EncodingOutput, Fmp4Muxing, \ H264VideoConfiguration, HlsManifestDefault, HlsManifestDefaultVersion, LiveDashManifest, LiveHlsManifest, \ - MessageType, MuxingStream, PresetConfiguration, S3Output, StartLiveEncodingRequest, Stream, StreamInput, Status + MessageType, MuxingStream, PresetConfiguration, S3Output, StartLiveEncodingRequest, Stream, StreamInput, \ + StreamSelectionMode, Status from common import ConfigProvider from os import path @@ -71,16 +72,14 @@ def main(): encoding=encoding, encoding_input=rtmp_input, input_path="live", - codec_configuration=h264_video_configuration, - position=0 + codec_configuration=h264_video_configuration ) aac_audio_stream = _create_stream( encoding=encoding, encoding_input=rtmp_input, input_path="live", - codec_configuration=aac_audio_configuration, - position=1 + codec_configuration=aac_audio_configuration ) _create_fmp4_muxing(encoding=encoding, @@ -311,8 +310,8 @@ def _create_h264_video_configuration(height, bitrate): return bitmovin_api.encoding.configurations.video.h264.create(h264_video_configuration=config) -def _create_stream(encoding, encoding_input, input_path, codec_configuration, position): - # type: (Encoding, Input, str, CodecConfiguration, int) -> Stream +def _create_stream(encoding, encoding_input, input_path, codec_configuration): + # type: (Encoding, Input, str, CodecConfiguration) -> Stream """ Adds a video or audio stream to an encoding @@ -328,7 +327,7 @@ def _create_stream(encoding, encoding_input, input_path, codec_configuration, po stream_input = StreamInput( input_id=encoding_input.id, input_path=input_path, - position=position + selection_mode=StreamSelectionMode.AUTO ) stream = Stream(