Add audio only transcoding tests

This commit is contained in:
Chocobozzz 2019-11-22 11:43:17 +01:00
parent 6ad88df896
commit 3a149e9f8b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
8 changed files with 156 additions and 84 deletions

View file

@ -83,51 +83,18 @@ async function transcodeNewResolution (video: MVideoWithFile, resolution: VideoR
const transcodeOptions = resolution === VideoResolution.H_NOVIDEO
? {
type: 'split-audio' as 'split-audio',
inputPath: videoInputPath,
outputPath: videoTranscodedPath,
resolution,
}
type: 'only-audio' as 'only-audio',
inputPath: videoInputPath,
outputPath: videoTranscodedPath,
resolution
}
: {
type: 'video' as 'video',
inputPath: videoInputPath,
outputPath: videoTranscodedPath,
resolution,
isPortraitMode: isPortrait
}
await transcode(transcodeOptions)
return onVideoFileTranscoding(video, newVideoFile, videoTranscodedPath, videoOutputPath)
}
/**
* Extract audio into a separate audio-only mp4.
*/
async function splitAudioFile (video: MVideoWithFile) {
const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
const extname = '.mp4'
const resolution = VideoResolution.H_NOVIDEO
// We are sure it's x264 in mp4 because optimizeOriginalVideofile was already executed
const videoInputPath = join(videosDirectory, video.getVideoFilename(video.getOriginalFile()))
const newVideoFile = new VideoFileModel({
resolution,
extname,
size: 0,
videoId: video.id
})
const videoOutputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(newVideoFile))
const videoTranscodedPath = join(transcodeDirectory, video.getVideoFilename(newVideoFile))
const transcodeOptions = {
type: 'split-audio' as 'split-audio',
inputPath: videoInputPath,
outputPath: videoTranscodedPath,
resolution
}
type: 'video' as 'video',
inputPath: videoInputPath,
outputPath: videoTranscodedPath,
resolution,
isPortraitMode: isPortrait
}
await transcode(transcodeOptions)