<p>Make videos from images:</p>

<pre><code>ffmpeg -loop 1 -framerate 24 -t 5 -i image0.png -loop 1 -framerate 24 -t 5 -i image1.jpg -loop 1 -framerate 24 -t 5 -i image2.jpg -f lavfi -i anullsrc=cl=stereo:r=44100 -filter_complex "[0]fade=t=in:duration=1,format=yuv420p[v0];[1]format=yuv420p[v1];[2]format=yuv420p[v2]" -map "[v0]" -map 3 -shortest pre1.mp4 -map "[v1]" -map 3 -shortest pre2.mp4 -map "[v2]" -map 3 -shortest post.mp4
</code></pre>

<p>Note that the frame rate, width, height, aspect ratio, pixel format, H.264 profile, timebase, audio channel layout, audio sample rate, stream types, and number of streams of these videos match that of the main video.</p>

<p>Make <code>input.txt</code>:</p>

<pre><code>file 'pre1.mp4'
file 'pre2.mp4'
file 'main.mp4'
file 'post.mp4'
</code></pre>

<p>Concatenate with <a href="https://ffmpeg.org/ffmpeg-formats.html#concat" rel="nofollow noreferrer">concat demuxer</a>:</p>

<pre><code>ffmpeg -f concat -i input.txt -c copy -movflags +faststart output.mp4 
</code></pre>

CC BY-SA 4.0
2020-03-10T22:00:11.027Z
2020-03-10T22:00:11.027Z
llogan
<p>I'm trying to make an operation using FFmpeg with just one command to leave the output as lossless as possible.</p>

<p>My intention is to add two images, 5 seconds each, before the mp4 file, add a fade in to the first one of 1 second and add a third image after the video during 5 seconds.</p>

<p>Is it possible to do this on one pass?</p>

<p>I found some bits of code, namely:</p>

<pre><code>ffmpeg -r 25 -loop 1 -t 5 -i "image" -i "video" -f lavfi -t 5 -i aevalsrc=0 \
   -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" \
   -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4 
</code></pre>

<p>and</p>

<pre><code>ffmpeg -i clip.mp4 -vf "fade=in:0:25" -acodec copy clip-out.mp4
</code></pre>

<p>But I'm not being able to use them together and I don't know if all those commands are really necessary. Any thoughts?</p>

CC BY-SA 4.0
2020-03-10T17:00:59.230Z
Is doing it in one command an absolute requirement? Otherwise you could make the beginning and end videos first, then concatenate them to the main video without needing to re-encode the main video. If this is acceptable then show the complete output of `ffmpeg -i video -i image1 -i image2 -i image3` to show important info about each input.
llogan
CC BY-SA 4.0
2020-03-10T21:31:44.910Z
Hi @llogan.
I just would like to avoid compressing the main video more than once to keep the best image possible, but it's not an absolute requirement.
The video and three images are 1920x1080.

`Video
 Encoder: Lavf58.18.104
 Duration: 00:01:36.48, start: 0.000000, bitrate: 4038 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3907 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)`
AntMadeira
<video><ffmpeg><editing>
Add two images before a mp4 and one in the end with ffmpeg
AntMadeira
# Add two images before a mp4 and one in the end with ffmpeg

(Asked by: username_0 on 2020-03-09)

I'm trying to make an operation using FFmpeg with just one command to leave the output as lossless as possible.
My intention is to add two images, 5 seconds each, before the mp4 file, add a fade in to the first one of 1 second and add a third image after the video during 5 seconds.
Is it possible to do this on one pass?
I found some bits of code, namely:
ffmpeg -r 25 -loop 1 -t 5 -i "image" -i "video" -f lavfi -t 5 -i aevalsrc=0 \
   -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" \
   -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4 

and
ffmpeg -i clip.mp4 -vf "fade=in:0:25" -acodec copy clip-out.mp4

But I'm not being able to use them together and I don't know if all those commands are really necessary. Any thoughts?

**Tags:** video, ffmpeg, editing

> **Comments:**
> **username_1**: Is doing it in one command an absolute requirement? Otherwise you could make the beginning and end videos first, then concatenate them to the main video without needing to re-encode the main video. If this is acceptable then show the complete output of `ffmpeg -i video -i image1 -i image2 -i image3` to show important info about each input.  
> **username_0**: Hi @username_1. I just would like to avoid compressing the main video more than once to keep the best image possible, but it's not an absolute requirement. The video and three images are 1920x1080.  `Video  Encoder: Lavf58.18.104  Duration: 00:01:36.48, start: 0.000000, bitrate: 4038 kb/s  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3907 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default) Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)`  

---

## 1 answers

### Answer by username_1 on 2020-03-10. Score: 0

Make videos from images:
ffmpeg -loop 1 -framerate 24 -t 5 -i image0.png -loop 1 -framerate 24 -t 5 -i image1.jpg -loop 1 -framerate 24 -t 5 -i image2.jpg -f lavfi -i anullsrc=cl=stereo:r=44100 -filter_complex "[0]fade=t=in:duration=1,format=yuv420p[v0];[1]format=yuv420p[v1];[2]format=yuv420p[v2]" -map "[v0]" -map 3 -shortest pre1.mp4 -map "[v1]" -map 3 -shortest pre2.mp4 -map "[v2]" -map 3 -shortest post.mp4

Note that the frame rate, width, height, aspect ratio, pixel format, H.264 profile, timebase, audio channel layout, audio sample rate, stream types, and number of streams of these videos match that of the main video.
Make input.txt:
file 'pre1.mp4'
file 'pre2.mp4'
file 'main.mp4'
file 'post.mp4'

Concatenate with concat demuxer:
ffmpeg -f concat -i input.txt -c copy -movflags +faststart output.mp4


---

