<p>It's possible. Use</p>

<pre><code>ffmpeg -loop 1 -i image.png -f lavfi -t 5 -i anullsrc -i video.mp4 -i music.wav \
-filter_complex "[0]trim=duration=5,fps=N[pre];[3]showwaves=WxH:r=N[b]; \
                 [b][0]overlay=shortest=1[post]; \
                 [pre][1:a][2:v][2:a][post][3]concat=n=3:v=1:a=1[v][a]" \
-map [v] -map [a] out.mp4
</code></pre>

<p>The image and video have to be of the same dimensions. If not, you should scale one of them, likely the image.</p>

<p>The fps filter should be set to the framerate of the video.</p>

<p>The <code>showwaves</code> is a kludge. Since the looped image stream does not terminate, I generate a video stream using <code>showwaves</code> from the audio, which will be of the same length as the WAV. <code>WxH</code> should be the same as the video, and <code>r</code> the same as the video's framerate.</p>

<p>Then the image is overlaid on top the filter is set to terminate when the waves video ends.</p>

<p>Finally, the concat filter assembles the full video.</p>

CC BY-SA 3.0
2016-05-04T18:19:44.373Z
2016-05-07T10:28:41.383Z
2016-05-07T10:28:41.383Z
Gyan
<p>Here is basically what I'm trying to do.</p>

<p>I have three files :
1. image.png
2. music.wav
3. video.mp4</p>

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

<ol>
<li>IMAGE.PNG for the first 5 seconds</li>
<li>VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)</li>
<li>IMAGE.PNG + MUSIC.WAV for the duration of MUSIC.WAV (example 60 seconds)</li>
</ol>

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

<p>and if yes, is it possible in one "go" meaning without creating several intermediate video files ?</p>

<p>thanks a lot !</p>

<video><ffmpeg>
FFMPEG - Add intro and outro to a video
Sewer
# FFMPEG - Add intro and outro to a video

(Asked by: username_0 on 2016-05-04)

Here is basically what I'm trying to do.

I have three files :
1. image.png
2. music.wav
3. video.mp4

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

1. IMAGE.PNG for the first 5 seconds
2. VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)
3. IMAGE.PNG + MUSIC.WAV for the duration of MUSIC.WAV (example 60 seconds)

is it possible in FFMPEG ?

and if yes, is it possible in one "go" meaning without creating several intermediate video files ?

thanks a lot !

**Tags:** video, ffmpeg


---

## 1 answers

### Answer by username_1 on 2016-05-04. Score: 2

It's possible. Use
ffmpeg -loop 1 -i image.png -f lavfi -t 5 -i anullsrc -i video.mp4 -i music.wav \
-filter_complex "[0]trim=duration=5,fps=N[pre];[3]showwaves=WxH:r=N[b]; \
                 [b][0]overlay=shortest=1[post]; \
                 [pre][1:a][2:v][2:a][post][3]concat=n=3:v=1:a=1[v][a]" \
-map [v] -map [a] out.mp4

The image and video have to be of the same dimensions. If not, you should scale one of them, likely the image.
The fps filter should be set to the framerate of the video.
The showwaves is a kludge. Since the looped image stream does not terminate, I generate a video stream using showwaves from the audio, which will be of the same length as the WAV. WxH should be the same as the video, and r the same as the video's framerate.
Then the image is overlaid on top the filter is set to terminate when the waves video ends.
Finally, the concat filter assembles the full video.


---

