Skip to content

Instantly share code, notes, and snippets.

@ksharsha
Created October 31, 2016 21:54
Show Gist options
  • Save ksharsha/b06d184391290bc3b87fdadadb73c5bc to your computer and use it in GitHub Desktop.
Save ksharsha/b06d184391290bc3b87fdadadb73c5bc to your computer and use it in GitHub Desktop.
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
@eshanokpe
Copy link

pls how do i impliment this code

@ksharsha
Copy link
Author

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
Copy link
Author

pls how do i impliment this code

You just run it on the command line.

@Sharkaboi
Copy link

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

@yanwardos
Copy link

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

@nayankothari
Copy link

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
Copy link

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

@gonnavis
Copy link

gonnavis commented Jan 9, 2021

I tried mp2 and mp3, all no audio on ios13.6, windows and android ok.

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

Finally I use with no -acodec, all ok, and file size no big different.

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

@RENANZG
Copy link

RENANZG commented Mar 31, 2024

One-line bash script for Debian GNU/Linux

$ cd ~/Videos
$ for file in .mp4; do ffmpeg -i "$file" -vf "scale=-2:240" "Output-${file%.}.mp4"; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment