Last active
June 2, 2023 21:30
-
-
Save SoundBlaster/d86c8b373db3602e0a38d240cb1ed4f2 to your computer and use it in GitHub Desktop.
ffmpeg cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Конвертация MKV в MP4 | |
ffmpeg -i sme.mkv -codec copy MmZdigKm2ls.mp4 | |
ffmpeg -i 1.avi -c:v libx264 -c:a aac 1.mp4 | |
ffmpeg -i MmZdigKm2ls.mkv -c copy MmZdigKm2ls.mp4 | |
ffmpeg -i MmZdigKm2ls.mkv -c:v libx264 -c:a copy -x264-params crf=25 MmZdigKm2ls.mp4 | |
WEBM в MP4 | |
ffmpeg -fflags +genpts -i 11.webm -r 24 1.mp4 | |
MKV в MP4 с HDR 10 | |
ffmpeg -i 1.mkv -c:v copy -tag:v hvc1 -c:a pcm_s24le -f mov -movflags +faststart 1.mov | |
Crop | |
ffmpeg -i AuroraLightsSlow2.mp4 -filter:v "crop=3840:2160:0:400" AuroraLightsSlow2_out.mp4 | |
ffmpeg -framerate 29.97 -pattern_type glob -i '*.jpg' -c:v libx264 -b:v 10M -minrate 10M output.mp4 | |
ffmpeg -framerate 29.97 -pattern_type glob -i '*.jpg' -vcodec libx264 -y -an -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" video.mp4 | |
ffmpeg -i video.mp4 -filter:v "crop=3840:1080:0:0" out.mp4 | |
ffmpeg -i Aurora_4k_.mov -r 30 -vf "crop=3840:2160:0:640" -c:a copy Aurora_4k.mp4 | |
ffmpeg -i AuroraLightsSlow2_4K.mp4 -r 30 -vf "crop=1920:1080:640:0" -c:a copy AuroraLightsSlow2_FHD.mp4 | |
ffmpeg -i output_1920_1200.mp4 -r 30 -vf "crop=1920:1080:0:0" -c:a copy output_1920_1080.mp4 | |
Изменение размера (без сохранения пропорций) | |
ffmpeg -i 711675454_456239243_o.mp4 -filter:v "scale=1920:1080" 711675454_456239243_o_FHD.mp4 | |
ffmpeg -i rec.mov -vf scale=1920:1200 output_1920_1200.mp4 | |
Изменение пропорций отображения | |
ffmpeg -i out.mp4 -aspect 1920:1080 -c copy out-16-9.mp4 | |
ffmpeg -i 20201105_112417.mp4 image%d.jpg | |
ffmpeg -i 20201105_112417.mp4 input -acodec aac final_video.mp4 | |
Удалить аудио | |
ffmpeg -i 1.mov -c copy -an 2.mov | |
Информация | |
ffmpeg -i videoclock1.1.1-mac.mov | |
ffmpeg -i Luna\ Design\ Prime.mp4 -vf "transpose=1" LunaDesignPrime.mp4 | |
GIF to mp4 | |
ffmpeg -i lenin.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" lenin.mp4 | |
Экспорт аудио | |
ffmpeg -i 1.mp4 -vn -acodec copy output-audio_1.aac | |
ffmpeg -i 12345.mkv -vn -acodec copy JV3FgaJD-wM.aac | |
ffmpeg -i 12345.mkv -acodec copy -vn audio.opus | |
Экспорт конкретного трека 0:2 | |
ffmpeg -i 123.mov -map 0:2 -vn -acodec copy output-audio_2.aac | |
Аудио в mp3 | |
ffmpeg -i 1.aac -acodec libmp3lame 1.mp3 | |
Ресемплинг аудио | |
ffmpeg -i output-audio_1.aac -ar 3000 output-audio_1.wav | |
Смена FPS без потери кадров | |
ffmpeg -r 29.97 -i output_x.mov test.mov | |
Ускорение | |
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video | |
1 | |
ffmpeg -i test.mov -map 0:v -c:v copy -bsf:v h264_mp4toannexb raw.h264 | |
ffmpeg -fflags +genpts -r 30 -i raw.h264 -c:v copy output.mp4 | |
2 | |
ffmpeg -i 1.mp4 -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'" output.mkv | |
Изменить битрейт | |
ffmpeg -i LASCALA.mp4 -b:v 9.5M -b:a 127k LASCALA_2.mp4 | |
Видео из картинки со звуком | |
ffmpeg -i ep1.png -i ep1.wav ep1.flv | |
без звука | |
ffmpeg -loop 1 -i image.png -c:v libx264 -t 15 -pix_fmt yuv420p -vf scale=320:240 out.mp4 | |
Экспорт кадров | |
for f in ../*.mp4 | |
do | |
ffmpeg -i $f -r 0.2 -s 853x480 $f+_thumb%06d.jpg | |
done | |
ffmpeg -i *.mp4 thumb%06d.jpg -hide_banner | |
Обрезка длительности | |
ffmpeg -ss 00:00:00 -i nebula.mp4 -ss 00:00:03 -t 00:00:03 -c copy nebula_clip.mp4 | |
The first -ss seeks fast to (approximately) 8min0sec, and then the second -ss seeks accurately to 9min0sec, and the -t 00:01:00 takes out a 1min0sec clip. | |
https://superuser.com/a/704118 | |
ffmpeg -ss 0 -i nebula.mp4 -c copy -t 3 nebula_clip.mp4 | |
Поворот | |
ffmpeg -i Тоха-43556543_456239028.mp4 -vf transpose=2 Тоха-43556543_456239028_90.mp4 | |
1. Flip video vertically: | |
ffmpeg -i INPUT -vf vflip -c:a copy OUTPUT | |
2. Flip video horizontally: | |
ffmpeg -i smeshariki.mp4 -vf hflip -c:a copy smeshariki2.mp4 | |
3. Rotate 90 degrees clockwise: | |
ffmpeg -i INPUT -vf transpose=1 -c:a copy OUTPUT | |
4. Rotate 90 degrees counterclockwise: | |
ffmpeg -i INPUT -vf transpose=2 -c:a copy OUTPUT | |
Видео из картинок | |
ffmpeg -framerate 2 -pattern_type glob -i '*.JPG' -c:v libx264 -pix_fmt yuv420p out.mp4 | |
Деление на сегменты https://unix.stackexchange.com/a/725985 | |
ffmpeg -i video.mp4 -ss 00:00:00 -t 00:01:00 -vf "[in]scale=iw*min(1080/iw\,1920/ih):ih*min(1080/iw\,1920/ih),pad=1080:1920:(1080-iw)/2:(1920-ih)/2[out]" newVideo.mp4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment