EncodingUtils.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using MediaBrowser.Model.MediaInfo;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MediaBrowser.MediaEncoding.Encoder
  5. {
  6. public static class EncodingUtils
  7. {
  8. public static string GetInputArgument(List<string> inputFiles, MediaProtocol protocol)
  9. {
  10. if (protocol == MediaProtocol.Http)
  11. {
  12. var url = inputFiles.First();
  13. return string.Format("\"{0}\"", url);
  14. }
  15. if (protocol == MediaProtocol.Rtmp)
  16. {
  17. var url = inputFiles.First();
  18. return string.Format("\"{0}\"", url);
  19. }
  20. return GetConcatInputArgument(inputFiles);
  21. }
  22. /// <summary>
  23. /// Gets the concat input argument.
  24. /// </summary>
  25. /// <param name="inputFiles">The input files.</param>
  26. /// <returns>System.String.</returns>
  27. private static string GetConcatInputArgument(IReadOnlyList<string> inputFiles)
  28. {
  29. // Get all streams
  30. // If there's more than one we'll need to use the concat command
  31. if (inputFiles.Count > 1)
  32. {
  33. var files = string.Join("|", inputFiles);
  34. return string.Format("concat:\"{0}\"", files);
  35. }
  36. // Determine the input path for video files
  37. return GetFileInputArgument(inputFiles[0]);
  38. }
  39. /// <summary>
  40. /// Gets the file input argument.
  41. /// </summary>
  42. /// <param name="path">The path.</param>
  43. /// <returns>System.String.</returns>
  44. private static string GetFileInputArgument(string path)
  45. {
  46. return string.Format("file:\"{0}\"", path);
  47. }
  48. public static string GetProbeSizeArgument(bool isDvd)
  49. {
  50. return isDvd ? "-probesize 1G -analyzeduration 200M" : string.Empty;
  51. }
  52. }
  53. }