Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have couple of (over 100) mp4 video files, which are approximately 15 MB each. I think they are unnecessarily high quality videos, I want to lower the sizes of each, by reducing the quality. I know I can do this with ffmpeg, but I am not familiar with concepts like bitrates, codes etc, so can anyone help with that? This is metadata of one of them:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '16.8-AnomalyDetection-AnomalyDetectionUsingTheMultivariateGaussianDistribution-OPTIONAL.mp4':
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2011-12-06 18:56:20
  Duration: 00:14:03.40, start: 0.000000, bitrate: 176 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1000x562 [SAR 1:1 DAR 500:281], 45 kb/s, 15 fps, 15 tbr, 15 tbn, 30 tbc
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 127 kb/s
      creation_time   : 2011-12-06 18:56:20
      handler_name    : GPAC ISO Audio Handler
share|improve this question
You do realize that the audio is responsible for over 70% of your file size? – Daniel Beck Jan 8 '12 at 22:24
No I do not :) As I say, I am not particularly good with audio and video encodings. – yasar Jan 8 '12 at 22:26
You can see the lines that contain Audio and Video, with the former having 127 kb/s and the latter 45 kb/s, making up almost all of the total 176 kb/s. – Daniel Beck Jan 8 '12 at 22:31

I ended up doing this:

for d in $(find .. -maxdepth 1 -name '*.mp4'); do 
    filename=$(echo "$d" | sed 's:../::')
    ffmpeg -i "$d" -b:a 64k -ac 1 -ar 22050 -acodec libmp3lame -s\
    640x480 -r 10 "$filename" && rm --interactive=never "$d"

Options stands for:

  • -b:a -> Set audio bitrate
  • -ac -> Set the number of audio channels.
  • -ar -> Set the audio sampling frequency
  • -s -> Set video dimensions.
  • -r -> Set frames per second
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .