i18n-labelText labelText="Allow additional extensions"
>
<ng-container ngProjectAs="description">
- <span i18n>Allows users to upload {{ additionalVideoExtensions }} videos.</span>
+ <span i18n>Allows users to upload videos with additional extensions than .mp4, .ogv and .webm (for example: .avi, .mov, .mkv etc).</span>
</ng-container>
</my-peertube-checkbox>
</div>
+import { truncate } from 'lodash-es'
import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx'
+import { isIOS } from 'src/assets/player/utils'
import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http'
import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
import { Router } from '@angular/router'
import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
import { UploaderXFormData } from './uploaderx-form-data'
import { VideoSend } from './video-send'
-import { isIOS } from 'src/assets/player/utils'
@Component({
selector: 'my-video-upload',
channelId: this.firstStepChannelId,
nsfw: this.serverConfig.instance.isNSFW,
privacy: this.highestPrivacy.toString(),
+ name: this.buildVideoFilename(file.name),
filename: file.name,
previewfile: previewfile as any
}
}
private closeFirstStep (filename: string) {
- const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '')
- const name = nameWithoutExtension.length < 3 ? filename : nameWithoutExtension
+ const name = this.buildVideoFilename(filename)
this.form.patchValue({
name,
return extensions.some(e => filename.endsWith(e))
}
+
+ private buildVideoFilename (filename: string) {
+ const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '')
+ let name = nameWithoutExtension.length < 3
+ ? filename
+ : nameWithoutExtension
+
+ const videoNameMaxSize = 110
+ if (name.length > videoNameMaxSize) {
+ name = truncate(name, { length: videoNameMaxSize, omission: '' })
+ }
+
+ return name
+ }
}
if (!handler) {
await moveToFailedTranscodingState(video)
+ await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
throw new Error('Cannot find transcoding handler for ' + payload.type)
}
} catch (error) {
await moveToFailedTranscodingState(video)
+ await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
+
throw error
}
return video
}
+// ---------------------------------------------------------------------------
+
+export {
+ processVideoTranscoding
+}
+
// ---------------------------------------------------------------------------
// Job handlers
// ---------------------------------------------------------------------------
logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
- await onVideoFileOptimizer(video, payload, 'video', user)
+ await onVideoFirstWebTorrentTranscoding(video, payload, 'video', user)
}
async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
- await onVideoFileOptimizer(video, payload, transcodeType, user)
+ await onVideoFirstWebTorrentTranscoding(video, payload, transcodeType, user)
}
// ---------------------------------------------------------------------------
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
}
-async function onVideoFileOptimizer (
+async function onVideoFirstWebTorrentTranscoding (
videoArg: MVideoWithFile,
payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload,
transcodeType: TranscodeOptionsType,
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
}
+// ---------------------------------------------------------------------------
+
async function createHlsJobIfEnabled (user: MUserId, payload: {
videoUUID: string
resolution: number
return true
}
-// ---------------------------------------------------------------------------
-
-export {
- processVideoTranscoding,
- createHlsJobIfEnabled,
- onNewWebTorrentFileResolution
-}
-
-// ---------------------------------------------------------------------------
-
async function createLowerResolutionsJobs (options: {
video: MVideoFullLight
user: MUserId
const videoFileMetadata = {
mimetype: req.headers['x-upload-content-type'] as string,
size: +req.headers['x-upload-content-length'],
- originalname: req.body.name
+ originalname: req.body.filename
}
const user = res.locals.oauth.token.User
import { AttributesOnly } from '@shared/core-utils'
import { VideoModel } from './video'
+export type VideoJobInfoColumnType = 'pendingMove' | 'pendingTranscode'
+
@Table({
tableName: 'videoJobInfo',
indexes: [
return VideoJobInfoModel.findOne({ where, transaction })
}
- static async increaseOrCreate (videoUUID: string, column: 'pendingMove' | 'pendingTranscode'): Promise<number> {
+ static async increaseOrCreate (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
return pendingMove
}
- static async decrease (videoUUID: string, column: 'pendingMove' | 'pendingTranscode'): Promise<number> {
+ static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`