The following command will find all mp4
files that are in the current directory and in all sub-folders and convert them to mkv
.
Recently we needed to share some footage from a HikVision NVR which was recording to H.265+ which was a proprietary format of the company. To do so, we converted them in another format that more players could recognize the videos.
for FILE in *.mp4; do
echo -e "Processing video '\e[32m$FILE\e[0m'";
ffmpeg -i "${FILE}" -analyzeduration 2147483647 -probesize 2147483647 -c:v libx265 -an -x265-params crf=0 "${FILE%.mp4}.mkv";
done;
The filename of the mkv
file will be the same as the mp4
video with the correct extension. The mp4
extension will be removed and replaced by the mkv
extension e.g hi.mp4 will become hi.mkv
A few notes, the compression they use seems really good, the size of the original video is very small in comparison to the generated result.