如何使用FFMPEG覆盖XSTACK MOSAICS上的波形并指定播放的特定音频

发布于 2025-01-25 05:49:10 字数 2235 浏览 1 评论 0原文

我想制作一个标题为“流”的镶嵌物,1)指定要播放的音频流以及2)在每个视频瓷砖底部的覆盖波形,以供其所属的音频。

我成功地使用了以下代码来创建标题为“流媒体”。

但是:

  1. 我很难弄清楚如何仅指定特定音频源之一。 不想混合它们,我只想指定音频[A0],[A1]或[A2]等

我找到了Amix,但我真的

  1. 。每个瓷砖的视频底部形成波浪。我努力地试图弄清楚将表演波打入组合中。是否可以?

我希望每个瓷砖看起来都这样,但是由于这些是RTMP流,因此他们需要在每个流中动态播放匹配的波形。 https://dragonquest64.blogspot.com/2020/2020/01/501/501/ffmpeg--peg-peg- Audio-Waveform.html

如果有人可以将我指向正确的方向,那就太好了。我已经接近了,但是我对所有这些都非常新手,并且已经花费的时间比我应该拥有的更多,因此会喜欢一点帮助。

ffmpeg \
-i rtmp://my.cdn.com/srcEncoders/STREAM-1 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-2 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-3 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-4 \
  -filter_complex " \
      [0:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-1:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a0]; \
      [1:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-2:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a1]; \
      [2:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-3:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a2]; \
      [3:v] setpts=PTS-STARTPTS, scale=qvga \ 
    , drawtext=text=STREAM-4:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a3]; \
      [a0][a1][a2][a3]xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0[out]; \
    amix=inputs=1
      " \
  -map "[out]" \
 -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast -f mpegts "udp://127.0.0.1:1234?pkt_size=1316"

I would like to make a mosaic of multiple titled streams, 1) specifying which of the audio streams to play and 2) overlay waveforms at the bottom of each of the video tiles for the audio that they belong to.

I'm successfully able to create the titled mosaic of streams with the code below.

However:

  1. I'm having a hard time figuring out how to specify just one of the specific audio sources. I found amix, but I don't really want to mix them, I just want to specify audio [a0], or [a1], or [a2], etc.

and

  1. I'm having a hard time figuring out how to overlay the wave forms at the bottom of the video for each of the tiles. I struggled trying to figure out putting showwaves into the mix. Is it possible?

I want each tile to look like this, but since these are rtmp streams, they need to play-out the matching waveforms dynamically with each stream. https://dragonquest64.blogspot.com/2020/01/ffmpeg-audio-waveform.html

If someone could point me in the right direction, that would be great. I'm getting close, but I'm pretty new to all of this, and have already spent way more time than I should have, so would love a little help.

ffmpeg \
-i rtmp://my.cdn.com/srcEncoders/STREAM-1 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-2 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-3 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-4 \
  -filter_complex " \
      [0:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-1:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a0]; \
      [1:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-2:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a1]; \
      [2:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-3:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a2]; \
      [3:v] setpts=PTS-STARTPTS, scale=qvga \ 
    , drawtext=text=STREAM-4:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a3]; \
      [a0][a1][a2][a3]xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0[out]; \
    amix=inputs=1
      " \
  -map "[out]" \
 -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast -f mpegts "udp://127.0.0.1:1234?pkt_size=1316"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沒落の蓅哖 2025-02-01 05:49:10
  1. 仅指定特定音频流之一:只需使用另一个-map选项,就像使用视频流一样指定音频流。

  2. 放入showwaves进入混合物:您需要每个音频输入的单独过滤链。

以下是命令的粗略草图:

ffmpeg \
-i rtmp://my.cdn.com/srcEncoders/STREAM-1 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-2 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-3 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-4 \
  -filter_complex " \
      [0:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-1:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a0]; \
      [0:a] showwaves=r=fps:s=wxh[a0w];
      [1:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-2:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a1]; \
      [1:a] showwaves=r=fps:s=wxh[a1w];\
      [2:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-3:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a2]; \
      [2:a] showwaves=r=fps:s=wxh[a2w];\
      [3:v] setpts=PTS-STARTPTS, scale=qvga \ 
    , drawtext=text=STREAM-4:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a3]; \
      [3:a]showwaves=r=fps:s=wxh[a3w];\
      [a0][a0w][a1][a1w][a2][a2w][a3][a3w][a3w]\
        xstack=inputs=8:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2|0_h0+h1+h2+h3|w0_0|w0_h0|w0_h0+h1|w0_h0+h1+h2|w0_h0+h1+h2+h3[out]" \
  -map [out] -map 0:a \
 -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast -f mpegts "udp://127.0.0.1:1234?pkt_size=1316"

将framerate r和frameize s showwaves的选项 expoction 过滤器。

对于音频,我只是使用了第一个输入,请从0:a 更改流说明符以选择另一个输入

  1. Specifying just one of the specific audio stream: Just use another -map option to specify an audio stream just as you are doing with the video stream.

  2. Putting showwaves into the mix: You need a separate filterchain for each of audio inputs.

Below is a rough sketch of the command:

ffmpeg \
-i rtmp://my.cdn.com/srcEncoders/STREAM-1 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-2 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-3 \
-i rtmp://my.cdn.com/srcEncoders/STREAM-4 \
  -filter_complex " \
      [0:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-1:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a0]; \
      [0:a] showwaves=r=fps:s=wxh[a0w];
      [1:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-2:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a1]; \
      [1:a] showwaves=r=fps:s=wxh[a1w];\
      [2:v] setpts=PTS-STARTPTS, scale=qvga \
    , drawtext=text=STREAM-3:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a2]; \
      [2:a] showwaves=r=fps:s=wxh[a2w];\
      [3:v] setpts=PTS-STARTPTS, scale=qvga \ 
    , drawtext=text=STREAM-4:fontsize=20:x=10:y=10:fontcolor=white:box=1:[email protected]:boxborderw=5 [a3]; \
      [3:a]showwaves=r=fps:s=wxh[a3w];\
      [a0][a0w][a1][a1w][a2][a2w][a3][a3w][a3w]\
        xstack=inputs=8:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2|0_h0+h1+h2+h3|w0_0|w0_h0|w0_h0+h1|w0_h0+h1+h2|w0_h0+h1+h2+h3[out]" \
  -map [out] -map 0:a \
 -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast -f mpegts "udp://127.0.0.1:1234?pkt_size=1316"

Set the framerate r and framesize s options of showwaves filters to your liking.

For the audio, I just used the first input's, change the stream specifier from 0:a to select another input

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文