Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get some error while merging audio with image #983

Open
VirajEbiz opened this issue May 16, 2024 · 1 comment
Open

get some error while merging audio with image #983

VirajEbiz opened this issue May 16, 2024 · 1 comment

Comments

@VirajEbiz
Copy link

I want to merge audio with my image but After executing below code output file not playing properly like audio not playing properly
this is my code please check :-
final FlutterFFmpeg _flutterFFmpeg = FlutterFFmpeg();

Future mergeImageAndAudio(
String imagePath, String audioPath, String outputPath) async {
// Define the FFmpeg command
String command =
"-y -i $imagePath -i $audioPath -map 0:v -map 1:a -c:v copy "
"-shortest $outputPath";
// Execute the command
int rc = await _flutterFFmpeg.execute(command);
if (rc == 0) {
print("FFmpeg process completed successfully.");
} else {
print("FFmpeg process failed with return code $rc.");
}
}

Future createVideo(
{String? imagePathSelected, String? audioPathSelected}) async {
// Get the temporary directory of the device to save the output video
final Directory tempDir = await getTemporaryDirectory();
final String outputPath =
path.join(tempDir.path, '${DateTime.now().second}output.mp4');

print("Check Image Path ==> ${imagePathSelected}");
print("Check Image Path ==> ${audioPathSelected}");
// Paths to your image and audio files
String imagePath = imagePathSelected!; // Update with actual path
String audioPath = audioPathSelected!; // Update with actual path

await mergeImageAndAudio(imagePath, audioPath, outputPath);

print("Check Image Path ==> $outputPath");
Get.to(() => CapturedVideoPreview(videoURL: outputPath));

// Share.shareXFiles([XFile(outputPath)], text: 'Check out this video!');

}

in android devices I just able to here audio but it's also not proper and image not visible, for the iPhone i am able to see image but audio not playing properly

@merbin2012
Copy link

I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants