使用ffmpeg android在视频上叠加图像

标签 image video ffmpeg overlay

我正在尝试使用 ffmpeg 库在视频上添加图像叠加,但没有成功。

我尝试使用 ffmpeg 示例,https://drive.google.com/file/d/0B2aT0QoEmtuaN0VJZ2Z4ODY3T2s/view

并将此链接也称为在视频上叠加图像,http://ksloan.net/watermarking-videos-from-the-command-line-using-ffmpeg-filters/#comment-9793但得到错误。

以下是我的 logcat 错误供引用:

07-31 10:23:43.406 29517-29517/com.examples.ffmpeg4android_demo D/ffmpeg4android:/storage/emulated/0/videokit/in.mp4 字节长度:840896
07-31 10:23:43.432 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: doInBackground 开始...
07-31 10:23:43.432 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: vk 已删除: false
07-31 10:23:43.434 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: 获取唤醒锁
07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: =======运行第一个命令=========
07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: 运行 ffmpeg4android_lib: 322.00.02_LM322
07-31 10:23:43.479 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android: {"ffmpeg","-y","-loop","1","-i","/sdcard/videokit/logo.png","-i","/sdcard/videokit/in.mp4","-y","-filter_complex","overlay=0:0:shortest=1","/sdcard/videokit/out.m4v"}
07-31 10:23:43.485 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android:/sdcard/videokit/logo.png 字节长度:6047
07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo D/ffmpeg4android:/sdcard/videokit/in.mp4 字节长度:840896
07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android: videokitLibPath 退出
07-31 10:23:43.486 29517-30185/com.examples.ffmpeg4android_demo I/ffmpeg4android:/data/user/0/com.examples.ffmpeg4android_demo/lib/libvideokit.so
07-31 10:23:43.493 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: libvideokit.so 加载
07-31 10:23:43.493 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: args 不为 NULL
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: 不止一个参数
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: 找到函数符号
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: 调用 videokit 通过加载器运行
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit:调用 licenseCheckComplex
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit: isLicExistsComplex...
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo I/Videokit:您使用了 15 个试用天中的 1 个。
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: 许可证检查 rc: 0
07-31 10:23:43.494 29517-30185/com.examples.ffmpeg4android_demo D/Videokit: ffmpeg4android base 2.5

                                                                        --------- beginning of crash

07-31 10:23:43.584 29517-30185/com.examples.ffmpeg4android_demo A/libc:致命信号 11 (SIGSEGV),代码 1,tid 30185 (AsyncTask #1) 中的故障地址 0x0
07-31 10:23:44.432 29517-29517/com.examples.ffmpeg4android_demo I/Choreographer:跳过了 44 帧!应用程序可能在其主线程上做了太多工作。

最佳答案

您可以使用 ffmpeg Android 包装器和常规 ffmpeg 命令行语法(得到很好的支持和记录)来实现这一点 - 请记住,移动设备上的视频处理是一个重度 CPU 用户,因此可能比您想要的慢并且还可能影响电池使用。

以下是一个得到很好支持的 ffmpeg 包装器:

  • https://github.com/WritingMinds/ffmpeg-android-java

  • 您可以使用 ffmpeg 使用如下命令添加图像:

    ffmpeg -i inputVideo.mp4 -i yourImage.png -filter_complex "overlay=5:5" -codec:a copy outputVideo.mp4
    

    有关放置图像的更多示例,请参见此答案 - 即左上角、右下角等:https://stackoverflow.com/a/10920872/334402

    关于使用ffmpeg android在视频上叠加图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45399230/

    相关文章:

    html - 如何强制 <img> 占用宽度,即使未加载图像

    javascript - 使用 HTML5 canvas 和 getImageData 的透明像素?

    带有 Image 列的 SQL SELECT 语句速度缓慢

    video - 如何将视频特征从 CNN 传递到 LSTM?

    linux - 如何使用文本文件中的给定参数对文本文件中的每一行重复一个命令(Bash?)

    java - 图标图像 "error java.lang.NullPointerException"

    c++ - 如何使用 VideoWriter 从 OpenCV 打开 GStreamer 管道

    ios - Quickblox 使用 QBRTCRemoteVideoView 填充完整视频

    python - 电影Py错误: FFMPEG permission error

    python-3.x - ffmpy.FFExecutableNotFoundError : Executable 'ffmpeg' not found?