Search code examples
ffmpegvideo-processingvideo-encoding

ffmpeg save difference between 2 videos to file


I'm currently trying to learn everything related to videos and encountered a problem that I need help with.

The Question is: How can I save the difference between 2 videos to a seperate file with ffmpeg?
For example here is the ffplay command I'm trying with: (Source: https://superuser.com/questions/854543/how-to-compare-the-difference-between-2-videos-color-in-ffmpeg)

ffplay -f lavfi "movie=left.mp4,setpts=PTS-STARTPTS,split=3[a0][a1][a2];
            movie=right.mp4,setpts=PTS-STARTPTS,split[b0][b1];
            [a0][b0]blend=c0_mode=difference[y];
            [a1]lutyuv=y=val:u=128:v=128[uv];
            [y][uv]mergeplanes=0x001112:yuv420p,pad=2*iw:ih:0:0[down];
            [a2][b1]hstack[up];[up][down]vstack"

In this case I would want to have the bottom left video saved to a new file.
Can someone help me get together the right ffmpeg filter and explain the proccessing of ffmpeg?


Solution

  • Your modified command:

    ffmpeg -i left.mp4 -i right.mp4 -filter_complex "[0][1]blend=c0_mode=difference[y];[0]lutyuv=y=val:u=128:v=128[uv];[y][uv]mergeplanes=0x001112:yuv420p[v]" -map "[v]" output.mp4
    

    See documentation for blend, lutyuv, and mergeplanes filters.