====== ffmpeg ======
==== Vypsaní informací o video souboru ====
ffprobe -v error -show_format -show_streams input.mp4
ffmpeg -hide_banner -i input.mkv
Informace o video kodeku
ffprobe -v error -select_streams v -show_entries stream=codec_name,codec_type,codec_long_name,codec_tag_string -of default=noprint_wrappers=1 file.avi
==== Konverze na h.265 ====
#!/bin/bash -x
fromBR=`ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "$1"`
toBR=`awk "BEGIN {print $fromBR*0.60}"`
maxBR=`awk "BEGIN {print $fromBR*1.0}"`
toFILE=`echo ${1%.*}`
CRF=23
echo FROM:$fromBR
echo TO: $toBR
echo MAX: $maxBR
echo $CRF
# TWO WAY METHOD
ffmpeg -y -i "$1" -c:v libx265 -preset medium -b:v $toBR -maxrate $maxBR -x265-params pass=1 -an -f mp4 /dev/null
ffmpeg -i "$1" -c:v libx265 -preset medium -b:v $toBR -maxrate $maxBR -x265-params pass=2 -c:a copy -c:s copy "$toFILE.BR$toBR.h265.MIML.mkv"
#ONE WAY CRF METHOD
#ffmpeg -i "$1" -c:v libx265 -preset slow -crf $CRF -c:a copy -c:s copy "$toFILE.CRF$CRF.h265.MIML.mkv"
==== Konverze na h.264 ====
ffmpeg -i ./input.mkv -map 0 -c:a copy -c:s copy -c:v libx264 output.mkv
==== Spojení ====
==MPEG-2==
ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts
==MP4==
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
==== Vystřihnutí části ====
ffmpeg -i video.mp4 -ss 00:01:00 -to 00:02:00 -c copy cut.mp4
==== Přidání titulků ====
Konverze kódování souboru s titulku z CP1250 do UTF-8
iconv -f CP1250 -t UTF-8//TRANSLIT input.file -o out.file
Vložení titulků do kontejneru videa MKV
ffmpeg -i IN.mkv -i IN.srt -map 0:v -map 0:a -map 1 -c:v copy -c:a copy -c:s srt -metadata:s:s:0 language=Czech output.mkv
Vložení titulků do kontejneru videa MP4
ffmpeg -i IN.mkv -i IN.srt -map 0:v -map 0:a -map 1 -c:v copy -c:a copy -c:s mov_text -metadata:s:s:0 language=Czech output.mkv
==== Vypálení titulků do obrazu ====
ffmpeg -i IN.mp4 -vf subtitles=SubIN.srt out.mp4
==== Rotování obrazu ====
* 0 = 90° counter-clockwise and vertical flip (default)
* 1 = 90° clockwise
* 2 = 90° counter-clockwise
* 3 = 90° clockwise and vertical flip
ffmpeg -i input.mp4 -vf "transpose=0" output_0.mp4