const strFile = `http://localhost:8080/public/srtFiles/nombreArchivo.srt`
const localSubtitleFilePath = path.join(__dirname, 'nombreArchivo.srt');
axios.get(strFile, { responseType: 'arraybuffer' })
.then(response => {
fs.writeFileSync(localSubtitleFilePath, Buffer.from(response.data));
const outputFilePath = path.join(__dirname, '../../../public/videosSubtitled', `${videoName}`);
console.log('Subtitle File Path:', localSubtitleFilePath);
console.log('Output File Path:', outputFilePath);
exec(`ffmpeg -i ${tempFilePath} -vf subtitles=${localSubtitleFilePath} ${outputFilePath}`, function(error, stdout, stderr) {
if (error) {
console.log(error);
console.log(stdout);
console.log(stderr);
console.log("❌ Something went wrong!");
res.status(500).json({ success: false, message: 'Error al crear el video subtitulado' });
} else {
fs.unlinkSync(tempFilePath);
fs.unlinkSync(localSubtitleFilePath);
console.log("Done! ");
}
});
})
.catch(error => {
console.log("Error downloading subtitle file:", error);
res.status(500).json({ success: false, message: 'Error al descargar el archivo de subtítulos' });
});
Hi, I'm trying to add subtitles to a video with ffmpeg in a NodeJS app, but I have this error: [Parsed_subtitles_0 @ 0000024140111580] Unable to parse option value xxx.srt as image size Error applying option 'original_size' to filter 'subtitles': Invalid argument
I have tried to send the srt file by a public url and by a local file, but I have also a mistake.