- if (videoArg === undefined) return undefined
-
- // Outside the transaction (IO on disk)
- const { videoFileResolution, isPortraitMode } = await videoArg.getMaxQualityResolution()
-
- const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
- // Maybe the video changed in database, refresh it
- const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid, t)
- // Video does not exist anymore
- if (!videoDatabase) return undefined
-
- let videoPublished = false
-
- // Generate HLS version of the original file
- const originalFileHLSPayload = Object.assign({}, payload, {
- isPortraitMode,
- resolution: videoDatabase.getMaxQualityFile().resolution,
- // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues
- copyCodecs: transcodeType !== 'quick-transcode',
- isMaxQuality: true
- })
- const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload)
-
- const hasNewResolutions = await createLowerResolutionsJobs(videoDatabase, user, videoFileResolution, isPortraitMode, 'webtorrent')
-
- if (!hasHls && !hasNewResolutions) {
- // No transcoding to do, it's now published
- videoPublished = await videoDatabase.publishIfNeededAndSave(t)
- }
-
- await federateVideoIfNeeded(videoDatabase, payload.isNewVideo, t)
-
- return { videoDatabase, videoPublished }
+ const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
+
+ // Maybe the video changed in database, refresh it
+ const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid)
+ // Video does not exist anymore
+ if (!videoDatabase) return undefined
+
+ // Generate HLS version of the original file
+ const originalFileHLSPayload = {
+ ...payload,
+
+ isPortraitMode,
+ hasAudio: !!audioStream,
+ resolution: videoDatabase.getMaxQualityFile().resolution,
+ // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues
+ copyCodecs: transcodeType !== 'quick-transcode',
+ isMaxQuality: true
+ }
+ const hasHls = await createHlsJobIfEnabled(user, originalFileHLSPayload)
+ const hasNewResolutions = await createLowerResolutionsJobs({
+ video: videoDatabase,
+ user,
+ videoFileResolution: resolution,
+ hasAudio: !!audioStream,
+ isPortraitMode,
+ type: 'webtorrent',
+ isNewVideo: payload.isNewVideo ?? true