X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Ftranscoding%2Fvideo-transcoding.ts;h=d70f7f4745be2872a201d1ea752c576299425f80;hb=83903cb65d531a6b6b91715387493ba8312b264d;hp=5df192575f1ea6548f8291ca703b133a400d199f;hpb=819b656439e5f0ec2ae5de9357502cdfe3196197;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/transcoding/video-transcoding.ts b/server/lib/transcoding/video-transcoding.ts index 5df192575..d70f7f474 100644 --- a/server/lib/transcoding/video-transcoding.ts +++ b/server/lib/transcoding/video-transcoding.ts @@ -1,6 +1,7 @@ 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' @@ -13,7 +14,7 @@ import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSER 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' /** @@ -35,6 +36,8 @@ async function optimizeOriginalVideofile (video: MVideoFullLight, inputVideoFile ? 'quick-transcode' : 'video' + const resolution = toEven(inputVideoFile.resolution) + const transcodeOptions: TranscodeOptions = { type: transcodeType, @@ -44,7 +47,7 @@ async function optimizeOriginalVideofile (video: MVideoFullLight, inputVideoFile availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), profile: CONFIG.TRANSCODING.PROFILE, - resolution: inputVideoFile.resolution, + resolution, job } @@ -57,7 +60,7 @@ async function optimizeOriginalVideofile (video: MVideoFullLight, inputVideoFile // 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) @@ -83,7 +86,7 @@ async function transcodeNewWebTorrentResolution (video: MVideoFullLight, resolut const newVideoFile = new VideoFileModel({ resolution, extname, - filename: generateVideoFilename(video, false, resolution, extname), + filename: generateWebTorrentVideoFilename(resolution, extname), size: 0, videoId: video.id }) @@ -166,7 +169,7 @@ async function mergeAudioVideofile (video: MVideoFullLight, resolution: VideoRes // 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 @@ -268,7 +271,7 @@ async function generateHlsPlaylistCommon (options: { 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) @@ -316,7 +319,7 @@ async function generateHlsPlaylistCommon (options: { resolution, extname, size: 0, - filename: generateVideoFilename(video, true, resolution, extname), + filename: videoFilename, fps: -1, videoStreamingPlaylistId: videoStreamingPlaylist.id })