if (!videoFile || !fontFile) {
console.error('Please select a video file and a font file.');
return;
}
const videoPath = URL.createObjectURL(videoFile);
const outputPath = '/path/to/output/video.mp4';
const text = 'Your text here';
const timeInSeconds = 10; // Add text at 10 seconds mark
addTextAtTime(videoFile, fontFile, outputPath, text, timeInSeconds)
.then((outputUrl) => {
console.log('Text added successfully at the specified time.');
// Use the outputUrl as needed (e.g., display the video in a <video> element)
})
.catch((error) => {
console.error('Error adding text:', error);
});
};
return (
);
};
export default VideoTextEditor;
this is my code in react and i am getting the above error again and again in ffmpeg.
whyyy????
any help....
import React, { useRef } from 'react'; import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg/dist/ffmpeg.min.js';
const VideoTextEditor = () => { const videoFileRef = useRef(null); const fontFileRef = useRef(null);
const addTextAtTime = async (videoFile, fontFile, outputPath, text, timeInSeconds) => { const ffmpegInstance = createFFmpeg({ log: true }); await ffmpegInstance.load(); return new Promise(async(resolve, reject) => { ffmpegInstance.FS('writeFile', 'input.mp4', new Uint8Array(videoFile, 0, videoFile.byteLength)); ffmpegInstance.FS('writeFile', 'font.ttf', new Uint8Array(fontFile, 0, fontFile.byteLength));
};
const handleAddText = () => { const videoFile = videoFileRef.current.files[0]; const fontFile = fontFileRef.current.files[0];
};
return (
); };
export default VideoTextEditor;
this is my code in react and i am getting the above error again and again in ffmpeg. whyyy???? any help....