jbilcke-hf HF staff commited on
Commit
9bf9d23
·
1 Parent(s): 5c62d38

try to fix the text overlay bug

Browse files
src/bug-in-bun/aitube_ffmpeg/overlay/addImageToVideo.ts CHANGED
@@ -8,12 +8,16 @@ import { getRandomDirectory } from "@aitube/io"
8
  type AddImageToVideoParams = {
9
  inputVideoPath: string;
10
  inputImagePath: string;
 
 
11
  outputVideoPath?: string;
12
  };
13
 
14
  export async function addImageToVideo({
15
  inputVideoPath,
16
  inputImagePath,
 
 
17
  outputVideoPath,
18
  }: AddImageToVideoParams): Promise<string> {
19
  // Verify that the input files exist
@@ -35,9 +39,10 @@ export async function addImageToVideo({
35
  ffmpeg(inputVideoPath)
36
  .input(inputImagePath)
37
  .complexFilter([
 
38
  {
39
- filter: "overlay",
40
- options: { x: "0", y: "0" }, // Overlay on the entire video frame
41
  }
42
  ])
43
  .on("error", (err) => {
 
8
  type AddImageToVideoParams = {
9
  inputVideoPath: string;
10
  inputImagePath: string;
11
+ width: number
12
+ height: number
13
  outputVideoPath?: string;
14
  };
15
 
16
  export async function addImageToVideo({
17
  inputVideoPath,
18
  inputImagePath,
19
+ width,
20
+ height,
21
  outputVideoPath,
22
  }: AddImageToVideoParams): Promise<string> {
23
  // Verify that the input files exist
 
39
  ffmpeg(inputVideoPath)
40
  .input(inputImagePath)
41
  .complexFilter([
42
+ `scale=${width}:${height}`, // Scale video
43
  {
44
+ filter: 'overlay', // Overlay image on scaled video
45
+ options: { x: '0', y: '0' }
46
  }
47
  ])
48
  .on("error", (err) => {
src/bug-in-bun/aitube_ffmpeg/overlay/addTextToVideo.ts CHANGED
@@ -34,6 +34,8 @@ export async function addTextToVideo({
34
  await addImageToVideo({
35
  inputVideoPath,
36
  inputImagePath: temporaryImageOverlayFilePath,
 
 
37
  outputVideoPath,
38
  })
39
 
 
34
  await addImageToVideo({
35
  inputVideoPath,
36
  inputImagePath: temporaryImageOverlayFilePath,
37
+ width,
38
+ height,
39
  outputVideoPath,
40
  })
41
 
src/core/exporters/videoSegmentToVideoFile.ts CHANGED
@@ -4,7 +4,7 @@ import { ClapProject, ClapSegment, ClapSegmentCategory, ClapSegmentFilteringMode
4
  import { extractBase64 } from "@aitube/encoders"
5
  import { deleteFile, writeBase64ToFile } from "@aitube/io"
6
  // import { addTextToVideo, concatenateVideosWithAudio } from "@aitube/ffmpeg"
7
- import { addTextToVideo, concatenateVideosWithAudio } from "../../bug-in-bun/aitube_ffmpeg"
8
 
9
  export async function videoSegmentToVideoFile({
10
  clap,
 
4
  import { extractBase64 } from "@aitube/encoders"
5
  import { deleteFile, writeBase64ToFile } from "@aitube/io"
6
  // import { addTextToVideo, concatenateVideosWithAudio } from "@aitube/ffmpeg"
7
+ import { addTextToVideo, concatenateVideosWithAudio, scaleVideo } from "../../bug-in-bun/aitube_ffmpeg"
8
 
9
  export async function videoSegmentToVideoFile({
10
  clap,