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