Search

15 examples of different usage of ffmpeg

ffmpeg is an excellent tool. It's a complete video editor via the command line.


15 examples of different usage of ffmpeg


ffmpeg was created by Fabrice Bellard the same creator as QEMU and QuickJS, the engine behind JSLinux.

In addition to the conventional conversion commands that we use on a daily basis, let’s see 15 more utilities that can be good for you in many cases.


1. Finding out how many FPS your video has

ffmpeg -i output.mp4 2>&1 | egrep -o '[0-9]+ fps'

2. Inserting ZOOM into your video

fmpeg -i input.mp4 -vf "zoompan=z='if(lte(mod(time,10),10),2,1)':d=1:x=iw/2-(iw/zoom/2 ):y=ih/2-(ih/zoom/2):fps=30" output.mp4

3. Optimizing your video

Decreasing the size without losing image quality:

ffmpeg -i input.mp4 -vcodec libx264 -crf 28 output.mp4

4. Resizing video resolution

Leaving it in the resolution: 1280x720

ffmpeg -i input.mp4 -vf scale=1280:720 -preset slow -crf 18 output.mp4


5. Resizing the width and height will be proportional

Specified for width of 1280 .

ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4

6. Resizing the height and width will be proportional

Specified for height of 720

ffmpeg -i input.mp4 -vf scale=-1:720 output.mp4

7. Removing audio from a video

ffmpeg -i input.mp4 -c copy -an output.mp4

8. Rotating a video

It looks like a cell phone screen, the width becomes the height and vice versa

ffmpeg -i input.mp4 -vf "transpose=clock" output.mp4

9. Rotating 180°

If the video is “upside down” you will reverse it

ffmpeg -i input.mp4 -vf "transpose=2,transpose=2" output.mp4

10. Summarizing information output

When you run the command: ffmpeg -i output.mp4 ffmpeg displays the video data, but the header makes it difficult to see this, to ignore that initial data, run:

ffmpeg -i output.mp4 -hide_banner


11. Extracting frames from a video

mkdir frames
ffmpeg -y -ss 00:00 -i input.mp4 -t 10 "frames/filename%05d.jpg"

There will be several images in the frames directory named filename00001.jpg up to the maximum number of images that the video has.


12. Extract frames from only the initial 10 seconds

ffmpeg -y -ss 00:00 -i input.mp4 -t 10 "frames/filename%05d.jpg"

13. Watching video

ffplay video.mp4

14. Listening to music

ffplay music.mp3

15. Adding subtitles to video

Example caption:

vim subtitle.srt

1
00:00:00,000 --> 00:00:02,827
- Root Terminal - Systems
Operational, C++ and Development.

two
00:00:02,827 --> 00:00:06,383
15 Examples of different usage
from ffmpeg to help you

3
00:00:06,383 --> 00:00:09,427
Don't forget to also read
the links below. It cost!

Command:

ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text outfile.mp4

multimedia commands terminal


Share



Comments