Add back -re option on uncached streams

This commit is contained in:
Max Isom 2021-11-24 13:16:44 -06:00
parent 49664be9e1
commit 9f9469f682
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880

View file

@ -364,6 +364,17 @@ export default class {
// Create stream and pipe to capacitor // Create stream and pipe to capacitor
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const capacitor = new WriteStream();
// Cache video if necessary
if (shouldCacheVideo) {
const cacheStream = this.fileCache.createWriteStream(this.getHashForCache(url));
capacitor.createReadStream().pipe(cacheStream);
} else {
ffmpegInputOptions.push('-re');
}
const youtubeStream = ffmpeg(ffmpegInput) const youtubeStream = ffmpeg(ffmpegInput)
.inputOptions(ffmpegInputOptions) .inputOptions(ffmpegInputOptions)
.noVideo() .noVideo()
@ -374,17 +385,8 @@ export default class {
reject(error); reject(error);
}); });
const capacitor = new WriteStream();
youtubeStream.pipe(capacitor); youtubeStream.pipe(capacitor);
// Cache video if necessary
if (shouldCacheVideo) {
const cacheStream = this.fileCache.createWriteStream(this.getHashForCache(url));
capacitor.createReadStream().pipe(cacheStream);
}
resolve(capacitor.createReadStream()); resolve(capacitor.createReadStream());
}); });
} }