【问题标题】:How to load GIF continuously on video in android using FFMPEG?如何使用 FFMPEG 在 android 中的视频上连续加载 GIF?
【发布时间】:2020-05-02 23:40:43
【问题描述】:

我试过这个命令来解决上述问题,但只加载一次不在循环中的 GIF,

"-y", "-i", inputvideopath, "-i", inputgifpath, "-filter_complex", "[1:v]scale=1080:720[ovrl];[0:v][ovrl]overlay=0:0", "-frames:v", "600", "-codec:a", "copy", "-codec:v", "libx264", "-preset", "ultrafast", finalvideoPath

我也尝试过使用 {"-ignore_loop", "0"},但视频不是在准确的时间创建的,它会用额外的时间创建,而且 GIF 也会连续循环。

"-y", "-i", inputvideopath, "-ignore_loop", "0", "-i", inputgifpath, "-filter_complex", "[1:v]scale=1080:720[ovrl];[0:v][ovrl]overlay=0:0", "-frames:v", "600", "-codec:a", "copy", "-codec:v", "libx264", "-preset", "ultrafast", finalvideoPath

【问题讨论】:

  • 您好,请您尝试添加"-loop", "3" 命令而不是"-ignore_loop", "0",
  • 我已经尝试过这个“-loop”,“3”,但那不是创建视频并且会导致 ffmpeg 进程失败
  • 你的错误信息是什么?
  • 找不到选项循环和 ffmpeg 版本 n4.0-39-gda39990 版权所有 (c) 2000-2018 FFmpeg 开发人员使用 gcc 4.9.x (GCC) 20150123(预发行版)构建
  • 您在此处使用视频或 gif 作为输入?我可以看到 2 个输入路径

标签: android video gif android-ffmpeg


【解决方案1】:

试试这个命令

String commnad[] = {
    "-y"
    , "-i"
    , inputVideo
    , "-ss"
    , "0"
    , "-t"
    , videoLength
    , "-ignore_loop"
    , "0"
    , "-i"
    , gifPath
    , "-filter_complex"
    , "[1:v]format=yuva444p,rotate=" + gifRotation + "*PI/180:c=none:ow=rotw(" + gifRotation + "*PI/180):oh=roth(" + gifRotation + "*PI/180),scale=h=" + gifHeight + ":w=" + gifWidth + ":[overlay_scaled],[0:v][overlay_scaled]overlay=eval=init:x=" + gifXPositionOnVideo  + ":y=" + gifYPositionOnVideo
    , "-frames:v"
    , "900"
    , "-codec:a"
    , "copy"
    , "-codec:v"
    , "libx264",
    outputVideo

};

如果您不想旋转 gif,请将“filter_complex”之后的行替换为

"[1:v]format=yuva444p,scale=h=" + gifHeight + ":w=" + ifWidth + ":[overlay_scaled],[0:v][overlay_scaled]overlay=eval=init:x=" + gifXPositionOnVideo  + ":y=" + gifYPositionOnVideo

这对我来说非常适合无限 gif 播放(直到视频结束)和视频上 gif 的特定位置

希望这对你也有用:)

【讨论】:

    猜你喜欢
    • 2018-11-19
    • 2020-11-21
    • 2021-08-16
    • 2014-12-16
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    • 2014-10-10
    • 2020-01-30
    相关资源
    最近更新 更多