mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Fix:Catch error with transcodes writing concat file & do not fallback to AAC encode if error message is a failure to find include file
This commit is contained in:
parent
3ab638ed61
commit
1b2cf50633
@ -254,8 +254,14 @@ class Stream extends EventEmitter {
|
||||
this.ffmpeg = Ffmpeg()
|
||||
this.furthestSegmentCreated = 0
|
||||
|
||||
var adjustedStartTime = Math.max(this.startTime - this.maxSeekBackTime, 0)
|
||||
var trackStartTime = await writeConcatFile(this.tracks, this.concatFilesPath, adjustedStartTime)
|
||||
const adjustedStartTime = Math.max(this.startTime - this.maxSeekBackTime, 0)
|
||||
const trackStartTime = await writeConcatFile(this.tracks, this.concatFilesPath, adjustedStartTime)
|
||||
if (trackStartTime == null) {
|
||||
// Close stream show error
|
||||
this.ffmpeg = null
|
||||
this.close('Failed to write stream concat file')
|
||||
return
|
||||
}
|
||||
|
||||
this.ffmpeg.addInput(this.concatFilesPath)
|
||||
// seek_timestamp : https://ffmpeg.org/ffmpeg.html
|
||||
@ -343,7 +349,8 @@ class Stream extends EventEmitter {
|
||||
|
||||
// Temporary workaround for https://github.com/advplyr/audiobookshelf/issues/172 and https://github.com/advplyr/audiobookshelf/issues/2157
|
||||
const aacErrorMsg = 'ffmpeg exited with code 1'
|
||||
if (audioCodec === 'copy' && this.isAACEncodable && err.message?.startsWith(aacErrorMsg)) {
|
||||
const errorMessageSuggestsReEncode = err.message?.startsWith(aacErrorMsg) && !err.message?.includes('No such file or directory')
|
||||
if (audioCodec === 'copy' && this.isAACEncodable && errorMessageSuggestsReEncode) {
|
||||
Logger.info(`[Stream] Re-attempting stream with AAC encode`)
|
||||
this.transcodeOptions.forceAAC = true
|
||||
this.reset(this.startTime)
|
||||
|
@ -35,9 +35,14 @@ async function writeConcatFile(tracks, outputPath, startTime = 0) {
|
||||
return line
|
||||
})
|
||||
var inputstr = trackPaths.join('\n\n')
|
||||
await fs.writeFile(outputPath, inputstr)
|
||||
|
||||
try {
|
||||
await fs.writeFile(outputPath, inputstr)
|
||||
return firstTrackStartTime
|
||||
} catch (error) {
|
||||
Logger.error(`[ffmpegHelpers] Failed to write stream concat file at "${outputPath}"`, error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
module.exports.writeConcatFile = writeConcatFile
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user