diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/transcoding/video-transcoding.ts | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/server/lib/transcoding/video-transcoding.ts b/server/lib/transcoding/video-transcoding.ts index ee228c011..250a678eb 100644 --- a/server/lib/transcoding/video-transcoding.ts +++ b/server/lib/transcoding/video-transcoding.ts | |||
@@ -8,7 +8,6 @@ import { VideoResolution, VideoStorage } from '../../../shared/models/videos' | |||
8 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' | 8 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' |
9 | import { transcode, TranscodeOptions, TranscodeOptionsType } from '../../helpers/ffmpeg-utils' | 9 | import { transcode, TranscodeOptions, TranscodeOptionsType } from '../../helpers/ffmpeg-utils' |
10 | import { canDoQuickTranscode, getDurationFromVideoFile, getMetadataFromFile, getVideoFileFPS } from '../../helpers/ffprobe-utils' | 10 | import { canDoQuickTranscode, getDurationFromVideoFile, getMetadataFromFile, getVideoFileFPS } from '../../helpers/ffprobe-utils' |
11 | import { logger } from '../../helpers/logger' | ||
12 | import { CONFIG } from '../../initializers/config' | 11 | import { CONFIG } from '../../initializers/config' |
13 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers/constants' | 12 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers/constants' |
14 | import { VideoFileModel } from '../../models/video/video-file' | 13 | import { VideoFileModel } from '../../models/video/video-file' |
@@ -62,25 +61,17 @@ function optimizeOriginalVideofile (video: MVideoFullLight, inputVideoFile: MVid | |||
62 | // Could be very long! | 61 | // Could be very long! |
63 | await transcode(transcodeOptions) | 62 | await transcode(transcodeOptions) |
64 | 63 | ||
65 | try { | 64 | // Important to do this before getVideoFilename() to take in account the new filename |
66 | await remove(videoInputPath) | 65 | inputVideoFile.extname = newExtname |
67 | 66 | inputVideoFile.filename = generateWebTorrentVideoFilename(resolution, newExtname) | |
68 | // Important to do this before getVideoFilename() to take in account the new filename | 67 | inputVideoFile.storage = VideoStorage.FILE_SYSTEM |
69 | inputVideoFile.extname = newExtname | ||
70 | inputVideoFile.filename = generateWebTorrentVideoFilename(resolution, newExtname) | ||
71 | inputVideoFile.storage = VideoStorage.FILE_SYSTEM | ||
72 | |||
73 | const videoOutputPath = VideoPathManager.Instance.getFSVideoFileOutputPath(video, inputVideoFile) | ||
74 | 68 | ||
75 | const { videoFile } = await onWebTorrentVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) | 69 | const videoOutputPath = VideoPathManager.Instance.getFSVideoFileOutputPath(video, inputVideoFile) |
76 | 70 | ||
77 | return { transcodeType, videoFile } | 71 | const { videoFile } = await onWebTorrentVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) |
78 | } catch (err) { | 72 | await remove(videoInputPath) |
79 | // Auto destruction... | ||
80 | video.destroy().catch(err => logger.error('Cannot destruct video after transcoding failure.', { err })) | ||
81 | 73 | ||
82 | throw err | 74 | return { transcodeType, videoFile } |
83 | } | ||
84 | }) | 75 | }) |
85 | } | 76 | } |
86 | 77 | ||