<p>You can do something like this:</p>
<pre><code>ffmpeg
-i intro.mp4
-i rtmp://second-input-server:port/input-id
-filter_complex &quot;concat=n=2:v=1:a=1[merged_video][merged_audio]&quot;
-map [merged_video] -map [merged_audio] -f flv rtmp://final-output:port/merged
</code></pre>
<ul>
<li>We are taking two inputs, one from a local file (<code>intro.mp4</code>) and one using an rtmp address (<code>rtmp://second-input-server:port/input-id</code>).</li>
<li>We are using the <code>concat</code> filter here, specifying that it has 2 segments to concant (<code>n=2</code>), each segment having 1 video (<code>v=1</code>) and 1 audio stream (<code>a=1</code>).</li>
<li>We are labelling the concatted streams as <code>merged_video</code> and <code>merged_audio</code>, and muxing them into <code>flv</code> format, before sending that to the output rtmp server (<code>rtmp://final-output:port/merged</code>).</li>
</ul>
<p>This assumes that you have the two inputs having same number of streams (1 video and 1 audio), same frame rate, same dimensions etc. If you don't, you may need to add additional filters (e.g. <code>scale</code>, <code>fps</code>) and stream selectors (e.g. <code>[0:v:0]</code>, <code>[1:a:1]</code>) above to first make the two streams have the same characteristics, before feeding those to the <code>concat</code> filter.</p>

CC BY-SA 4.0
2021-06-17T03:06:29.927Z
2021-06-17T03:06:29.927Z
Syed Andaleeb Roomy
<p>I need a ffmpeg command to first feed a mp4 video into a RTMP output stream, then followed by a RTMP input subsequently; what should be the parameters to get it working?</p>

<ffmpeg><mp4><rtmp>
Combine mp4 video and a RTMP stream into 1 RTMP output stream via ffmpeg
Jason Lin
# Combine mp4 video and a RTMP stream into 1 RTMP output stream via ffmpeg

(Asked by: username_0 on 2021-06-13)

I need a ffmpeg command to first feed a mp4 video into a RTMP output stream, then followed by a RTMP input subsequently; what should be the parameters to get it working?

**Tags:** ffmpeg, mp4, rtmp


---

## 1 answers

### Answer by username_1 on 2021-06-17. Score: 0

You can do something like this:
ffmpeg
-i intro.mp4
-i rtmp://second-input-server:port/input-id
-filter_complex "concat=n=2:v=1:a=1[merged_video][merged_audio]"
-map [merged_video] -map [merged_audio] -f flv rtmp://final-output:port/merged


We are taking two inputs, one from a local file (intro.mp4) and one using an rtmp address (rtmp://second-input-server:port/input-id).
We are using the concat filter here, specifying that it has 2 segments to concant (n=2), each segment having 1 video (v=1) and 1 audio stream (a=1).
We are labelling the concatted streams as merged_video and merged_audio, and muxing them into flv format, before sending that to the output rtmp server (rtmp://final-output:port/merged).

This assumes that you have the two inputs having same number of streams (1 video and 1 audio), same frame rate, same dimensions etc. If you don't, you may need to add additional filters (e.g. scale, fps) and stream selectors (e.g. [0:v:0], [1:a:1]) above to first make the two streams have the same characteristics, before feeding those to the concat filter.


---

