Home > OS >  ffmpeg / batch addition of watermarks for videos [duplicate]
ffmpeg / batch addition of watermarks for videos [duplicate]

Time:10-03

I used with script to add dynamic watermark to one video, how to adapt it to convert multiple videos?

ffmpeg -i test.mp4 -i logo.png -filter_complex "[1]colorchannelmixer=aa=0.6,scale=iw*0.7:-1[a];[0][a]overlay=x='if(lt(mod(t\,16)\,8)\,W-w-W*5/100\,W*5/100)':y='if(lt(mod(t 4\,16)\,8)\,H-h-H*2.5/100\,H*2.5/100)'" -c:v libx264 -an out.mp4

CodePudding user response:

You just need to iterate the video files:

source_folder=$1
target_folder=$2

mkdir -p $target_folder

echo "procesing..."
count=1
for file in $source_folder/*.mp4 $source_folder/**/*.mp4 ; do

  if [[ -f $file ]]; then
    filename=$(basename -- "$file")
    echo "source video:"$file "new :"$target_folder/$filename
    ffmpeg -i "$file" -i logo.png -filter_complex "[1]colorchannelmixer=aa=0.6,scale=iw*0.7:-1[a];[0][a]overlay=x='if(lt(mod(t\,16)\,8)\,W-w-W*5/100\,W*5/100)':y='if(lt(mod(t 4\,16)\,8)\,H-h-H*2.5/100\,H*2.5/100)'" -c:v libx264 -an "$target_folder/$filename"
  fi
done;

echo ""
echo "result: $target_folder"
find  $target_folder | sort

Example:

bash script.sh /input /foo/bar/output
  • Related