IT/Software/Command Line Applications/ffmpeg: Difference between revisions
Walttheboss (talk | contribs) No edit summary |
Walttheboss (talk | contribs) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
<code>ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4</code> | <code>ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4</code> | ||
crf should vary between 18 and | crf should vary between 18 and 32. The higher the number the higher the compression and lower the quality | ||
== Reduce Audio Size == | You can also reduce the audio bitrate | ||
<code> -b:a 32k -crf 32 output32_23.mp4 </code> | |||
==Reduce Audio Size== | |||
This will take an mp3 or other audio file and shrink it. | 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. | I do not recommend going below 32k or the sound will have hiss. | ||
<code>ffmpeg -i The\ Scarlet\ Letter.mp3 -b:a 64k theScarletLetter64k.mp3 </code> | |||
==Convert a whole directory.== | ==Convert a whole directory.== |
Latest revision as of 05:04, 19 November 2021
_
_
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 32. The higher the number the higher the compression and lower the quality
You can also reduce the audio bitrate
-b:a 32k -crf 32 output32_23.mp4
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.