diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-02-23 10:35:22 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-02-23 10:35:22 +0100 |
| commit | 4abcce013c9ee3053badf2abda77190233066676 (patch) | |
| tree | 450de7e8fed3c3c7501a9d2e2eb60a676bdfa09e /_posts/notes/2023-11-04-using-ffmpeg-to-combine-video-side-by-side.md | |
| parent | cdf50cb2e3051200c6ea0628c318d66220b7d1a1 (diff) | |
| download | mitjafelicijan.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.md | 41 |
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 | --- | ||
| 2 | title: "Using ffmpeg to combine videos side by side" | ||
| 3 | permalink: /using-ffmpeg-to-combine-video-side-by-side.html | ||
| 4 | date: 2023-11-04T09:04:28+02:00 | ||
| 5 | layout: post | ||
| 6 | type: note | ||
| 7 | draft: false | ||
| 8 | --- | ||
| 9 | |||
| 10 | I had a 4 webm videos (each 492x451) that I wanted to combine to be played side | ||
| 11 | by 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 | ||
| 13 | this for Github readme file so it also needed to be a GIF. | ||
| 14 | |||
| 15 | The following is the [ffmpeg](https://ffmpeg.org/) version of it. | ||
| 16 | |||
| 17 | ```sh | ||
| 18 | ffmpeg -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 | {:loading="lazy"} | ||
