I am working on an app where i first extract audio from a video, then transcribe it and then i wanna attach that transcribed captions or subtitles to the original video.
Everything is working smooth except the subtitles attaching part
if im running the FFMPEG command directly in terminal, it works fine but not in flutter
here is my code of attaching the subtitles to the video :
Future<void> attachCaptionsToVideo(DeepGramResponse deepGramResponse) async {
var tempDir = await getTemporaryDirectory();
final outputPath = "${tempDir.path}/outputWithCaptions.mp4";
final String subtitlePath = deepGramResponse.captionsPath
.replaceAll('\', '\\')
.replaceAll(' ', '\ ');
final String command =
'-y -i ${deepGramResponse.videoPath} -vf subtitles=$subtitlePath $outputPath';
await FFmpegKit.executeAsync(command, (session) async {
final returnCode = await session.getReturnCode();
final output = await session.getOutput();
final error = await session.getFailStackTrace();
log('FFmpeg command executed with return code: $returnCode');
if (ReturnCode.isSuccess(returnCode)) {
log('Captions attached successfully');
deepGramResponse.copyWith(
videoPath: outputPath,
);
Get.to(() => VideoPlayerScreen(videoPath: outputPath));
} else {
log('FFmpeg command failed');
log('Error output: $output');
log('Error details: $error');
Fluttertoast.showToast(
msg: 'Something went wrong, please try again later');
}
});
}
here is the error im getting :
[AVFilterGraph @ 0x7b8a3f35f0] No option name near
‘/data/user/0/com.example.blink/app_flutter/captions.srt’
[AVFilterGraph @ 0x7b8a3f35f0] Error parsing a filter description around:
[AVFilterGraph @ 0x7b8a3f35f0] Error parsing filterchain ‘subtitles=/data/user/0/com.example.blink/app_flutter/captions.srt’
around:
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!