====== Media directory ======
This guide aims at getting a media directory of a large movie collection on a Debian linux server. We want to get the movie title, audio language, subtitle language, duration, and video resolution.
- Find the requested information from a file:ffmpeg -i .mkv 2>&1 | grep Audio
ffmpeg -i .mkv 2>&1 | grep Subtitle
ffmpeg -i .mkv 2>&1 | grep Duration
ffmpeg -i .mkv 2>&1 | grep Video
- Create a batch file which extracts the required information:
- Create a batch file "mkvextract" which extracts all required information into format "movie name; audio languages; subtitle languages; video resolution; movie duration"echo $(basename "$1") | tr -d '\n'
echo -n ";"
ffmpeg -i "$1" 2>&1 | grep -P '(?<=\()(.*?)(?=\): Audio)' -o | tr '\n' ' ' | xargs | tr -d '\n'
echo -n ";"
ffmpeg -i "$1" 2>&1 | grep -P '(?<=\()(.*?)(?=\): Subtitle)' -o | tr '\n' ' ' | xargs | tr -d '\n'
echo -n ";"
ffmpeg -i "$1" 2>&1 | grep -e Video | grep -P '\b\d*x\d*\b' -o | tr '\n' ' ' | xargs | tr -d '\n'
echo -n ";"
ffmpeg -i "$1" 2>&1 | grep -P '(?<=Duration: )(.*?)(?=[\.,])' -o | tr '\n' ' ' | xargs | tr -d '\n'
echo
exit 0
- Run the find command on the directory to analyze:find . -name *.mkv -exec /path/to/batch/mkvextract {} \;