This project allows you to use FFmpeg to arrange video files stored in a specified folder in a grid layout of NxN and generate the output.
sample1.mov, sample2.mov, sample3.mov, sample4.mov
![sample-screenshot](https://private-user-images.githubusercontent.com/33836132/240936777-caccd49b-08a4-4c34-a8f4-8f82749716be.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAwNzMzNTAsIm5iZiI6MTcyMDA3MzA1MCwicGF0aCI6Ii8zMzgzNjEzMi8yNDA5MzY3NzctY2FjY2Q0OWItMDhhNC00YzM0LWE4ZjQtOGY4Mjc0OTcxNmJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDA2MDQxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWViOTQxYWUzMWJiZjczNTdlYjIwMzE1Njc3NmUzZGQ1Y2QwMTRlN2JkZTQ0YWNiNGQ1M2EzOWJlY2JlYWM5OWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sIGhYBw-kVuVPTMpaa6t30eap_MS5Ouvnjzqmcn6e7w)
- This project supports Mac, Linux, and WSL2 as operating systems, but not Windows.
- The video file generation process depends on the number of input videos (square root is an integer and must be greater than or equal to 2).
- For example, 4 videos will be placed in a 2x2 layout, and 9 videos will be placed in a 3x3 layout.
- Input videos should be stored in the input folder.
- The output video is created by looping and merging according to the longest video among the input videos, and stored in the output folder.
- The videos are arranged alphabetically from top left to top right and from bottom left to bottom right.
- To specify the placement, prefix it with a number.
- Target input and output video file formats are MP4 and MOV.
In order to execute the code, FFmpeg must be installed and accessible via the $PATH environment variable.
There are a variety of ways to install FFmpeg, such as the official download links, or using your package manager of choice (e.g. sudo apt install ffmpeg on Debian/Ubuntu, brew install ffmpeg on OS X, etc.).
Regardless of how FFmpeg is installed, you can check if your environment path is set correctly by running the ffmpeg command from the terminal, in which case the version information should appear, as in the following example (truncated for brevity):
$ ffmpeg
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
Note
The actual version information displayed here may vary from one system to another; but if a message such as ffmpeg: command not found appears instead of the version information, FFmpeg is not properly installed.
- If you are using poetry, please execute the following command
git clone --filter=blob:none --no-checkout https://github.com/7rikazhexde/video-grid-merge.git && cd video-grid-merge && git sparse-checkout init --cone && git sparse-checkout set video_grid_merge && git checkout
poetry install --only main
- It includes a static analysis tool and test data that performs the following
git clone https://github.com/7rikazhexde/video-grid-merge.git
cd video-grid-merge
poetry install
- Input videos should be stored in the Input folder.
- Specify the resolution of the output video.
- The following two patterns are available for specifying the resolution. (Default is 1)
- Expand the number of Input Video:
match_input_resolution_flag = true
- 640x480:
match_input_resolution_flag = false
- Expand the number of Input Video:
- Command Execution Result Example
$ python video_grid_merge
Input Video Time List: [48.31, 62.43, 63.96, 77.83]
Enter the name of the output file (default is 'combined_video.mov'): test.mov
Video Grid Merge Start
Video Grid Merge End And Output Success
File Output Complete: ./video_grid_merge/media/output/test.mov
Processing Time(s): 24.62715184
if you delete temporary data files in the specified folder
- poetry
poetry run task vgmrm
- Not poetry
python video_grid_merge/delete_files.py
If you fork this project, you can use the following function to synchronously update the versions of poetry.toml and git tags.
If you need it, please see the link for instructions on how to use it.
feat: Add Version update feature by pre-commit and post-commit #1