gpt4 book ai didi

android - FFMPEG 命令从图像 (JPEG) + 音频 (.mp3) 制作视频并在 Whatsapp 中分享视频

转载 作者:行者123 更新时间:2023-11-29 00:57:46 24 4
gpt4 key购买 nike

我正在尝试从 .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。 但我仍然无法分享支持文件格式的视频

最佳答案

正如评论中已经讨论的那样,由于 -c:a copymp3 音频文件上使用,因此音频未使用 AAC 编解码器编码而出现问题。

解决方案是告诉 ffmpeg 使用 -c:a aac 将音频流重新编码为 AAC。还可以找到有关如何对 AAC 进行编码的更多示例 here .

关于android - FFMPEG 命令从图像 (JPEG) + 音频 (.mp3) 制作视频并在 Whatsapp 中分享视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53424073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com