import { buildNextVideoState } from '@server/lib/video-state'
import { openapiOperationDoc } from '@server/middlewares/doc'
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
-import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'
-import { isAudioFile } from '@shared/extra-utils'
+import { getLowercaseExtension } from '@shared/core-utils'
+import { isAudioFile, uuidToShort } from '@shared/extra-utils'
import { HttpStatusCode, VideoCreate, VideoResolution, VideoState } from '@shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { retryTransactionWrapper } from '../../../helpers/database-utils'
import { createReqFiles } from '../../../helpers/express-utils'
-import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
+import { buildFileMetadata, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '../../../helpers/ffmpeg'
import { logger, loggerTagsFactory } from '../../../helpers/logger'
-import { CONFIG } from '../../../initializers/config'
import { MIMETYPES } from '../../../initializers/constants'
import { sequelizeTypescript } from '../../../initializers/database'
import { federateVideoIfNeeded } from '../../../lib/activitypub/videos'
authenticate,
videosAddLegacyValidator,
videosAddResumableInitValidator,
- videosAddResumableValidator,
- videosResumableUploadIdValidator
+ videosAddResumableValidator
} from '../../../middlewares'
import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
import { VideoModel } from '../../../models/video/video'
const reqVideoFileAdd = createReqFiles(
[ 'videofile', 'thumbnailfile', 'previewfile' ],
- Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT),
- {
- videofile: CONFIG.STORAGE.TMP_DIR,
- thumbnailfile: CONFIG.STORAGE.TMP_DIR,
- previewfile: CONFIG.STORAGE.TMP_DIR
- }
+ { ...MIMETYPES.VIDEO.MIMETYPE_EXT, ...MIMETYPES.IMAGE.MIMETYPE_EXT }
)
const reqVideoFileAddResumable = createReqFiles(
[ 'thumbnailfile', 'previewfile' ],
MIMETYPES.IMAGE.MIMETYPE_EXT,
- {
- thumbnailfile: getResumableUploadPath(),
- previewfile: getResumableUploadPath()
- }
+ getResumableUploadPath()
)
uploadRouter.post('/upload',
uploadRouter.delete('/upload-resumable',
authenticate,
- videosResumableUploadIdValidator,
asyncMiddleware(deleteUploadResumableCache),
uploadx.upload
)
uploadRouter.put('/upload-resumable',
openapiOperationDoc({ operationId: 'uploadResumable' }),
authenticate,
- videosResumableUploadIdValidator,
uploadx.upload, // uploadx doesn't next() before the file upload completes
asyncMiddleware(videosAddResumableValidator),
asyncMiddleware(addVideoResumable)
extname: getLowercaseExtension(videoPhysicalFile.filename),
size: videoPhysicalFile.size,
videoStreamingPlaylistId: null,
- metadata: await getMetadataFromFile(videoPhysicalFile.path)
+ metadata: await buildFileMetadata(videoPhysicalFile.path)
})
const probe = await ffprobePromise(videoPhysicalFile.path)
if (await isAudioFile(videoPhysicalFile.path, probe)) {
videoFile.resolution = VideoResolution.H_NOVIDEO
} else {
- videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path, probe)
- videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path, probe)).resolution
+ videoFile.fps = await getVideoStreamFPS(videoPhysicalFile.path, probe)
+ videoFile.resolution = (await getVideoStreamDimensionsInfo(videoPhysicalFile.path, probe)).resolution
}
videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname)