简体   繁体   中英

How to upload videos to azure media services from smartphones

How to upload videos to azure media services from smartphones using c#? Is there any third party encoder present for mobile like wirecast present for laptop/desktop? Can we achieve this using rest api?

Due to low bandwidth on mobile devices it's not preferable to upload the videos from the mobile. Also I am not sure if there is any third party application to achieve the same but it can be done. The following code works fine for the windows Phone an Xamirin App Development

    // Part 1 - Connect to Media Services
  //          Setup upload progress event
  //          Upload a video to encode
  CloudMediaContext mediaContext =
    new CloudMediaContext("[ ACCOUNT NAME ]","[ ACCOUNT KEY ]");
  mediaContext.Assets.OnUploadProgress += Assets_OnUploadProgress;
  var asset = mediaContext.Assets.Create(    
    @"C:\windows\Performance\WinSat\winsat.wmv");
  // Part 2 - Create a task, specify encoding details
  Console.Clear();
  IJob job = mediaContext.Jobs.CreateJob("Sample Job");
  var expressionEncoder = mediaContext.MediaProcessors.Where(
    mp => mp.Name == "Expression Encoder").Single();
  var task = job.Tasks.Add(
    mediaProcessor: expressionEncoder,
    configuration: "H.264 HD 720p VBR");
  task.Inputs.Add(asset);
  task.Outputs.Add("Sample Task Output Asset");
  // Part 3 - Submit the encoding job to begin processing
  while (job.State != JobState.Finished)
  {
    job = mediaContext.Jobs.Refresh(job.Id);
    Console.SetCursorPosition(0, 0);
    Console.WriteLine("Job Name: " + job.Name);
    Console.WriteLine("Job ID: " + job.Id);
    Console.WriteLine();
    Console.WriteLine("Job State: {0,-20}", job.State);
    Console.WriteLine("Task Progress: {0:0.00}%  ",
      job.Tasks.Single().Progress);
    Thread.Sleep(500);
  }
  Console.WriteLine();
  Console.WriteLine("Job Complete!");
  Console.ReadLine();
}

Don't forget to add Media Service SDK via Nugget Package Manager.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM