await ffmpeg(tmpFile)
.withOutputOption('-f mp4')
// List of presets https://trac.ffmpeg.org/wiki/Encode/H.264
// The slower, the better the compression.
.withOutputOption('-preset medium')
.withOutputOption('-movflags frag_keyframe+empty_moov')
.withOutputOption('-max_muxing_queue_size 9999')
// Compressing at typical 23 quality to reduce file sizes with compromising quality.
.withOutputOption('-crf 23')
.withVideoCodec('libx264')
.withAudioCodec('aac')
.withSize('1280x720')
.withAspectRatio('16:9')
.on('start', cmdLine => {
if (debug) {
functions.logger.info('Started ffmpeg', cmdLine)
}
})
.on('end', () => {
if (debug) {
functions.logger.info('Transcoding succeeded!')
}
resolve(true)
})
.on('error', (err: Error, stdout, stderr) => {
if (debug && stdout && stdout !== undefined) {
functions.logger.error('stdout', stdout)
}
if (debug && stderr && stderr !== undefined) {
functions.logger.error('stderr', stderr)
}
reject(Error(err.message))
})
.pipe(remoteWriteStream, { end: true })
Expected results
end should be called when the ffmpeg is finished and the video has been piped. I'm using google cloud storage and I can see the transcoded video is fully complete, but end is only called on short videos, not large videos.
Observed results
end is only called on smaller size videos. On larger videos, around 1GB, end is not called so I'm unable to resolve() the promise waiting for fluent-ffmpeg to throw the end event.
Is there something in my code here that I can adjust to make sure 'end' is called if there is no error? start calls just find and no error is emitted, just end is never called on large videos.
Version information
Code to reproduce
Expected results
end
should be called when the ffmpeg is finished and the video has been piped. I'm using google cloud storage and I can see the transcoded video is fully complete, butend
is only called on short videos, not large videos.Observed results
end
is only called on smaller size videos. On larger videos, around 1GB, end is not called so I'm unable to resolve() the promise waiting for fluent-ffmpeg to throw theend
event.Is there something in my code here that I can adjust to make sure 'end' is called if there is no error?
start
calls just find and noerror
is emitted, justend
is never called on large videos.