I am trying to create a video .mp4 file from .mp3 audio & .jpeg image.
I am able to create a video and able to play it in video players on Android devices.
But after creation of file when I tried to share that video in WhatsApp, at that time it shows a message "The file format not supported".
I am using below FFMPEG command:
"-loop 1 -r 1 -i " + imageFilePath + " -i " + audioFilePath + " -c:v libx264 -crf 27 -tune stillimage -c:a copy -pix_fmt yuv420p -preset ultrafast -shortest " + pathOutputVideo(sectionName);
And for sharing video, I am using code listed below:
MediaScannerConnection.scanFile(ShareQuestionAudioActivity.this, new String[]{FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))));
startActivity(Intent.createChooser(shareIntent, "Share Question"));
}
});
I foundhere that I need to use H.264 + AAC. But I'm still not able to share video with supported file format .
As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy
was used on mp3
audio files.
The solution to this is to tell ffmpeg
to re-encode audio stream to AAC using -c:a aac
. More examples on how to encode AAC can also be found here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.