Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Oct 31, 2016

Compress videos using ffmpeg

@karltaylor

This comment has been minimized.

Copy link

@karltaylor karltaylor commented Nov 11, 2016

Just what I needed, went from 90mb to 5 and still looks good :) Thankyou 👍

@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Nov 17, 2016

Glad that you this help you :)

@karltaylor

This comment has been minimized.

Copy link

@karltaylor karltaylor commented Nov 17, 2016

Can I just say though these don't work in IE9! :( Not sure why

@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Nov 25, 2016

Try changing the bit rate to a lower value something like 250k instead of 1000k and let me know if it helps.

@opensas

This comment has been minimized.

Copy link

@opensas opensas commented Nov 21, 2018

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

and went from 1.1 GB to 69 MB!!!

@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Dec 20, 2018

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

and went from 1.1 GB to 69 MB!!!

Glad it worked!

@iburunat

This comment has been minimized.

Copy link

@iburunat iburunat commented Jun 22, 2019

Hi @ksharsha I wish it worked on mine. I understand this would work on already compressed videos (my phone takes already compressed mp4 files, but I need to compress them further). I am trying to use Automator to do batches, like this:

for f in "$@"
do
/usr/local/bin/ffmpeg -i "$f" -vcodec h264 -b:v 1000k -acodec mp2 "${f%.*}.mp4"
done

...unsuccessfully. See error output. Any advice welcome!
screenshot1561243957@2X

@eshanokpe

This comment has been minimized.

Copy link

@eshanokpe eshanokpe commented Aug 22, 2019

pls how do i impliment this code

@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Aug 28, 2019

Hi @ksharsha I wish it worked on mine. I understand this would work on already compressed videos (my phone takes already compressed mp4 files, but I need to compress them further). I am trying to use Automator to do batches, like this:

for f in "$@"
do
/usr/local/bin/ffmpeg -i "$f" -vcodec h264 -b:v 1000k -acodec mp2 "${f%.*}.mp4"
done

...unsuccessfully. See error output. Any advice welcome!
screenshot1561243957@2X

Not sure sorry.

@ksharsha

This comment has been minimized.

Copy link
Owner Author

@ksharsha ksharsha commented Aug 28, 2019

pls how do i impliment this code

You just run it on the command line.

@Sharkaboi

This comment has been minimized.

Copy link

@Sharkaboi Sharkaboi commented Jan 26, 2020

anyway i can preserve my subtitles while transcoding and compressing from mkv to mp4? map doesnt seem to work.

@yanwardos

This comment has been minimized.

Copy link

@yanwardos yanwardos commented Apr 9, 2020

Thanks, It works for me
from 137,6MB tobe 61,5MB

@nayankothari

This comment has been minimized.

Copy link

@nayankothari nayankothari commented Jun 3, 2020

Thanks. it still work good.
hint:- if it increase the size of converted video, then try to reduce the bitrate (-b:v 1000k to 500k) for ex.

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

                                to

ffmpeg -i input.mp4 -vcodec h264 -b:v 500k -acodec mp3 output.mp4

@riddhij16

This comment has been minimized.

Copy link

@riddhij16 riddhij16 commented Aug 25, 2020

It is not working for me sir...
showing me unknown encoder 'h264' and same for 'libx264'
I even tried other commands like:
'-i ${_storedVideoOne.path} -vcodec h264 -acodec aac $outputPath';

'-i ${_storedVideoOne.path} -vcodec libx264 -crf 28 $outputPath';

using with flutter_ffmpeg plugin

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.