mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Regenerate miniature on live save
This commit is contained in:
parent
3bc68dfd61
commit
053aed43fb
12 changed files with 61 additions and 69 deletions
|
@ -1,10 +1,10 @@
|
|||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import { maxBy, minBy } from 'lodash'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import { join } from 'path'
|
||||
import * as request from 'request'
|
||||
import * as sequelize from 'sequelize'
|
||||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import {
|
||||
ActivityHashTagObject,
|
||||
ActivityMagnetUrlObject,
|
||||
|
@ -13,8 +13,7 @@ import {
|
|||
ActivitypubHttpFetcherPayload,
|
||||
ActivityTagObject,
|
||||
ActivityUrlObject,
|
||||
ActivityVideoUrlObject,
|
||||
VideoState
|
||||
ActivityVideoUrlObject
|
||||
} from '../../../shared/index'
|
||||
import { VideoObject } from '../../../shared/models/activitypub/objects'
|
||||
import { VideoPrivacy } from '../../../shared/models/videos'
|
||||
|
@ -562,8 +561,6 @@ function isAPHashTagObject (url: any): url is ActivityHashTagObject {
|
|||
return url && url.type === 'Hashtag'
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function createVideo (videoObject: VideoObject, channel: MChannelAccountLight, waitThumbnail = false) {
|
||||
logger.debug('Adding remote video %s.', videoObject.id)
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@ import { VideoFileModel } from '@server/models/video/video-file'
|
|||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
|
||||
import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
|
||||
import { VideoLiveEndingPayload, VideoState } from '@shared/models'
|
||||
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { generateVideoMiniature } from '@server/lib/thumbnail'
|
||||
|
||||
async function processVideoLiveEnding (job: Bull.Job) {
|
||||
const payload = job.data as VideoLiveEndingPayload
|
||||
|
@ -109,6 +110,15 @@ async function saveLive (video: MVideo, live: MVideoLive) {
|
|||
await remove(videoInputPath)
|
||||
}
|
||||
|
||||
// Regenerate the thumbnail & preview?
|
||||
if (videoWithFiles.getMiniature().automaticallyGenerated === true) {
|
||||
await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.MINIATURE)
|
||||
}
|
||||
|
||||
if (videoWithFiles.getPreview().automaticallyGenerated === true) {
|
||||
await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
|
||||
}
|
||||
|
||||
await publishAndFederateIfNeeded(video, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,13 @@ import * as chokidar from 'chokidar'
|
|||
import { FfmpegCommand } from 'fluent-ffmpeg'
|
||||
import { ensureDir, stat } from 'fs-extra'
|
||||
import { basename } from 'path'
|
||||
import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution, getVideoStreamCodec, getVideoStreamSize, runLiveMuxing, runLiveTranscoding } from '@server/helpers/ffmpeg-utils'
|
||||
import {
|
||||
computeResolutionsToTranscode,
|
||||
getVideoFileFPS,
|
||||
getVideoFileResolution,
|
||||
runLiveMuxing,
|
||||
runLiveTranscoding
|
||||
} from '@server/helpers/ffmpeg-utils'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config'
|
||||
import { MEMOIZE_TTL, P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants'
|
||||
|
|
|
@ -9,7 +9,7 @@ import { extractVideo } from '@server/helpers/video'
|
|||
function getVideoFilename (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile) {
|
||||
const video = extractVideo(videoOrPlaylist)
|
||||
|
||||
if (isStreamingPlaylist(videoOrPlaylist)) {
|
||||
if (videoFile.isHLS()) {
|
||||
return generateVideoStreamingPlaylistName(video.uuid, videoFile.resolution)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ function generateWebTorrentVideoName (uuid: string, resolution: number, extname:
|
|||
}
|
||||
|
||||
function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) {
|
||||
if (isStreamingPlaylist(videoOrPlaylist)) {
|
||||
if (videoFile.isHLS()) {
|
||||
const video = extractVideo(videoOrPlaylist)
|
||||
|
||||
return join(getHLSDirectory(video), getVideoFilename(videoOrPlaylist, videoFile))
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
|
||||
import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
|
||||
import { basename, extname as extnameUtil, join } from 'path'
|
||||
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
|
||||
import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
|
||||
import { VideoResolution } from '../../shared/models/videos'
|
||||
import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
|
||||
import {
|
||||
canDoQuickTranscode,
|
||||
getDurationFromVideoFile,
|
||||
|
@ -9,18 +13,13 @@ import {
|
|||
TranscodeOptions,
|
||||
TranscodeOptionsType
|
||||
} from '../helpers/ffmpeg-utils'
|
||||
import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { VideoResolution } from '../../shared/models/videos'
|
||||
import { VideoFileModel } from '../models/video/video-file'
|
||||
import { updateMasterHLSPlaylist, updateSha256VODSegments } from './hls'
|
||||
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
|
||||
import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
|
||||
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
|
||||
import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
|
||||
import { VideoFileModel } from '../models/video/video-file'
|
||||
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
|
||||
import { updateMasterHLSPlaylist, updateSha256VODSegments } from './hls'
|
||||
import { generateVideoStreamingPlaylistName, getVideoFilename, getVideoFilePath } from './video-paths'
|
||||
import { spawn } from 'child_process'
|
||||
|
||||
/**
|
||||
* Optimize the original video file and replace it. The resolution is not changed.
|
||||
|
|
|
@ -4,7 +4,7 @@ import { TagModel } from '@server/models/video/tag'
|
|||
import { VideoModel } from '@server/models/video/video'
|
||||
import { FilteredModelAttributes } from '@server/types'
|
||||
import { MTag, MThumbnail, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
|
||||
import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState } from '@shared/models'
|
||||
import { ThumbnailType, VideoCreate, VideoPrivacy } from '@shared/models'
|
||||
import { federateVideoIfNeeded } from './activitypub/videos'
|
||||
import { Notifier } from './notifier'
|
||||
import { createVideoMiniatureFromExisting } from './thumbnail'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue