Skip to content

ffmpeg scripts

Convert to H264

#!/bin/bash
#
IFS=$'\n'

for i in $(ls -1 | grep -v run.sh ); do

  converted_file=$(echo "$i" | grep h264)

  if [ -z "$converted_file" ]; then

    codec264=$(ffprobe -i "$i" 2>&1 | grep Stream | grep Video: | grep 264)

    if [ -z "$codec264"  ]; then
        newfile="${i%.*}.h264.${i##*.}"

    test -f $newfile && { echo "SKIP converted file present: $newfile"; continue; }

    echo "Converting: $i"
    ffmpeg -i "$i" -crf 15 -vcodec libx264 -acodec aac "$newfile"
    fi
  else
    echo "SKIP converted: $i"
  fi 

done