3

首先,我是 FFMPEG 的初学者,所以请多多包涵。

我正在使用这个库并成功地结合了音频和视频:D

但是,当我尝试在视频上插入图像/水印时,我一直失败。

这是我使用的代码:

public MediaDesc combineVideoAndImage (MediaDesc videoIn, MediaDesc image, MediaDesc out, ShellCallback sc) throws Exception
    {
        ArrayList<String> cmd = new ArrayList<String>();

        cmd.add(ffmpegBin);
        cmd.add("-i");
        cmd.add(new File(videoIn.path).getCanonicalPath());

        cmd.add("-vf");
        cmd.add("movie=" + new File(image.path).getAbsolutePath() + " [logo];[in][logo] overlay=10:10 [out]");

        cmd.add("-strict");
        cmd.add("-2");

        File fileOut = new File(out.path);
        cmd.add(fileOut.getCanonicalPath());

        execFFMPEG(cmd, sc);

        return out;
    }

这些代码将生成这个 cmd :

ffmpeg -i VIDEONAME.mp4 -vf "movie=LOGONAME.png [logo];[in][logo] overlay=10:10 [out]"
-strict -2 OUTPUTNAME.MP4

我已经在 ubuntu 13.10 64bit 上测试了这个 CMD,安装了最新的 FFMPEG 并且成功了。

但它不在我的android项目中。它不会捕获/抛出任何错误/异常,程序正常运行并且文件已创建但其中没有任何内容(0 字节)

任何帮助表示赞赏。感谢您的帮助:D

4

1 回答 1

0

尝试使用以下命令

ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=10:10" -codec:a copy output.mp4

我已经在 android 上对其进行了测试,并且运行良好。

于 2016-07-29T10:44:59.673 回答