aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-transcoding.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-03-10 14:39:40 +0100
committerGitHub <noreply@github.com>2020-03-10 14:39:40 +0100
commit8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (patch)
tree1f87041b2cd76222844960602cdc9f52fe206c7b /server/lib/video-transcoding.ts
parentedb868655e52f934a71141175cf9dc6cb4753e11 (diff)
downloadPeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.gz
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.zst
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.zip
Add video file metadata to download modal, via ffprobe (#2411)
* Add video file metadata via ffprobe * Federate video file metadata * Add tests for file metadata generation * Complete tests for videoFile metadata federation * Lint migration and video-file for metadata * Objectify metadata from getter in ffmpeg-utils * Add metadataUrl to all videoFiles * Simplify metadata API middleware * Load playlist in videoFile when requesting metadata
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r--server/lib/video-transcoding.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index 0d5b3ae39..444b0d954 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -2,6 +2,7 @@ import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSER
2import { basename, extname as extnameUtil, join } from 'path' 2import { basename, extname as extnameUtil, join } from 'path'
3import { 3import {
4 canDoQuickTranscode, 4 canDoQuickTranscode,
5 getMetadataFromFile,
5 getDurationFromVideoFile, 6 getDurationFromVideoFile,
6 getVideoFileFPS, 7 getVideoFileFPS,
7 transcode, 8 transcode,
@@ -19,6 +20,7 @@ import { CONFIG } from '../initializers/config'
19import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/typings/models' 20import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/typings/models'
20import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 21import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
21import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths' 22import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths'
23import { extractVideo } from './videos'
22 24
23/** 25/**
24 * Optimize the original video file and replace it. The resolution is not changed. 26 * Optimize the original video file and replace it. The resolution is not changed.
@@ -202,6 +204,7 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso
202 204
203 newVideoFile.size = stats.size 205 newVideoFile.size = stats.size
204 newVideoFile.fps = await getVideoFileFPS(videoFilePath) 206 newVideoFile.fps = await getVideoFileFPS(videoFilePath)
207 newVideoFile.metadata = await getMetadataFromFile(videoFilePath)
205 208
206 await createTorrentAndSetInfoHash(videoStreamingPlaylist, newVideoFile) 209 await createTorrentAndSetInfoHash(videoStreamingPlaylist, newVideoFile)
207 210
@@ -230,11 +233,16 @@ export {
230async function onVideoFileTranscoding (video: MVideoWithFile, videoFile: MVideoFile, transcodingPath: string, outputPath: string) { 233async function onVideoFileTranscoding (video: MVideoWithFile, videoFile: MVideoFile, transcodingPath: string, outputPath: string) {
231 const stats = await stat(transcodingPath) 234 const stats = await stat(transcodingPath)
232 const fps = await getVideoFileFPS(transcodingPath) 235 const fps = await getVideoFileFPS(transcodingPath)
236 const metadata = await getMetadataFromFile(transcodingPath)
233 237
234 await move(transcodingPath, outputPath) 238 await move(transcodingPath, outputPath)
235 239
240 const extractedVideo = extractVideo(video)
241
236 videoFile.size = stats.size 242 videoFile.size = stats.size
237 videoFile.fps = fps 243 videoFile.fps = fps
244 videoFile.metadata = metadata
245 videoFile.metadataUrl = extractedVideo.getVideoFileMetadataUrl(videoFile, extractedVideo.getBaseUrls().baseUrlHttp)
238 246
239 await createTorrentAndSetInfoHash(video, videoFile) 247 await createTorrentAndSetInfoHash(video, videoFile)
240 248