IT/Software/Command Line Applications/ffmpeg

From msgwiki
Jump to navigation Jump to search
Access restrictions were established for this page. If you see this message, you have no access to this page.

_

_

This tool is amazingly broad.

We will only attempt to show a few of its key features.

Reduce Video size and maintain some quality.

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

crf should vary between 18 and 24. The higher the number the higher the compression and lower the quality

Reduce Audio Size

This will take an mp3 or other audio file and shrink it.

I do not recommend going below 32k or the sound will have hiss.

ffmpeg -i The\ Scarlet\ Letter.mp3 -b:a 64k theScarletLetter64k.mp3

Convert a whole directory.

for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done

You can add your parameters there like crf and -vcodec

Extract audio from video

  • Change extension and names as needed.
  • Path is relative unless noted.
  • Single quotes are needed if you have spaces or any special character

ffmpeg -i '20150125 Word Blesses Us'.mp4 '20150125 Word Blesses Us'.mp3

Trim based on start and end time.

Try using this. It is the fastest and best ffmpeg-way I have figure it out:

 ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4

This command trims your video in seconds!

Explanation of the command:

-i: This specifies the input file. In that case, it is (input.mp4).

-ss: Used with -i, this seeks(seek start) in the input file (input.mp4) to position.

00:01:00: This is the time your trimmed video will start with.

-to: This specifies(time out) duration from start (00:01:40) to end (00:02:12).

00:02:00: This is the time your trimmed video will end with.

-c copy: This is an option to trim via stream copy. (NB: Very fast)

I highly recommend Lossless Cut from github. It is very nice and easy to use and cross platform.