Menu
Menu

Reducing the size of the mp4 files taken with my mobile phone

Posted in linux, server on 2014/04/13
Tags: , , , , , ,

My mobile phone creates a good quality movies, but they are pretty big in size.
In order to save some disk space but still keep a good quality I'm using the following small script to reduce the size of the file but do not sacrifice the quality of the movie.
Usually I'm using CRF value of 22. Default value is 23 and lower values mean better quality and bigger file size.


#!/bin/sh

# Reduce the size of the mp4 files produced by my mobike,
# keeping good quality

inputfile="$1"
outputfile="$2"

ffmpeg_mp4reduce() {
   ffmpeg -i "$1" -c:v libx264 -crf 22 -c:a aac -strict experimental -b:a 256k "$2"
}

if [ $# -ne 2 ]; then
   echo "Reduce the size of mp4 file, keeping good quality"
   echo "Usage: $0 inputfile outputfile"
   exit 1
else
   ffmpeg_mp4reduce "$inputfile" "$outputfile"
fi

Comments are closed.