Results 1 to 10 of 10

Thread: Converting avi files to smaller file size

  1. #1
    Join Date
    Sep 2013
    Beans
    3

    Converting avi files to smaller file size

    Hi!

    My camera produces AVI files rather huge. I want to convert them to smaller files, for archiving. If I could go from 100Mo/min to about 6Mo/min that would be great. How can I do that?

    I use ubuntu 10.04 64 bits.

    Thank you!

  2. #2
    Join Date
    Jul 2013
    Beans
    190

    Re: Converting avi files to smaller file size

    Hello,

    avidemux is an application you can try.

    sudo apt-get install avidemux

    I'm shure you can find an english side about it's functionality. If you have
    no experience with video compression it's a bit learning for you. You can
    get a smaller file if you choose a lower video bitrate and/or a lower audio
    bitrate. A compression results always in lower quality. You have to play
    around with the video bitrate and video resolution to find your satisfiying result.

  3. #3
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,724
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Converting avi files to smaller file size

    You have a couple of choices:

    1) Reduce the size of the video. Because the size of a video file is proportional to the area of the image, reducing a 1920x1080 image to 1280x720 will result in a file that is only 43% as large as the original. Most people with normal eyesight have little ability to discriminate between the two resolutions, especially if it is being viewed on an HDTV at normal living-room distances. I'd suggest this as the long-run strategy. Tell your camera to shoot at 720p rather than 1080p.

    2) Reduce the number of frames shot. Most HDTV video these days is shot at just under 24 frames per second. If your camera is running at some higher rate, like 60 fps, you could tell it to shoot at a slower pace. Unless you spend most of your time filming subjects in rapid motion like athletes or flying birds, you'll probably see little difference at 24 fps.

    As for converting existing AVI files, you might give mencoder a try (sudo apt-get install mencoder). Though it's a little long in the tooth, mencoder was originally developed by the mplayer crew to work with AVI. To rescale a 1080p video to 720p, you can use the command:

    Code:
    mencoder -o output.avi -oac copy -ovc lavc -lavopts vcodec=mpeg4 -vf scale=1280:720 /path/to/input.avi
    This copies the audio track intact, but rescales the video to 1280x720 and encodes it with the mpeg4 codec. Because the output file name ends in .avi, mencoder will use the AVI container format. For testing purposes, you can add the parameter "-endpos 120" to the list, and mencoder will stop after the first two minutes of recoding. If the results look good, remove the -endpos parameter to let it run for the full duration.
    Last edited by SeijiSensei; September 4th, 2013 at 05:37 PM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  4. #4
    Join Date
    Sep 2006
    Beans
    3,480

    Re: Converting avi files to smaller file size

    You can also use ffmpeg:

    1. Get ffmpeg. 10.04 is showing its age, the ffmpeg in the repo is even older, and FFmpeg development is very active. Most simple thing to do is to download a Linux build of ffmpeg, but there is also a step-by-step non-intrusive guide to compile ffmpeg if you prefer.
    2. Then encode:
      Code:
      ffmpeg -i input -codec:v libx264 -preset medium -crf 23 -codec:a aac -strict experimental -b:a 192k -metadata title="A movie by Frdric_Lvesque" output.mp4


    You can tweak preset and crf for video encoding speed and quality. -b:a is audio bitrate (this encoder, aac, requires "-strict experimental"). See the FFmpeg and x264 Encoding Guide and FFmpeg and AAC Encoding Guide for detailed instructions.

  5. #5
    Join Date
    Sep 2013
    Beans
    3

    Re: Converting avi files to smaller file size

    Quote Originally Posted by SeijiSensei View Post
    You have a couple of choices:

    1) Reduce the size of the video.

    2) Reduce the number of frames shot.
    I guess there is a command line to show these info?

  6. #6
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,724
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Converting avi files to smaller file size

    If you install mplayer and play the file from the command line, mplayer will report the information.

    Code:
    $ mplayer /path/to/some/video.avi
    You'll see a result like this:

    Code:
    Playing XXXXXX.avi.
    Detected file format: AVI format (libavformat)
    [lavf] stream 0: video (mpeg4), -vid 0
    [lavf] stream 1: audio (mp3), -aid 0
    VIDEO:  [MP4V]  640x360  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
    Load subtitles in .
    Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
    Asking decoder to use 4 threads if supported.
    Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
    AUDIO: 48000 Hz, 2 ch, floatle, 128.0 kbit/4.17% (ratio: 16000->384000)
    Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
    (I've removed a couple of irrelevant errors like the failed probe for an NVIDIA card.) This file contains a video in 640x360 at 24 frames per second (actually 23.976 for reasons not worth going into here). The video is encoded with mpeg4 and the audio with mp3.

    If you use the excellent GUI front-end for mplayer, called SMPlayer, you can use Ctrl-I to pop up a box with the information about the current video. Installing SMPlayer with "sudo apt-get install smplayer" will automatically install mplayer as well if it is not already on your system.
    Last edited by SeijiSensei; September 5th, 2013 at 12:40 AM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  7. #7
    Join Date
    Jun 2007
    Beans
    11,011

    Re: Converting avi files to smaller file size

    I guess there is a command line to show these info?
    Code:
    sudo apt-get install mediainfo
    mediainfo <filename>
    EDIT: Nvm, mediainfo is not in Lucid repo.

  8. #8
    Join Date
    Sep 2013
    Beans
    3

    Re: Converting avi files to smaller file size

    Thank you everyone, I think I can now move on following your excellent advices.

  9. #9
    Join Date
    Dec 2006
    Beans
    6,922

    Re: Converting avi files to smaller file size

    Quote Originally Posted by SeijiSensei View Post
    If you install mplayer [...]
    Interestingly enough the MPlayer source (from svn) contains a little script in TOOLS/ called midentify.sh which helps identify a few aspects of a video and lines things up so a script can more easily extract information. For example:

    Code:
    andrew@skamandros~/media/videos$ midentify.sh Decay_2012_1080p_HQ.avi 
    ID_VIDEO_ID=0
    ID_AUDIO_ID=1
    ID_CLIP_INFO_NAME0=Software
    ID_CLIP_INFO_VALUE0=Lavf54.50.102
    ID_CLIP_INFO_N=1
    ID_FILENAME=Decay_2012_1080p_HQ.avi
    ID_DEMUXER=avi
    ID_VIDEO_FORMAT=XVID
    ID_VIDEO_BITRATE=2739016
    ID_VIDEO_WIDTH=1920
    ID_VIDEO_HEIGHT=960
    ID_VIDEO_FPS=23.976
    ID_VIDEO_ASPECT=0.0000
    ID_AUDIO_FORMAT=85
    ID_AUDIO_BITRATE=123496
    ID_AUDIO_RATE=0
    ID_AUDIO_NCH=0
    ID_START_TIME=0.00
    ID_LENGTH=4566.98
    ID_SEEKABLE=1
    ID_CHAPTERS=0
    ID_VIDEO_CODEC=ffodivx
    ID_AUDIO_BITRATE=32000
    ID_AUDIO_RATE=44100
    ID_AUDIO_NCH=2
    ID_AUDIO_CODEC=mpg123
    ID_EXIT=EOF
    andrew@skamandros~/media/videos$
    Lots of other goodies in there as well...
    You think that's air you're breathing now?

  10. #10
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,724
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Converting avi files to smaller file size

    Ah, I wondered where that was in Ubuntu. I recall using midentify some years back on a non-Ubuntu system where it didn't carry the .sh extension.

    A quick "locate midentify" shows the script is shipped as /usr/share/mplayer/midentify.sh.
    Last edited by SeijiSensei; September 5th, 2013 at 08:48 PM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •