【问题标题】:How to use -stream_loop audio in fluent-ffmpeg?如何在 fluent-ffmpeg 中使用 -stream_loop 音频?
【发布时间】:2020-04-14 04:30:00
【问题描述】:

我正在尝试循环播放音频以适应视频的大小。我使用 VIDEOSHOW 创建 VIDEO,videoshow 使用 fluent-ffmpeg。 我已经在命令行上拥有了完美运行的代码:

    `ffmpeg -y -r 1 -loop 1 -i image.png -stream_loop -1 -i audio.mp3 -c:a copy -r 1 
-shortest -c:v libx264 -t 60 -vf scale=1280:720 video.mp4

但我不知道如何将它与 node-fluent-ffmpeg 一起使用,这是我使用的代码:

 async function nodeFluentFfmpeg() {
    let image = [image.png]

    return new Promise((resolve, reject) => {

    const videoOptions = {
      fps: 30,
      loop: segundoVideo, // seconds
      transition: true,
      transitionDuration: 1, // seconds
      videoBitrate: 1024,
      videoCodec: "libx264",
      size: "1280x720",
      audioBitrate: "128k",
      audioChannels: 2,
      format: "mp4",
      pixelFormat: "yuv420p"
      }

    videoshow(image, videoOptions)
      .audio("audio.mp3","**-stream_loop -1 -c:a copy -r 1**")// **ERROR IS HERE**
      .save("video.mp4")
      .on("start", function(command) {
        console.log("Rendering : ", command);
      })
      .on("error", function(err, stdout, stderr) {
        console.error("Error:", err);
        console.error("ffmpeg stderr:", stderr);
      })
      .on("end", function(output) {
        console.error("Video created in:", output);
        resolve()
      });

    })

【问题讨论】:

    标签: ffmpeg fluent-ffmpeg


    【解决方案1】:

    您可以使用.inputOption(-stream_loop -1); 解决。

    【讨论】:

      猜你喜欢
      • 2019-05-23
      • 2018-01-03
      • 2023-04-06
      • 2020-10-03
      • 2012-09-05
      • 2017-03-26
      • 2020-12-04
      • 2015-08-16
      • 2017-12-07
      相关资源
      最近更新 更多