aboutsummaryrefslogtreecommitdiff
path: root/_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-02-23 10:35:22 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-02-23 10:35:22 +0100
commit4abcce013c9ee3053badf2abda77190233066676 (patch)
tree450de7e8fed3c3c7501a9d2e2eb60a676bdfa09e /_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md
parentcdf50cb2e3051200c6ea0628c318d66220b7d1a1 (diff)
downloadmitjafelicijan.com-4abcce013c9ee3053badf2abda77190233066676.tar.gz
Testing thoughts page
Diffstat (limited to '_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md')
-rw-r--r--_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md b/_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md
new file mode 100644
index 0000000..c47a726
--- /dev/null
+++ b/_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md
@@ -0,0 +1,41 @@
1---
2title: "Using ffmpeg to combine videos side by side"
3permalink: /using-ffmpeg-to-combine-video-side-by-side.html
4date: 2023-11-04T09:04:28+02:00
5layout: post
6type: note
7draft: false
8---
9
10I had a 4 webm videos (each 492x451) that I wanted to combine to be played side
11by side and I tried [iMovie](https://support.apple.com/imovie) and
12[Kdenlive](https://kdenlive.org/) and failed to do it in an easy way. I needed
13this for Github readme file so it also needed to be a GIF.
14
15The following is the [ffmpeg](https://ffmpeg.org/) version of it.
16
17```sh
18ffmpeg -y \
19 -i 01.webm \
20 -i 02.webm \
21 -i 03.webm \
22 -i 04.webm \
23 -filter_complex "\
24 [0:v] trim=duration=8, setpts=PTS-STARTPTS, scale=492x451, fps=6 [a0]; \
25 [1:v] trim=duration=8, setpts=PTS-STARTPTS, scale=492x451, fps=6 [a1]; \
26 [2:v] trim=duration=8, setpts=PTS-STARTPTS, scale=492x451, fps=6 [a2]; \
27 [3:v] trim=duration=8, setpts=PTS-STARTPTS, scale=492x451, fps=6 [a3]; \
28 [a0][a1][a2][a3] xstack=inputs=4:layout=0_0|w0_0|w0+w1_0|w0+w1+w2_0, scale=1000:-1 [v]" \
29 -map "[v]" \
30 -crf 23 \
31 -preset veryfast \
32 trigraphs.gif
33```
34
35- This will produce `trigraphs.gif` that is also scaled to max 1000px in width
36 (refer to `scale=1000:-1`).
37- The important part for 4x1 stack is `xstack=inputs=4:layout=0_0|w0_0|w0+w1_0|w0+w1+w2_0`.
38- This will also cap frame rate to 6 (refer to `fps=6`) since that is enough and
39 this makes playback of GIFs smoother in a browser.
40
41![Result](./assets/notes/trigraphs.gif){:loading="lazy"}