You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

format.go 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package data
  2. type FormatType uint8
  3. const (
  4. FormatVideoOnly = 1 << iota
  5. FormatAudioOnly
  6. Format3D
  7. FormatHLS
  8. FormatDASH
  9. FormatHighFps
  10. FormatStd = 0
  11. )
  12. type Format struct {
  13. FormatID string
  14. Extension string
  15. Width uint32
  16. Height uint32
  17. VideoCodec string
  18. AudioCodec string
  19. AudioBitrate uint32
  20. Flags FormatType
  21. }
  22. // Taken from github.com/rg3/youtube-dl
  23. // As in youtube_dl/extractor/youtube.py
  24. var Formats = []Format{
  25. // Standard formats
  26. { "5", "flv", 400, 240, "h263", "mp3", 64, FormatStd },
  27. { "6", "flv", 450, 270, "h263", "mp3", 64, FormatStd },
  28. { "13", "3gp", 0, 0, "mp4v", "aac", 0, FormatStd },
  29. { "17", "3gp", 176, 144, "mp4v", "aac", 24, FormatStd },
  30. { "18", "mp4", 640, 360, "h264", "aac", 96, FormatStd },
  31. { "22", "mp4", 1280, 720, "h264", "aac", 192, FormatStd },
  32. { "34", "flv", 640, 360, "h264", "aac", 128, FormatStd },
  33. { "35", "flv", 854, 480, "h264", "aac", 128, FormatStd },
  34. // * ID 36 videos are either 320x180 (BaW_jenozKc) or 320x240 (__2ABJjxzNo), abr varies as well
  35. { "36", "3gp", 320, 0, "mp4v", "aac", 0, FormatStd },
  36. { "37", "mp4", 1920, 1080, "h264", "aac", 192, FormatStd },
  37. { "38", "mp4", 4096, 3072, "h264", "aac", 192, FormatStd },
  38. { "43", "webm", 640, 360, "vp8", "vorbis", 128, FormatStd },
  39. { "44", "webm", 854, 480, "vp8", "vorbis", 128, FormatStd },
  40. { "45", "webm", 1280, 720, "vp8", "vorbis", 192, FormatStd },
  41. { "46", "webm", 1920, 1080, "vp8", "vorbis", 192, FormatStd },
  42. { "59", "mp4", 854, 480, "h264", "aac", 128, FormatStd },
  43. { "78", "mp4", 854, 480, "h264", "aac", 128, FormatStd },
  44. // 3D videos
  45. { "82", "mp4", 0, 360, "h264", "aac", 128, Format3D },
  46. { "83", "mp4", 0, 480, "h264", "aac", 128, Format3D },
  47. { "84", "mp4", 0, 720, "h264", "aac", 192, Format3D },
  48. { "85", "mp4", 0, 1080, "h264", "aac", 192, Format3D },
  49. { "100", "webm", 0, 360, "vp8", "vorbis", 128, Format3D },
  50. { "101", "webm", 0, 480, "vp8", "vorbis", 192, Format3D },
  51. { "102", "webm", 0, 720, "vp8", "vorbis", 192, Format3D },
  52. // Apple HTTP Live Streaming
  53. { "91", "mp4", 0, 144, "h264", "aac", 48, FormatHLS },
  54. { "92", "mp4", 0, 240, "h264", "aac", 48, FormatHLS },
  55. { "93", "mp4", 0, 360, "h264", "aac", 128, FormatHLS },
  56. { "94", "mp4", 0, 480, "h264", "aac", 128, FormatHLS },
  57. { "95", "mp4", 0, 720, "h264", "aac", 256, FormatHLS },
  58. { "96", "mp4", 0, 1080, "h264", "aac", 256, FormatHLS },
  59. { "132", "mp4", 0, 240, "h264", "aac", 48, FormatHLS },
  60. { "151", "mp4", 0, 72, "h264", "aac", 24, FormatHLS },
  61. // DASH mp4 video
  62. { "133", "mp4", 0, 240, "h264", "", 0, FormatDASH | FormatVideoOnly },
  63. { "134", "mp4", 0, 360, "h264", "", 0, FormatDASH | FormatVideoOnly },
  64. { "135", "mp4", 0, 480, "h264", "", 0, FormatDASH | FormatVideoOnly },
  65. { "136", "mp4", 0, 720, "h264", "", 0, FormatDASH | FormatVideoOnly },
  66. { "137", "mp4", 0, 1080, "h264", "", 0, FormatDASH | FormatVideoOnly },
  67. { "138", "mp4", 0, 0, "h264", "", 0, FormatDASH | FormatVideoOnly }, // Height can vary (https://github.com/rg3/youtube-dl/issues/4559)
  68. { "160", "mp4", 0, 144, "h264", "", 0, FormatDASH | FormatVideoOnly },
  69. { "212", "mp4", 0, 480, "h264", "", 0, FormatDASH | FormatVideoOnly },
  70. { "264", "mp4", 0, 1440, "h264", "", 0, FormatDASH | FormatVideoOnly },
  71. { "298", "mp4", 0, 720, "h264", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  72. { "299", "mp4", 0, 1080, "h264", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  73. { "266", "mp4", 0, 2160, "h264", "", 0, FormatDASH | FormatVideoOnly },
  74. // DASH mp4 audio
  75. { "139", "m4a", 0, 0, "", "aac", 48, FormatDASH | FormatAudioOnly },
  76. { "140", "m4a", 0, 0, "", "aac", 128, FormatDASH | FormatAudioOnly },
  77. { "141", "m4a", 0, 0, "", "aac", 256, FormatDASH | FormatAudioOnly },
  78. { "256", "m4a", 0, 0, "", "aac", 0, FormatDASH | FormatAudioOnly },
  79. { "258", "m4a", 0, 0, "", "aac", 0, FormatDASH | FormatAudioOnly },
  80. { "325", "m4a", 0, 0, "", "dtse", 0, FormatDASH | FormatAudioOnly },
  81. { "328", "m4a", 0, 0, "", "ec-3", 0, FormatDASH | FormatAudioOnly },
  82. // DASH webm
  83. { "167", "webm", 640, 360, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  84. { "168", "webm", 854, 480, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  85. { "169", "webm", 1280, 720, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  86. { "170", "webm", 1920, 1080, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  87. { "218", "webm", 854, 480, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  88. { "219", "webm", 854, 480, "vp8", "", 0, FormatDASH | FormatVideoOnly },
  89. { "278", "webm", 0, 144, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  90. { "242", "webm", 0, 240, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  91. { "243", "webm", 0, 360, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  92. { "244", "webm", 0, 480, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  93. { "245", "webm", 0, 480, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  94. { "246", "webm", 0, 480, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  95. { "247", "webm", 0, 720, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  96. { "248", "webm", 0, 1080, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  97. { "271", "webm", 0, 1440, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  98. // * ID 272 videos are either 3840x2160 (e.g. RtoitU2A-3E) or 7680x4320 (sLprVF6d7Ug)
  99. { "272", "webm", 0, 2160, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  100. { "302", "webm", 0, 720, "vp9", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  101. { "303", "webm", 0, 1080, "vp9", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  102. { "308", "webm", 0, 1440, "vp9", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  103. { "313", "webm", 0, 2160, "vp9", "", 0, FormatDASH | FormatVideoOnly },
  104. { "315", "webm", 0, 2160, "vp9", "", 0, FormatDASH | FormatVideoOnly | FormatHighFps },
  105. // DASH webm audio
  106. { "171", "webm", 0, 0, "", "vorbis", 128, FormatDASH | FormatAudioOnly },
  107. { "172", "webm", 0, 0, "", "vorbis", 256, FormatDASH | FormatAudioOnly },
  108. // DASH webm opus audio
  109. { "249", "webm", 0, 0, "", "opus", 50, FormatDASH | FormatAudioOnly },
  110. { "250", "webm", 0, 0, "", "opus", 70, FormatDASH | FormatAudioOnly },
  111. { "251", "webm", 0, 0, "", "opus", 160, FormatDASH | FormatAudioOnly },
  112. }