Search code examples
ffmpegffserver

How to use filter_complex on ffmpeg with streaming videos


I have 30 video sources. i want to make ffmpeg command to create 1 channel (streaming) with all channels embedded in (in bad quality)

"[0:v][1:v]setpts=PTS-STARTPTS,overlay=20:40[1]; \
 [1][1:v]setpts=PTS-STARTPTS,overlay=(W-w)/2:(H-h)/2[v]; \
 [1:a][2:a]amerge=inputs=2[a]" \
-map "[v]" -map "[a]" -ac 2 3.mp4

i trying to find the correct command do downgrade quality, than create one streaming output. (one audio chosen)


Solution

  • Scale each video to desired size with the scale filter. Arrange with the xstack filter.

    ffmpeg -i input0 -i input1 ... -i input29 -i audio -filter_complex
    "[0]scale=128:-1[v0];[1]scale=128:-1[v1];...[29]scale=128:-1[v29];
    [v0][v1]...[v29]xstack=inputs=30:layout=<your desired layout>[v]"
    -map "[v]" -map 30:a -c:v libx264 -crf 51 -c:a aac -shortest output.mp4
    

    -crf 51 will provide the low quality as requested. Decrease the value if you want better quality.