import { Job } from 'bull'
import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
import { basename, extname as extnameUtil, join } from 'path'
+import { toEven } from '@server/helpers/core-utils'
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
import { VideoResolution } from '../../../shared/models/videos'
import { VideoFileModel } from '../../models/video/video-file'
import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
import { updateMasterHLSPlaylist, updateSha256VODSegments } from '../hls'
-import { generateVideoFilename, generateVideoStreamingPlaylistName, getVideoFilePath } from '../video-paths'
+import { generateHLSVideoFilename, generateWebTorrentVideoFilename, getVideoFilePath } from '../video-paths'
import { VideoTranscodingProfilesManager } from './video-transcoding-profiles'
/**
? 'quick-transcode'
: 'video'
+ const resolution = toEven(inputVideoFile.resolution)
+
const transcodeOptions: TranscodeOptions = {
type: transcodeType,
availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
profile: CONFIG.TRANSCODING.PROFILE,
- resolution: inputVideoFile.resolution,
+ resolution,
job
}
// Important to do this before getVideoFilename() to take in account the new filename
inputVideoFile.extname = newExtname
- inputVideoFile.filename = generateVideoFilename(video, false, inputVideoFile.resolution, newExtname)
+ inputVideoFile.filename = generateWebTorrentVideoFilename(resolution, newExtname)
const videoOutputPath = getVideoFilePath(video, inputVideoFile)
const newVideoFile = new VideoFileModel({
resolution,
extname,
- filename: generateVideoFilename(video, false, resolution, extname),
+ filename: generateWebTorrentVideoFilename(resolution, extname),
size: 0,
videoId: video.id
})
// Important to do this before getVideoFilename() to take in account the new file extension
inputVideoFile.extname = newExtname
- inputVideoFile.filename = generateVideoFilename(video, false, inputVideoFile.resolution, newExtname)
+ inputVideoFile.filename = generateWebTorrentVideoFilename(inputVideoFile.resolution, newExtname)
const videoOutputPath = getVideoFilePath(video, inputVideoFile)
// ffmpeg generated a new video file, so update the video duration
const videoTranscodedBasePath = join(transcodeDirectory, type)
await ensureDir(videoTranscodedBasePath)
- const videoFilename = generateVideoStreamingPlaylistName(video.uuid, resolution)
+ const videoFilename = generateHLSVideoFilename(resolution)
const playlistFilename = VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)
const playlistFileTranscodePath = join(videoTranscodedBasePath, playlistFilename)
resolution,
extname,
size: 0,
- filename: generateVideoFilename(video, true, resolution, extname),
+ filename: videoFilename,
fps: -1,
videoStreamingPlaylistId: videoStreamingPlaylist.id
})