<p>One method is to use the <a href="https://ffmpeg.org/ffmpeg-filters.html#concat" rel="nofollow noreferrer">concat</a> filter:</p>

<pre><code>ffmpeg -framerate 25 -loop 1 -t 5 -i image.png -i video.mp4 -f lavfi -t 0.1 -i anullsrc -filter_complex "[0][2][1:v][1:a][0][2]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4
</code></pre>

<ul>
<li><p>The <a href="https://ffmpeg.org/ffmpeg-filters.html#anullsrc" rel="nofollow noreferrer">anullsrc</a> filter generates silent audio as filler for proper concatenation. The concat filter will automatically pad the silent audio, so you only need a very short duration for anullsrc (this example uses <code>-t 0.1</code>).</p></li>
<li><p>This assumes your image is the same width, height, and aspect ratio as <code>video.mp4</code>. If it is not then you'll have to filter the image to match with the <a href="https://ffmpeg.org/ffmpeg-filters.html#scale" rel="nofollow noreferrer">scale</a>, <a href="https://ffmpeg.org/ffmpeg-filters.html#pad" rel="nofollow noreferrer">pad</a>, <a href="https://ffmpeg.org/ffmpeg-filters.html#crop" rel="nofollow noreferrer">crop</a>, or <a href="https://ffmpeg.org/ffmpeg-filters.html#scale2ref" rel="nofollow noreferrer">scale2ref</a> filters. There are plenty of example of how to do this on Stack Exchange.</p></li>
<li><p>You didn't provide any info on your inputs or <code>ffmpeg</code> build so I only provided this basic example.</p></li>
<li><p>An alternative method is to use the <a href="https://ffmpeg.org/ffmpeg-formats.html#concat" rel="nofollow noreferrer">concat demuxer</a> which can avoid re-encoding <code>video.mp4</code>, but it can be somewhat harder to use because you'll have to make the video from the image first and made sure all of the parameters are the same as <code>video.mp4</code>. See the <a href="https://trac.ffmpeg.org/wiki/Concatenate" rel="nofollow noreferrer">FFmpeg Wiki</a>, and again search Stack Exchange for dozens of examples.</p></li>
</ul>

CC BY-SA 4.0
2019-01-03T20:14:19.413Z
2019-01-03T20:14:19.413Z
llogan
<p>Here is basically what I'm trying to do.</p>

<p>I have two files : 1. image.png 2. video.mp4</p>

<p>I'm trying to create a new video file (mp4) with :</p>

<p>IMAGE.PNG for the first 5 seconds</p>

<p>VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)</p>

<p>IMAGE.PNG for 5 seconds</p>

<p>is it possible in FFMPEG?</p>

<p>thanks a lot !</p>

<video><ffmpeg>
Add image as intro and outro to video
gourav sarswa
# Add image as intro and outro to video

(Asked by: username_0 on 2019-01-03)

Here is basically what I'm trying to do.

I have two files : 1. image.png 2. video.mp4

I'm trying to create a new video file (mp4) with :

IMAGE.PNG for the first 5 seconds

VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)

IMAGE.PNG for 5 seconds

is it possible in FFMPEG?

thanks a lot !

**Tags:** video, ffmpeg


---

## 1 answers

### Answer by username_1 on 2019-01-03. Score: 4

One method is to use the concat filter:
ffmpeg -framerate 25 -loop 1 -t 5 -i image.png -i video.mp4 -f lavfi -t 0.1 -i anullsrc -filter_complex "[0][2][1:v][1:a][0][2]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4


The anullsrc filter generates silent audio as filler for proper concatenation. The concat filter will automatically pad the silent audio, so you only need a very short duration for anullsrc (this example uses -t 0.1).
This assumes your image is the same width, height, and aspect ratio as video.mp4. If it is not then you'll have to filter the image to match with the scale, pad, crop, or scale2ref filters. There are plenty of example of how to do this on Stack Exchange.
You didn't provide any info on your inputs or ffmpeg build so I only provided this basic example.
An alternative method is to use the concat demuxer which can avoid re-encoding video.mp4, but it can be somewhat harder to use because you'll have to make the video from the image first and made sure all of the parameters are the same as video.mp4. See the FFmpeg Wiki, and again search Stack Exchange for dozens of examples.


---

