- How to downsample 4k to 1080p using ffmpeg while maintaining the quality?
- Converting video from 1080p to 720p with smallest quality loss
- How to speed up/slow down a video
- Remove audio from video file with FFmpeg
- Convert frames to optimized gif with palette generation
- FFMPEG is doubling audio length when extracting from video
- Create repeating copy of a video until the ffmpeg process is stopped
- Merge audio and video by shortest input
- Combine an image & an audio file to make a video
- How to create a video from multiple images
- Replace audio in a video
- Convert audio file to MP3
- How to use FFmpeg Command for Reverse Video
- Extract subtitles from video
- Crossfade effect with ffmpeg
- Concat files with ffmpeg
- Cut video fragments
ffmpeg -i orig.mp4 -vf scale=1920:1080 -c:v libx264 -crf 20 -preset slow smaller.mp4
ffmpeg \
-i orig.mp4 \
-vf scale=-1:720 -c:v libx264 -crf 18 -preset veryslow -c:a copy \
-y out-720p.mp4
To double the speed of the video use setpts filter with multiplier 0.5
:
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv
To slow down video use a multiplier greater than 1:
ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv
ffmpeg -i example.mkv -c copy -an example-nosound.mkv
- Source: https://superuser.com/a/268986
ffmpeg -i frames/frame%04d.png -filter_complex "[0:v] palettegen" -y palette.png
ffmpeg -i frames/frame%04d.png -i palette.png -y video.gif
ffmpeg -stream_loop -1 -i input.mp4 -c copy output.mp4
ffmpeg -i "videoFile.mp4" -i "audioFile.mp3" -shortest outPutFile.mp4
- Source: https://superuser.com/a/902229
ffmpeg -loop 1 -i background.jpg -i soundtrack.wav -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -b:a 192k -shortest output.mp4
- Source: https://superuser.com/a/1041818
ffmpeg -framerate 12 -i frames/frame%04d.jpg -i soundtrack.aac -c:v libx264 -pix_fmt yuv420p -c:a copy output.mkv
Create video from images starting for a number (e.g. with enumerated images from a photocamera):
ffmpeg -framerate 12 -start_number 1729 -i IMG_%d.jpg -c:v libx264 -pix_fmt yuv420p output.mkv
Replace audio track with another file:
ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 new.mp4
Replace audio and reencode it to AAC:
ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 -c:a aac -b:a 192k -shortest new.mp4
- Source: https://superuser.com/a/1137613
ffmpeg -i input.wav -c:a mp3 -b:a 192k output.mp3
Reverse only video
ffmpeg -i video.mp4 -vf reverse reversed.mp4
Reverse audio and video
ffmpeg -i video.mp4 -vf reverse -af areverse reversed.mp4
- Source: https://video.stackexchange.com/a/17739
- Video reverse filter - https://ffmpeg.org/ffmpeg-filters.html#reverse
- Audio reverse filter - https://ffmpeg.org/ffmpeg-filters.html#areverse
ffmpeg -i Movie.mkv -map 0:s:0 subs.srt
Here s:0 sets the subtitle stream id.
- Source: https://superuser.com/a/927507
Specify bitrate when converting the file:
ffmpeg -i "video.webm" -acodec mp3 -ab 128k "audio.mp3"
- Source: https://superuser.com/a/893044
Prepare a concat file (e.g. concat.txt
) with list of fragments:
file '/path/to/1st/file.mp4'
file '/path/to/2nd/file.mp4'
file '/path/to/3rd/file.mp4'
...
Run concat
plugin:
ffmpeg -f concat -safe 0 -i concat.txt -c copy output.mp4
- Official docs - https://trac.ffmpeg.org/wiki/Concatenate
- How to concatenate two MP4 files using FFmpeg?
Specify start of a fragment with -ss
flag and duration with -t
. Note -c copy
is specified here for simplicity as it may produce slightly corrupter results when not aligned with key frames. In more general case, us
ffmpeg -i MVI_9437.MP4 -ss 00:00:00.0 -t 00:00:24.0 -c copy MVI_9437_1.MP4
ffmpeg -i MVI_9437.MP4 -ss 00:01:27.0 -t 00:01:10.0 -c copy MVI_9437_2.MP4