+ return onVideoFileTranscoding(video, newVideoFile, videoTranscodedPath, videoOutputPath)
+}
+
+async function mergeAudioVideofile (video: MVideoWithFileThumbnail, resolution: VideoResolution) {
+ const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
+ const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
+ const newExtname = '.mp4'
+
+ const inputVideoFile = video.getOriginalFile()
+
+ const audioInputPath = join(videosDirectory, video.getVideoFilename(video.getOriginalFile()))
+ const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname)
+
+ // If the user updates the video preview during transcoding
+ const previewPath = video.getPreview().getPath()
+ const tmpPreviewPath = join(CONFIG.STORAGE.TMP_DIR, basename(previewPath))
+ await copyFile(previewPath, tmpPreviewPath)
+
+ const transcodeOptions = {
+ type: 'merge-audio' as 'merge-audio',
+ inputPath: tmpPreviewPath,
+ outputPath: videoTranscodedPath,
+ audioPath: audioInputPath,
+ resolution
+ }
+
+ try {
+ await transcode(transcodeOptions)