mirror of https://github.com/Chocobozzz/PeerTube
				
				
				
			Fix HLS audio desync on some videos
							parent
							
								
									f65920b2ca
								
							
						
					
					
						commit
						0adbc73eb9
					
				| 
						 | 
					@ -112,8 +112,8 @@ export class FFmpegVOD {
 | 
				
			||||||
    return this.ended
 | 
					    return this.ended
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async buildWebVideoCommand (options: TranscodeVODOptions) {
 | 
					  private async buildWebVideoCommand (options: TranscodeVODOptions & { canCopyAudio?: boolean, canCopyVideo?: boolean }) {
 | 
				
			||||||
    const { resolution, fps, inputPath } = options
 | 
					    const { resolution, fps, inputPath, canCopyAudio = true, canCopyVideo = true } = options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (resolution === VideoResolution.H_NOVIDEO) {
 | 
					    if (resolution === VideoResolution.H_NOVIDEO) {
 | 
				
			||||||
      presetOnlyAudio(this.commandWrapper)
 | 
					      presetOnlyAudio(this.commandWrapper)
 | 
				
			||||||
| 
						 | 
					@ -136,8 +136,8 @@ export class FFmpegVOD {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      resolution,
 | 
					      resolution,
 | 
				
			||||||
      input: inputPath,
 | 
					      input: inputPath,
 | 
				
			||||||
      canCopyAudio: true,
 | 
					      canCopyAudio,
 | 
				
			||||||
      canCopyVideo: true,
 | 
					      canCopyVideo,
 | 
				
			||||||
      fps,
 | 
					      fps,
 | 
				
			||||||
      scaleFilterValue
 | 
					      scaleFilterValue
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
| 
						 | 
					@ -193,9 +193,15 @@ export class FFmpegVOD {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const videoPath = this.getHLSVideoPath(options)
 | 
					    const videoPath = this.getHLSVideoPath(options)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (options.copyCodecs) presetCopy(this.commandWrapper)
 | 
					    if (options.copyCodecs) {
 | 
				
			||||||
    else if (options.resolution === VideoResolution.H_NOVIDEO) presetOnlyAudio(this.commandWrapper)
 | 
					      presetCopy(this.commandWrapper)
 | 
				
			||||||
    else await this.buildWebVideoCommand(options)
 | 
					    } else if (options.resolution === VideoResolution.H_NOVIDEO) {
 | 
				
			||||||
 | 
					      presetOnlyAudio(this.commandWrapper)
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      // If we cannot copy codecs, we do not copy them at all to prevent issues like audio desync
 | 
				
			||||||
 | 
					      // See for example https://github.com/Chocobozzz/PeerTube/issues/6438
 | 
				
			||||||
 | 
					      await this.buildWebVideoCommand({ ...options, canCopyAudio: false, canCopyVideo: false })
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.addCommonHLSVODCommandOptions(command, videoPath)
 | 
					    this.addCommonHLSVODCommandOptions(command, videoPath)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue