gpt4 book ai didi

android - 如何在 Android 中使用 FFMPEG 库将 Youtube 视频与 MP4 合并?

转载 作者:行者123 更新时间:2023-12-04 23:25:41 26 4
gpt4 key购买 nike

这是我的代码

private void executeAudioVideo() {
File moviesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
String filePrefix = "audio_video";
String fileExtn = ".mp4";

youtubeURL = "https://www.youtube.com/embed/oEKyXKL25FU";
videoPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/video.mp4";

File dest = new File(moviesDir, filePrefix + fileExtn);
int fileNo = 0;
while (dest.exists()) {
fileNo++;
dest = new File(moviesDir, filePrefix + fileNo + fileExtn);
}
filePath = dest.getAbsolutePath();

String[] command = new String[]{"-y", "-i", videoPath, "-i", youtubeURL, "-filter_complex", "[0:a][1:a]amerge=inputs=2[a]", "-map", "0:v", "-map", "[a]", "-c:v", "copy", "-c:a", "libvorbis", "-ac", "2", "-shortest", filePath};

Toast.makeText(this, filePath, Toast.LENGTH_SHORT).show();
execFFmpegBinary(command);
}

最佳答案

您可以使用以下库来实现此目的:FFmpeg-Android

这里有这个库的一个实现:KotlinFFMpeg

关于android - 如何在 Android 中使用 FFMPEG 库将 Youtube 视频与 MP4 合并?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49001342/

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