Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@ankurhora

This comment has been minimized.

Copy link

commented May 31, 2016

It increased the size instead of descreasing ?

@SamHH

This comment has been minimized.

Copy link

commented Jun 29, 2016

Worked well for me, from ~67MB to ~14MB. Thanks!

Edit: Appears to not play in IE. Blast.

@BeetLab

This comment has been minimized.

Copy link

commented Sep 22, 2016

Compressed from 14.1 mb to 4.9 mb. But lost sound( how can i fix it? Any options?

@ksharsha

This comment has been minimized.

Copy link

commented Oct 31, 2016

@ankurhora This code basically does transcoding, hence if the input video is already compressed, the output video could be larger than the input one. To achieve compression, we can reduce the bit rate. Look at the code here https://gist.github.com/ksharsha/b06d184391290bc3b87fdadadb73c5bc#file-ffmpeg-compress

@OlegFromKiev

This comment has been minimized.

Copy link

commented Jun 3, 2017

@BeetLab I faced the same problem. Changing -acodec mp2 to -acodec mp3 did the trick for me.

@TryTryAgain

This comment has been minimized.

Copy link

commented Aug 5, 2017

ffmpeg -i input.mp4 -vcodec h264 -acodec aac output.mp4 brought mine from 86457565 Bytes > 17195361 Bytes ~17MB ...wow, quality is really not even noticeably different. Thank you. -acodec mp3 was slightly smaller at 17195155. Now I'm looking to get my webm file down in size, hoping in a similar way.

@tigercosmos

This comment has been minimized.

Copy link

commented Sep 8, 2017

@TryTryAgain It works pretty well, and do it twice can compress more.

@AffanIndo

This comment has been minimized.

Copy link

commented Nov 16, 2017

It compress from 450 MB to 60 MB!
This is amazing.
But what is the thing that this command remove? Since I can't find any difference. Is the bitrate decreased?

@Noppez

This comment has been minimized.

Copy link

commented Dec 23, 2017

worked great, from 294 MB to 46.7 MB and still good quallity

Thanks!

@sunnyarora21

This comment has been minimized.

Copy link

commented Jan 16, 2018

Worked not expected.. I used 68.5Mb and get 65 MB ..

Thanks!

@Drgabi18

This comment has been minimized.

Copy link

commented Feb 2, 2018

220 MB to 21MB

coder moment

@dheerajbhaskar

This comment has been minimized.

Copy link

commented Feb 7, 2018

163mb to 60mb. This worked

@vkudyushev

This comment has been minimized.

Copy link

commented Feb 12, 2018

5Gb mov file (from after effects) downgraded to 250 Mb. Perfect!

@KievAndres

This comment has been minimized.

Copy link

commented May 7, 2018

De 1.06 GB a 229 MB. Genial!

@bassel999

This comment has been minimized.

Copy link

commented May 20, 2018

I tried to have the same code but doing the bulk compress but it didn't work anyone can help?'

for %%a in ("*.mp4") do ffmpeg -i "%%a" -i vcodec h264 -b:v 700k -acodec mp3 "FB\%%~na.mp4"

@crazy4groovy

This comment has been minimized.

Copy link

commented Jun 2, 2018

try:

for %%a in ("*.mp4") do ffmpeg -i "%%a" -vcodec h264 -b:v 700k -acodec mp3 "FB%%a~na.mp4"

@JanOwiesniak

This comment has been minimized.

Copy link

commented Jun 13, 2018

Worked as expected

ffmpeg -i input.mp4 -vcodec h264 -acodec aac output.mp4

Before 32.8 MB

After 6.8 MB

@lfuelling

This comment has been minimized.

Copy link

commented Jun 27, 2018

4,40 GB to 3,84 GB... I expected better.

@flamendless

This comment has been minimized.

Copy link

commented Jul 1, 2018

Woah, 300mb to 8mb

@Agile-SM

This comment has been minimized.

Copy link

commented Jul 26, 2018

I have 33MB and it command do a file more big...

@Ehsan-khaveh

This comment has been minimized.

Copy link

commented Sep 13, 2018

3.2gb to 320mb. And quality difference is very hard to see!

@ahmubashshir

This comment has been minimized.

Copy link

commented Sep 15, 2018

ffmpeg -i input.mp4 -vcodec libx265 -acodec aac -crf 23 output.mp4

Did the trick for me.

Before 400 mb

After 150 mb

@7statum

This comment has been minimized.

Copy link

commented Sep 28, 2018

ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4

Before : 124,2 mb

After ffmpeg 113,4 mb 👎

@IgorDePaula

This comment has been minimized.

Copy link

commented Nov 1, 2018

Its not work for me, I want reduce an webm video and 616mb to 480mb and very time spended =/

@thepante

This comment has been minimized.

Copy link

commented Nov 3, 2018

Here 14,9mb to 2,9mb - 00:56 yuv420p 480x480

@SwapnilSoni1999

This comment has been minimized.

Copy link

commented Nov 10, 2018

Worked! Thanks a lot

used ffmpeg -i input.mp4 -vcodec h264 -acodec aac output.mp4
Before 738MB
After 192MB
with no quality loss + flawless sound!

@CobaltXII

This comment has been minimized.

Copy link

commented Nov 11, 2018

Worked. Before: 1.6 MB. After: 132 KB. However, it doesn't work on videos with a width or height that is not divisible by 2. Not a big issue though.

@opensas

This comment has been minimized.

Copy link

commented Nov 21, 2018

Great!!

I tried compressing following this thread: https://gist.github.com/ksharsha/b06d184391290bc3b87fdadadb73c5bc

ffmpeg -i video.mp4 -vcodec h264 -b:v 1000k -acodec mp3 output.mp4

and went from 1.1 GB to 69 MB!!!

@tylerphillip

This comment has been minimized.

Copy link

commented Dec 28, 2018

So, first all thanks to the developers and coder. I've been using FFMPEG with the Sick Beard MP4 automator and it's working beautifully! Now as I'm watching it work, I wish I could shrink the file size down when it auto converts. So, I stumbled upon this thread. i am a total noob to all of this so forgive my ignorance, but where do I add this script to make FFMPEG compress as the automator is working? I'm running Sonarr, Radarr, SabNZBd, and of course the Sick Beard MP4 Automator scripts.

Thanks in advance and again sorry for my ignorance if this is a totally stupid question!

@x3inspire

This comment has been minimized.

Copy link

commented Jan 1, 2019

try:

for %%a in ("*.mp4") do ffmpeg -i "%%a" -vcodec h264 -b:v 700k -acodec mp3 "FB%%a~na.mp4"

Does it work?

@Zeryther

This comment has been minimized.

Copy link

commented Apr 8, 2019

27 GB -> 9.56 GB 👍

@baskax

This comment has been minimized.

Copy link

commented Apr 29, 2019

with mp3 as audio codec 832MB -> 53.1MB
thanks a lot!

@Ardeshir81

This comment has been minimized.

Copy link

commented May 17, 2019

Great
from 274 to 36
Thanks
(But changed mp2 to mp3)

@JamesSMF

This comment has been minimized.

Copy link

commented May 19, 2019

I guess this works great for large size videos. I got my video from 750 mb to 57 mb. Thanks.

@neelkadia

This comment has been minimized.

Copy link

commented Jun 11, 2019

This is legit! Thanks!

@eshanokpe

This comment has been minimized.

Copy link

commented Aug 22, 2019

pls how do i impliment this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.