In doing some Kelvin-Helmholtz comparisons I have been trying to cook up a script that can stitch two movies together with ffmpeg. In order to determine how many frames I need I must do a simple subtraction in bash, but how?! Easy apparently…you just:

#!/bin/bash
BEG=10
END=400
NUM=$((END-BEG))
echo $NUM

and it will return the value 390. So how about that ffmpeg script?!

#!/bin/bash

FPS=12

BEG=10
END=50

DIR1=.
DIR2=.

PREFIX1=splash\_%04d.png
PREFIX2=splash\_%04d.png

MOV1=1.mov
MOV2=2.mov
FINAL=SIDEBYSIDE.mov

NUM=$((END-BEG))

if [ $END -gt 0 ]
  then
  PARAM="-vframes $NUM"
  else
  PARAM=""
fi

ffmpeg -start\_number $BEG -r $FPS -i $DIR1/$PREFIX1 $PARAM -vcodec qtrle $MOV1
ffmpeg -start\_number $BEG -r $FPS -i $DIR2/$PREFIX2 $PARAM -vcodec qtrle $MOV2

## SIDE BY SIDE ##
ffmpeg -i $MOV2 -vf "movie=$MOV1 [in1]; [in]pad=iw\*2:ih:iw:0[in0]; [in0][in1] overlay=0:0 [out]" -vcodec qtrle $FINAL
Here’s the end result:

Comments

comments powered by Disqus