Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix adding studio watermark

Chocobozzz70871e4d4f18
diff --git a/packages/ffmpeg/src/ffmpeg-edition.ts b/packages/ffmpeg/src/ffmpeg-edition.ts
index 510533bb4b..89de5c493d 100644
--- a/packages/ffmpeg/src/ffmpeg-edition.ts
+++ b/packages/ffmpeg/src/ffmpeg-edition.ts
@@ -22,10 +22,12 @@ export class FFmpegEdition {
this.commandWrapper = new FFmpegCommandWrapper(options)
}
- async cutVideo (options: BaseStudioOptions & {
- start?: number
- end?: number
- }) {
+ async cutVideo (
+ options: BaseStudioOptions & {
+ start?: number
+ end?: number
+ }
+ ) {
const { videoInputPath, separatedAudioInputPath, outputPath, inputFileMutexReleaser } = options
const mainProbe = await ffprobePromise(videoInputPath)
@@ -59,20 +61,22 @@ export class FFmpegEdition {
await this.commandWrapper.runCommand()
}
- async addWatermark (options: BaseStudioOptions & {
- watermarkPath: string
+ async addWatermark (
+ options: BaseStudioOptions & {
+ watermarkPath: string
- videoFilters: {
- watermarkSizeRatio: number
- horitonzalMarginRatio: number
- verticalMarginRatio: number
+ videoFilters: {
+ watermarkSizeRatio: number
+ horitonzalMarginRatio: number
+ verticalMarginRatio: number
+ }
}
- }) {
+ ) {
const { watermarkPath, videoInputPath, separatedAudioInputPath, outputPath, videoFilters, inputFileMutexReleaser } = options
const videoProbe = await ffprobePromise(videoInputPath)
const fps = await getVideoStreamFPS(videoInputPath, videoProbe)
- const { resolution } = await getVideoStreamDimensionsInfo(videoInputPath, videoProbe)
+ const { resolution, height } = await getVideoStreamDimensionsInfo(videoInputPath, videoProbe)
const command = this.commandWrapper.buildCommand([ ...this.buildInputs(options), watermarkPath ], inputFileMutexReleaser)
.output(outputPath)
@@ -90,20 +94,25 @@ export class FFmpegEdition {
canCopyVideo: false
})
+ const videoInput = 0
+ const imageInput = separatedAudioInputPath
+ ? 2
+ : 1
+
const complexFilter: FilterSpecification[] = [
// Scale watermark
{
- inputs: [ '[1]', '[0]' ],
- filter: 'scale2ref',
+ inputs: [ `[${imageInput}]` ],
+ filter: 'scale',
options: {
- w: 'oh*mdar',
- h: `ih*${videoFilters.watermarkSizeRatio}`
+ w: '-1',
+ h: `${height * videoFilters.watermarkSizeRatio}`
},
- outputs: [ '[watermark]', '[video]' ]
+ outputs: [ '[watermark]' ]
},
{
- inputs: [ '[video]', '[watermark]' ],
+ inputs: [ `[${videoInput}]`, '[watermark]' ],
filter: 'overlay',
options: {
x: `main_w - overlay_w - (main_h * ${videoFilters.horitonzalMarginRatio})`,
@@ -117,11 +126,13 @@ export class FFmpegEdition {
await this.commandWrapper.runCommand()
}
- async addIntroOutro (options: BaseStudioOptions & {
- introOutroPath: string
+ async addIntroOutro (
+ options: BaseStudioOptions & {
+ introOutroPath: string
- type: 'intro' | 'outro'
- }) {
+ type: 'intro' | 'outro'
+ }
+ ) {
const { introOutroPath, videoInputPath, separatedAudioInputPath, outputPath, type, inputFileMutexReleaser } = options
const mainProbe = await ffprobePromise(videoInputPath)
diff --git a/packages/tests/src/api/transcoding/video-studio.ts b/packages/tests/src/api/transcoding/video-studio.ts
index ba6084f1d7..fe59308b12 100644
--- a/packages/tests/src/api/transcoding/video-studio.ts
+++ b/packages/tests/src/api/transcoding/video-studio.ts
@@ -50,7 +50,6 @@ describe('Test video studio', function () {
function runCommonTests () {
describe('Cutting', function () {
-
it('Should cut the beginning of the video', async function () {
this.timeout(120_000)
@@ -116,9 +115,10 @@ describe('Test video studio', function () {
it('Should cut start/end of the audio', async function () {
this.timeout(120_000)
+ await servers[0].config.save()
await servers[0].config.enableMinimumTranscoding({ splitAudioAndVideo: true })
await renewVideo('video_short1.webm')
- await servers[0].config.enableMinimumTranscoding()
+ await servers[0].config.rollback()
const video = await servers[0].videos.get({ id: videoUUID })
for (const file of video.files) {
@@ -150,7 +150,6 @@ describe('Test video studio', function () {
})
describe('Intro/Outro', function () {
-
it('Should add an intro', async function () {
this.timeout(120_000)
await renewVideo()
@@ -268,7 +267,6 @@ describe('Test video studio', function () {
})
describe('Watermark', function () {
-
it('Should add a watermark to the video', async function () {
this.timeout(120_000)
await renewVideo()
@@ -298,7 +296,6 @@ describe('Test video studio', function () {
}
describe('Web videos enabled', function () {
-
it('Should run a complex task', async function () {
this.timeout(240_000)
await renewVideo()
@@ -312,7 +309,6 @@ describe('Test video studio', function () {
})
describe('HLS only studio edition', function () {
-
before(async function () {
await servers[0].config.enableMinimumTranscoding({ webVideo: false, hls: true })
})
@@ -337,7 +333,6 @@ describe('Test video studio', function () {
})
describe('HLS with splitted audio studio edition', function () {
-
before(async function () {
await servers[0].config.enableMinimumTranscoding({ webVideo: false, hls: true, splitAudioAndVideo: true })
})
@@ -362,7 +357,6 @@ describe('Test video studio', function () {
})
describe('Server restart', function () {
-
it('Should still be able to run video edition after a server restart', async function () {
this.timeout(240_000)