Auto 4 cameras

Front (4k)

 

Rear (4k)

 

Left (HD)

 

Right (HD)

 

Output (4k)

 

The script below assumes that the size of the inputs are 3840×2160 for the front and rear cameras, and 1920×1080 for the left and right cameras.

The script usage is:

script {front video} {rear video} {left video} {right video} outputfilename

 

#!/bin/bash

# Front image

ffmpeg  -loglevel verbose \
-i $1 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-vf 'crop=3840:1636:0:0' \
-y \
-r 30000/1001 \
temp-front.mp4

# Rear image

ffmpeg  -loglevel verbose \
-i $2 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-vf 'crop=3840:1048:0:600,scale=1920:524,hflip' \
-y \
-r 30000/1001 \
temp-rear.mp4

# -vf 'crop=3840:1048:0:792,scale=1920:524,hflip' \

# Left image

ffmpeg -loglevel verbose \
-i $3 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-vf 'crop=1920:1048:0:0,scale=960:524' \
-y \
-r 30000/1001 \
temp-left.mp4

# Right image

ffmpeg  -loglevel verbose \
-i $4 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-vf 'crop=1920:1048:0:0,scale=960:524' \
-y \
-r 30000/1001 \
temp-right.mp4

# Create top row

ffmpeg  -loglevel verbose \
-i temp-left.mp4 \
-i temp-rear.mp4 \
-i temp-right.mp4 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-filter_complex hstack=inputs=3 \
-y \
-r 30000/1001 \
temp-top.mp4

# Join top to bottom

ffmpeg  -loglevel verbose \
-i temp-top.mp4 \
-i temp-front.mp4 \
-c:a aac \
-vbr 5 \
-c:v libx264 \
-crf 0 \
-coder 1 \
-context 1 \
-g 1 \
-threads 8 \
-filter_complex vstack=inputs=2 \
-y \
-r 30000/1001 \
$5