【发布时间】:2018-11-22 04:50:03
【问题描述】:
我正在尝试从 .mp3 音频和 .jpeg 图像创建视频 .mp4 文件。
我能够创建视频并在 Android 设备上的视频播放器中播放。
但是在创建文件后,当我尝试在 WhatsApp 中分享该视频时,它会显示一条消息“不支持文件格式”。
我正在使用以下 FFMPEG 命令:
"-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);
为了分享视频,我使用下面列出的代码:
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"));
}
});
我发现here 我需要使用 H.264 + AAC。 但我仍然无法分享支持文件格式的视频。
【问题讨论】:
-
你用什么将图像转换为视频?
-
我只使用 FFMPEG 来结合图像 + 音频来获得视频 [.mp4] 输出。 @AndroidUser
-
@NeelMevada 你能分享你创建的 mp4 文件吗?
-
@NeelMevada 另一个问题,你为什么不设置 shareIntent.setType("video/mp4");用于 mp4 文件?
-
@incBrain 感谢您的支持。在此命令中使用 AAC 音频编解码器已解决此问题。现在我正在使用 -c:a aac 并且运行良好。
标签: android video android-ffmpeg