Часто используемые команды ffmpeg

Конвертация видео

$ ffmpeg -i input.mov output.mp4

Видео в GIF

#Usage
$ ./gifCreator.sh saveas.mp4 anim.gif

Скачивание видео

Браузер ➡ Веб-страница ➡ Проверка ➡ Сеть ➡ поиск видео/аудиофайлов в формате, таком как m3u8, mp4 и т. д.

$ ffmpeg -i "<video URL>" -c:v libx264 -preset slow -crf 22 "<save-as>"
______________________________
$ ffmpeg -i "https://cnnios-f.akamaihd.net/i/cnn/big/us/2020/05/24/myrtle-beach-memorial-day-weekend-chen-nr-sot-vpx.cnn_3239527_ios_,440,650,840,1240,3000,5500,.mp4.csmil/indexW-w-5:H-h-5av.m3u8" -c:v libx264 -preset slow -crf 22 "saveas.mp4"

Создание миниатюры

$ ffmpeg -i <video-file-Path> -vframes 1 -an -s 400x222 -ss 30 <image-file-Path>
__________________________________
$ ffmpeg -i saveas.mp4 -vframes 1 -an -s 400x222 -ss 30 thumb.jpg

Извлечение аудио

«-vn» ➡ Нет видео

$ ffmpeg -i <video-file-Path> -vn -acodec copy <audio-file-Path>
__________________________________
$ ffmpeg -i saveas.mp4 -vn -acodec copy output.aac

Добавление водяного знака на видео

$ ffmpeg -i <video-file-Path>  \
         -i <Wartermark-Image> -filter_complex \
         "overlay=<Position>" \
         -codec:a copy <output-video-file>
________________________
# 5px padding
Center:  (W-w)/2:(H-h)/2
Top Left: 5:5
Top right: W-w-5:5
Bottom right: W-w-5:H-h-5
Bottom left: 5:H-h-5
Example:
$ ffmpeg -i saveas.mp4 -i logo.png -filter_complex "overlay=5:5" -codec:a copy output.mp4

Обрезка и масштабирование видео

$ ffmpeg -i <input> -vf <Scale/Crop Parms> <output>
crop=<NewSize>:<from Offset> eg. crop=640:320:100:100
scale=<New Scaled Size> eg. scale=640:320
Example:
$ ffmpeg -i  output.mp4 -vf "crop=640:320:100:100"  output2.mp4 
$ ffmpeg -i  output.mp4 -vf "scale=640:320"  output2.mp4

Разделение видео

#Getting Part of video
$ ffmpeg -i <input Video> -ss 0 -t 60 first-1-min.mp4
#Spliting video into time segments (useful when convert mp4 to HLS)
$ ffmpeg -i <input Video> -c copy -map 0 -segment_time <time> -f segment output%03d.mp4

Конвертирование видео из папки