Add audio only transcoding tests
This commit is contained in:
parent
6ad88df896
commit
3a149e9f8b
8 changed files with 156 additions and 84 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue