diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-29 13:57:17 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-29 14:05:41 +0100 |
commit | 789951460bf724ac6a2f18097878fc735269ea71 (patch) | |
tree | b27f9891333ceb1465e6fd63198568545fb0c266 /server | |
parent | e25f83ce2106750b552133da232a9a0810ceb9b0 (diff) | |
download | PeerTube-789951460bf724ac6a2f18097878fc735269ea71.tar.gz PeerTube-789951460bf724ac6a2f18097878fc735269ea71.tar.zst PeerTube-789951460bf724ac6a2f18097878fc735269ea71.zip |
Try to support other codecs
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/ffprobe-utils.ts | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 5b1ad9066..fefed25ae 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts | |||
@@ -91,18 +91,35 @@ async function getVideoStreamCodec (path: string) { | |||
91 | 91 | ||
92 | const videoCodec = videoStream.codec_tag_string | 92 | const videoCodec = videoStream.codec_tag_string |
93 | 93 | ||
94 | if (videoCodec === 'vp09') return 'vp09.00.50.08' | ||
95 | |||
94 | const baseProfileMatrix = { | 96 | const baseProfileMatrix = { |
95 | High: '6400', | 97 | avc1: { |
96 | Main: '4D40', | 98 | High: '6400', |
97 | Baseline: '42E0' | 99 | Main: '4D40', |
100 | Baseline: '42E0' | ||
101 | }, | ||
102 | av01: { | ||
103 | High: '1', | ||
104 | Main: '0', | ||
105 | Professional: '2' | ||
106 | } | ||
98 | } | 107 | } |
99 | 108 | ||
100 | let baseProfile = baseProfileMatrix[videoStream.profile] | 109 | let baseProfile = baseProfileMatrix[videoCodec][videoStream.profile] |
101 | if (!baseProfile) { | 110 | if (!baseProfile) { |
102 | logger.warn('Cannot get video profile codec of %s.', path, { videoStream }) | 111 | logger.warn('Cannot get video profile codec of %s.', path, { videoStream }) |
103 | baseProfile = baseProfileMatrix['High'] // Fallback | 112 | baseProfile = baseProfileMatrix[videoCodec]['High'] // Fallback |
113 | } | ||
114 | |||
115 | if (videoCodec === 'av01') { | ||
116 | const level = videoStream.level | ||
117 | |||
118 | // Guess the tier indicator and bit depth | ||
119 | return `${videoCodec}.${baseProfile}.${level}M.08` | ||
104 | } | 120 | } |
105 | 121 | ||
122 | // Default, h264 codec | ||
106 | let level = videoStream.level.toString(16) | 123 | let level = videoStream.level.toString(16) |
107 | if (level.length === 1) level = `0${level}` | 124 | if (level.length === 1) level = `0${level}` |
108 | 125 | ||
@@ -114,8 +131,11 @@ async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.Ffprobe | |||
114 | 131 | ||
115 | if (!audioStream) return '' | 132 | if (!audioStream) return '' |
116 | 133 | ||
117 | const audioCodec = audioStream.codec_name | 134 | const audioCodecName = audioStream.codec_name |
118 | if (audioCodec === 'aac') return 'mp4a.40.2' | 135 | |
136 | if (audioCodecName === 'opus') return 'opus' | ||
137 | if (audioCodecName === 'vorbis') return 'vorbis' | ||
138 | if (audioCodecName === 'aac') return 'mp4a.40.2' | ||
119 | 139 | ||
120 | logger.warn('Cannot get audio codec of %s.', path, { audioStream }) | 140 | logger.warn('Cannot get audio codec of %s.', path, { audioStream }) |
121 | 141 | ||