Video TIPS

Getting INFO

avprobe <file>

Convert to webm

ffmpeg -i input.video -threads 4 -b:v 1M -crf 10 output.webm

Repair index

mencoder -idx input.video -ovc copy -oac copy -o output.video

from images to video

# 5 images per seconds
ffmpeg -y -framerate 5 -pattern_type glob -i '*.jpg' -c:v libx264 -vf "fps=25,scale=720:-1" out.mp4

MKV

convert to mkv

mkvmerge -o output.mkv <inputfile>

convert to mkv and downgrade quality

avconv -i <inputfile> -map 0 -c:v libx264 -crf 20 -c:a copy -c:s copy <outfile>.mkv

concatenate all *.mp4 files to output.mkv

mkvmerge -o output.mkv $(echo *.mp4 | sed "s| | +|g")

x264

From x265 to x264

ffmpeg -xerror -i input.mkv -hide_banner -threads 0 -map 0 -c:a copy -c:s copy -c:v libx264 -pix_fmt yuv420p output.mkv

script

convert files to mkv and downgrade them if greater than specific value

tomkv (chmod +x)

#!/bin/bash
OUTDIR=out
LIMIT_MBYTE=1500
QUALITY=20 # lower values are better
mkdir -p $OUTDIR
set -x
for f in "$@"
do
[ -f "$f" ] || continue
SIZE=$(stat -c%s "$f")
OUTNAME=$OUTDIR/${f%.*}.mkv
[ -f "$OUTNAME" ] && ( echo "Skip $OUTNAME"; continue )
if [ $SIZE -gt $(($LIMIT_MBYTE*1000000)) ]; then
echo avconv $f
avconv -i "$f" -map 0 -c:v libx264 -crf $QUALITY -c:a copy -c:s copy "$OUTNAME"
else
echo mkvmerge $f
mkvmerge "$f" -o "$OUTNAME"
fi
done

Usage to convert into ./out folder

tomkv file1 file2 ...