Video grids with ffmpeg

I wanted to create a video that is a 3×2 grid of 6 other videos. This one to be precise: I was hoping I can use ffmpeg, because the thought of using a proper video editing software gives me the chills. In fact at some point I thought things will require iMovie and went to […]


This content originally appeared on phpied.com and was authored by Stoyan

I wanted to create a video that is a 3x2 grid of 6 other videos. This one to be precise:

I was hoping I can use ffmpeg, because the thought of using a proper video editing software gives me the chills. In fact at some point I thought things will require iMovie and went to install it. But it required OS update. Screw that! FFMPEG it is.

Turns out there's more than one way to skin that particular cat. One is using xstack filter

ffmpeg -i 1.m4v  -i 2.m4v -i 3.m4v -i 4.m4v -i 5.m4v -i 6.m4v \
-filter_complex "xstack=inputs=6:layout=0_0|0_h0|w0_0|w0_h0|w0+w3_0|w0+w3_h0" \
-map "[out]" output.m4v

The other is to use hstack and vstack:

ffmpeg -i 1.m4v  -i 2.m4v -i 3.m4v -i 4.m4v -i 5.m4v -i 6.m4v \
-filter_complex "[0:v][2:v][4:v]hstack=inputs=3[top];[1:v][3:v][5:v]hstack=inputs=3[bottom];[top][bottom]vstack=inputs=2[v]" \
-map "[v]" output.m4v

I'm no ffmpeg expert so I cannot afford the luxury of even pretending to begin to explain this syntax. But it works!

Side note: video editing with Reaper

How do I trim and time-align video without a video editor? I use my music editing software Reaper (unlimitted trial, $60 otherwise). I record the audio in Reaper and the video on an oldish iPhone. Then I drop the video in Reaper and cut it as regular audio file. And visually align the waveforms from the audio recording and the video. Then turn down the volume of the video.


This content originally appeared on phpied.com and was authored by Stoyan


Print Share Comment Cite Upload Translate Updates
APA

Stoyan | Sciencx (2020-12-07T20:11:27+00:00) Video grids with ffmpeg. Retrieved from https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/

MLA
" » Video grids with ffmpeg." Stoyan | Sciencx - Monday December 7, 2020, https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/
HARVARD
Stoyan | Sciencx Monday December 7, 2020 » Video grids with ffmpeg., viewed ,<https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/>
VANCOUVER
Stoyan | Sciencx - » Video grids with ffmpeg. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/
CHICAGO
" » Video grids with ffmpeg." Stoyan | Sciencx - Accessed . https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/
IEEE
" » Video grids with ffmpeg." Stoyan | Sciencx [Online]. Available: https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/. [Accessed: ]
rf:citation
» Video grids with ffmpeg | Stoyan | Sciencx | https://www.scien.cx/2020/12/07/video-grids-with-ffmpeg/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.