LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   target file size when encoding video (https://www.linuxquestions.org/questions/linux-software-2/target-file-size-when-encoding-video-732254/)

ghell 06-11-2009 12:40 PM

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.

H_TeXMeX_H 06-11-2009 02:53 PM

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:
http://www.mplayerhq.hu/DOCS/HTML/en...vd-mpeg4-2pass

Quote:

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.


All times are GMT -5. The time now is 05:41 AM.