How to upload videos using SDK

Product

Streams

Question

Hi, I’m following the C# SDK examples but, I didn’t find an example of how to use the SDK to upload a video in order to create a stream.

and also, this link does not work.
https://developer.bitmovin.com/streams/reference/postencodinginputsdirectfileupload

If someone knows how to do it, I’ll appreciate to have a code example.
Regards!!!

Hi,
The best way would be to store the video on one of the following storages :

  • AWS S3 bucket
  • Google GCS bucket
  • HTTP(S) server

Then you should be able to use one of the code samples from our repository as a basis to build your workflow.

You can also use our direct upload input, meaning that you can push the input file yourself directly into our system, but it comes with certain limitations :

  • The input file size is 2GB max
  • You cannot reuse the input
  • It is typically less performant than cloud storages

Example in Java (I’m sorry, but I don’t master C# as much). The logic should be the exact same though.

    Encoding encoding = new Encoding();
    encoding.setCloudRegion(CloudRegion.AWS_EU_WEST_1);
    encoding.setEncoderVersion("LATEST");
    encoding = bitmovinApi.encoding.encodings.create(encoding);
    
    DirectFileUploadInput directFileUploadInput = new DirectFileUploadInput();
    directFileUploadInput = bitmovinApi.encoding.inputs.directFileUpload.create(directFileUploadInput);

// you will need to use a HTTP library to "PUT" your file into `directFileUploadInput.uploadUrl`
    
    IngestInputStream ingestInputStream = new IngestInputStream();
    ingestInputStream.setInputId(directFileUploadInput.getId());
    ingestInputStream.setSelectionMode(StreamSelectionMode.AUTO);
    ingestInputStream = bitmovinApi.encoding.encodings.inputStreams.ingest.create(encoding.getId(), ingestInputStream);
    
    H264VideoConfiguration h264VideoConfiguration = new H264VideoConfiguration();
    h264VideoConfiguration.setBAdaptiveStrategy(BAdapt.FULL);
    h264VideoConfiguration.setBPyramid(H264BPyramid.NORMAL);
    h264VideoConfiguration.setBframes(3);
    h264VideoConfiguration.setCabac(true);
    h264VideoConfiguration.setMotionEstimationMethod(H264MotionEstimationMethod.UMH);
    h264VideoConfiguration.setMvPredictionMode(MvPredictionMode.AUTO);
    h264VideoConfiguration.setMvSearchRangeMax(16);
    h264VideoConfiguration.setNalHrd(H264NalHrd.NONE);
    h264VideoConfiguration.setPartitions(List.of(H264Partition.ALL));
    h264VideoConfiguration.setProfile(ProfileH264.MAIN);
    h264VideoConfiguration.setRcLookahead(50);
    h264VideoConfiguration.setRefFrames(5);
    h264VideoConfiguration.setSubMe(H264SubMe.RD_REF_IP);
    h264VideoConfiguration.setTrellis(H264Trellis.ENABLED_FINAL_MB);
    h264VideoConfiguration = bitmovinApi.encoding.configurations.video.h264.create(h264VideoConfiguration);
    
    Stream stream = new Stream();
    stream.setCodecConfigId(h264VideoConfiguration.getId());
    stream.setCreateQualityMetaData(false);
    StreamInput stream_streamInput = new StreamInput();
    stream_streamInput.setInputStreamId(ingestInputStream.getId());
    stream.setInputStreams(List.of(stream_streamInput));
    stream.setMode(StreamMode.PER_TITLE_TEMPLATE);
    stream = bitmovinApi.encoding.encodings.streams.create(encoding.getId(), stream);
    
    S3Output s3Output = new S3Output();
    s3Output.setAccessKey("<PLACEHOLDER>");
    s3Output.setBucketName("bitmovin-api-eu-west1-ci");
    s3Output.setSecretKey("<PLACEHOLDER>");
    s3Output = bitmovinApi.encoding.outputs.s3.create(s3Output);
    
    Mp4Muxing mp4Muxing = new Mp4Muxing();
    mp4Muxing.setFilename("{uuid}.mp4");
    mp4Muxing.setName("{uuid}.mp4");
    EncodingOutput mp4Muxing_encodingOutput = new EncodingOutput();
    AclEntry mp4Muxing_encodingOutput_aclEntry = new AclEntry();
    mp4Muxing_encodingOutput_aclEntry.setPermission(AclPermission.PUBLIC_READ);
    mp4Muxing_encodingOutput.setAcl(List.of(mp4Muxing_encodingOutput_aclEntry));
    mp4Muxing_encodingOutput.setOutputId(s3Output.getId());
    mp4Muxing_encodingOutput.setOutputPath("output/encoding_test/testStartPerTitleEncodingWithDirectFileUploadInput-Thu_Jun_06_20:51:07_MDT_2024/video/");
    mp4Muxing.setOutputs(List.of(mp4Muxing_encodingOutput));
    mp4Muxing.setStreamConditionsMode(StreamConditionsMode.DROP_MUXING);
    MuxingStream mp4Muxing_muxingStream = new MuxingStream();
    mp4Muxing_muxingStream.setStreamId(stream.getId());
    mp4Muxing.setStreams(List.of(mp4Muxing_muxingStream));
    mp4Muxing = bitmovinApi.encoding.encodings.muxings.mp4.create(encoding.getId(), mp4Muxing);

I hope this helps. Please let me know in case you have questions

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.