Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-11-2009, 12:40 PM   #1
LQ Newbie
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
target file size when encoding video

I was just wondering how to set a target file size when encoding media (on the command line).

I prefer ffmpeg over mencoder and I am trying to rip DVD VOB files to H.264 inside mp4 containers (libx264).

All of the examples I found say to use mencoder with a negative bitrate e.g. -700000 for a 700mb output file. However, I have tried copying several of these example command lines (even ones dealing with divx etc) verbatim and I never get the target file size. With a 1.2gb VOB file, I get roughly 250mb output using mencoder if I use -700000 or -175000.

A few people have told me to use Windows tools or to play it and at the same time, capture the screen output. I don't want to do either of these.

So, again, how can this be done on the command line (preferably with ffmpeg but I will settle for anything). If any maths is involved to calculate bitrates or whatever then I have no problem with that either. As I understand it, it requires 2 pass VBR but I have had no luck even trying to give it calculated bitrates.
Old 06-11-2009, 02:53 PM   #2
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I know there's the '-fs' option for ffmpeg but it might just always truncate. I wanted to try it with 2 pass encoding, maybe it has a different effect ?

Anyway for constant bitrate you can calculate the output size like it says here:

You can compute the bitrate with the following equation: bitrate = (target_size_in_Mbytes - sound_size_in_Mbytes) * 1024 * 1024 / length_in_secs * 8 / 1000 For instance, to squeeze a two-hour movie onto a 702MB CD, with 60MB of audio track, the video bitrate will have to be: (702 - 60) * 1024 * 1024 / (120*60) * 8 / 1000 = 740kbps
For variable bitrate, what I usually do is use this formula to get about what bitrate I would want, then use the '-qscale' option and watch the bitrate, if it hovers or averages to around this rate, then you are good to go (usually if it's around 800 or 900 it's good, sometimes it goes down to 600 or up to 1200, but overall the average should be about 800 to 900). If it goes over you can just cut off the credits at the end of the movie, which I usually do anyway.

Last edited by H_TeXMeX_H; 06-11-2009 at 02:55 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reduce video file size? leosgb Linux - General 9 06-15-2007 12:43 PM
Minimizing size of target RFS on host computer rsashok Linux - General 0 01-10-2007 02:06 PM
Video Encoding. barn63 Linux - Hardware 12 09-22-2006 01:33 PM
Video encoding: rm to Mpeg Harp00 Linux - General 6 02-28-2006 03:09 PM
Video Encoding Software NomadABC Linux - Software 3 01-24-2005 11:23 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration