aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/ffmpeg/src/ffprobe.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/ffmpeg/src/ffprobe.ts')
-rw-r--r--packages/ffmpeg/src/ffprobe.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/ffmpeg/src/ffprobe.ts b/packages/ffmpeg/src/ffprobe.ts
index ed1742ab1..f995e7925 100644
--- a/packages/ffmpeg/src/ffprobe.ts
+++ b/packages/ffmpeg/src/ffprobe.ts
@@ -10,7 +10,7 @@ import { VideoResolution } from '@peertube/peertube-models'
10 10
11function ffprobePromise (path: string) { 11function ffprobePromise (path: string) {
12 return new Promise<FfprobeData>((res, rej) => { 12 return new Promise<FfprobeData>((res, rej) => {
13 ffmpeg.ffprobe(path, (err, data) => { 13 ffmpeg.ffprobe(path, [ '-show_chapters' ], (err, data) => {
14 if (err) return rej(err) 14 if (err) return rej(err)
15 15
16 return res(data) 16 return res(data)
@@ -169,9 +169,26 @@ async function getVideoStream (path: string, existingProbe?: FfprobeData) {
169} 169}
170 170
171// --------------------------------------------------------------------------- 171// ---------------------------------------------------------------------------
172// Chapters
173// ---------------------------------------------------------------------------
174
175async function getChaptersFromContainer (path: string, existingProbe?: FfprobeData) {
176 const metadata = existingProbe || await ffprobePromise(path)
177
178 if (!Array.isArray(metadata?.chapters)) return []
179
180 return metadata.chapters
181 .map(c => ({
182 timecode: c.start_time,
183 title: c['TAG:title']
184 }))
185}
186
187// ---------------------------------------------------------------------------
172 188
173export { 189export {
174 getVideoStreamDimensionsInfo, 190 getVideoStreamDimensionsInfo,
191 getChaptersFromContainer,
175 getMaxAudioBitrate, 192 getMaxAudioBitrate,
176 getVideoStream, 193 getVideoStream,
177 getVideoStreamDuration, 194 getVideoStreamDuration,