Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
FORUMS:listlist (w/ descriptions)archivetagssearchhall of famerecent posts

MPEG-4 bitrate troubles.

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Ben SouthallMPEG-4 bitrate troubles.
by on Jun 8, 2010 at 7:55:35 pm

Hello everyone,

I have recently been trying to encode some videos to h264 or mp4, but ffmpeg seems to ignore any bitrate parameters I pass to it. I've tried maxrate, tolerance, etc. and have had it output at the bitrate it seems to want to use every time. I've even encoded it to mpeg at a lower rate, and then converted it to h264/mpeg4, and sill have no luck. Below is an example of an average command line entry (on windows of some sort)

ffmpeg -i infile.extension -b 100k -vcodec libx264 outfile.mp4 (or outfile.m4v)

Any advice would be much appreciated.

Thank you.


Return to posts index
Reply   Like  

Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 9, 2010 at 12:09:06 am

It looks like you are hitting the minimum bitrate threshold for the image size you are using. 100k is very low and is less than what is required to create a stream at SD or HD image sizes.

Have a look at http://forums.creativecow.net/readpost/291/4 for a brief description of minimum and maximum bitrates.

Try reducing the output image size or frame rate until you get the result you desire.

Also, can you post the full FFmpeg readout so I can see the image size/frame rate and input/output bitrates?

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  

Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 9, 2010 at 9:31:02 pm

Hi Michael,

I would've thought that theproblem might be a minimum bitrate, but the files were coming out at over 30mb for a two minute 320x480. In fact, they were larger than when they started, and some of the original files used h264 anyway. What puzzles me is that some videos that I encoded worked a treat, whilst most of them still won't go down in quality. As you can see below, the q factor is 31, which isn't right. Sorry about the bitrate I stated, 100k is low, but as I have tried to encode this so many times, I'm not that wise on what bitrates would be appropriate right now.

Thanks for your help.

Example 1: 475kb/s h264 > 400k h264. This was a superb size anyway, but ffmpeg has actually increased the bitrate.

C:\Users\jack\iPod\XP Videos>ffmpeg -i "ashes*" -b 400k -vcodec libx264 Quattr
o.mp4
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er --enable-avfilter-lavf --enable-pthreads --enable-avisynth --enable-libfaac -
-enable-libfaad --enable-libmp3lame --enable-libspeex --enable-libtheora --enabl
e-libvorbis --enable-libxvid --enable-libx264 --enable-memalign-hack
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]

Seems stream 1 codec frame rate differs from container frame rate: 50.00 (50/1)
-> 25.00 (25/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Ashes To Ashes Series 3 Episode 8 You'v
e Killed My Quattro!.mp4':
Duration: 00:01:08.40, start: 0.000000, bitrate: 457 kb/s
Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16
Stream #0.1(und): Video: h264, yuv420p, 480x272, 25 tbr, 25 tbn, 50 tbc
Output #0, mp4, to 'Quattro.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 480x272, q=2-31, 400 kb/s, 90k tb
n, 25 tbc
Stream #0.1(und): Audio: libfaac, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Stream #0.0 -> #0.1
[libx264 @ 0x1eb6f10]using cpu capabilities: MMX2 SSE2 SSE3 Cache64
[libx264 @ 0x1eb6f10]profile Baseline, level 2.1
Press [q] to stop encoding
frame= 1710 fps= 43 q=2288831.0 Lsize= 4419kB time=68.29 bitrate= 530.1kbits/
s
video:3848kB audio:533kB global headers:1kB muxing overhead 0.857215%
[libx264 @ 0x1eb6f10]slice I:143 Avg QP:19.92 size: 7916
[libx264 @ 0x1eb6f10]slice P:1567 Avg QP:21.79 size: 1792
[libx264 @ 0x1eb6f10]mb I I16..4: 26.2% 0.0% 73.8%
[libx264 @ 0x1eb6f10]mb P I16..4: 10.8% 0.0% 0.0% P16..4: 61.2% 0.0% 0.0%
0.0% 0.0% skip:28.1%
[libx264 @ 0x1eb6f10]final ratefactor: 23.65
[libx264 @ 0x1eb6f10]SSIM Mean Y:0.9859234
[libx264 @ 0x1eb6f10]kb/s:460.8

Example 2 Here, it would seem that the bitrate is actually around 600 kb/s, but the output ofr this video has always been about 1500. I have tried this in default mp4 format, and there was little difference.

C:\Users\jack\iPod\XP Videos>ffmpeg -i "caram*".* -b 375k -vcodec libx264 car
.mp4
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er --enable-avfilter-lavf --enable-pthreads --enable-avisynth --enable-libfaac -
-enable-libfaad --enable-libmp3lame --enable-libspeex --enable-libtheora --enabl
e-libvorbis --enable-libxvid --enable-libx264 --enable-memalign-hack
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Mar 16 2009 16:09:18, gcc: 4.2.4 [Sherpya]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Caramell Dansen.mp4':
Duration: 00:02:58.04, start: 0.000000, bitrate: 666 kb/s
Stream #0.0(und): Video: mpeg4, yuv420p, 480x270 [PAR 1:1 DAR 16:9], 25 tbr,
25 tbn, 25 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16
File 'car.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'car.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 480x270 [PAR 1:1 DAR 16:9], q=2-3
1, 375 kb/s, 90k tbn, 25 tbc
Stream #0.1(und): Audio: libfaac, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
[libx264 @ 0x3afa50]width or height not divisible by 16 (480x270), compression w
ill suffer.
[libx264 @ 0x3afa50]using SAR=1/1
[libx264 @ 0x3afa50]using cpu capabilities: MMX2 SSE2 SSE3 Cache64
[libx264 @ 0x3afa50]profile Baseline, level 2.1
Press [q] to stop encoding
frame= 2510 fps= 40 q=31.0 size= 19580kB time=100.29 bitrate=1599.4kbits/s
frame= 2533 fps= 40 q=29.0 size= 19724kB time=101.19 bitrate=1596.8kbits/s
frame= 2558 fps= 40 q=31.0 size= 19838kB time=102.19 bitrate=1590.3kbits/s
frame= 2580 fps= 40 q=31.0 size= 20009kB time=103.07 bitrate=1590.3kbits/s
frame= 2601 fps= 40 q=31.0 size= 20181kB time=103.91 bitrate=1591.0kbits/s
frame= 2620 fps= 40 q=31.0 size= 20376kB time=104.68 bitrate=1594.6kbits/s
frame= 2640 fps= 40 q=31.0 size= 20581kB time=105.49 bitrate=1598.3kbits/s
frame= 2658 fps= 40 q=31.0 size= 20796kB time=106.21 bitrate=1604.0kbits/s
frame= 2677 fps= 40 q=29.0 size= 20994kB time=106.95 bitrate=1608.1kbits/s
frame= 2695 fps= 40 q=31.0 size= 21196kB time=107.67 bitrate=1612.7kbits/s
frame= 2713 fps= 40 q=29.0 size= 21407kB time=108.39 bitrate=1617.9kbits/s
frame= 2731 fps= 40 q=31.0 size= 21624kB time=109.11 bitrate=1623.5kbits/s
frame= 2749 fps= 40 q=29.0 size= 21890kB time=109.83 bitrate=1632.7kbits/s
frame= 2768 fps= 40 q=31.0 size= 22108kB time=110.60 bitrate=1637.5kbits/s
frame= 2787 fps= 40 q=31.0 size= 22299kB time=111.36 bitrate=1640.4kbits/s
frame= 2805 fps= 40 q=31.0 size= 22538kB time=112.08 bitrate=1647.3kbits/s
frame= 2822 fps= 40 q=31.0 size= 22767kB time=112.78 bitrate=1653.7kbits/s
frame= 2841 fps= 40 q=31.0 size= 22985kB time=113.52 bitrate=1658.7kbits/s
frame= 2858 fps= 40 q=31.0 size= 23168kB time=114.20 bitrate=1662.0kbits/s
frame= 2877 fps= 40 q=31.0 size= 23369kB time=114.96 bitrate=1665.3kbits/s
frame= 2895 fps= 40 q=31.0 size= 23566kB time=115.68 bitrate=1668.8kbits/s
frame= 2914 fps= 40 q=31.0 size= 23770kB time=116.47 bitrate=1671.9kbits/s
frame= 2933 fps= 40 q=31.0 size= 23961kB time=117.19 bitrate=1674.9kbits/s
frame= 2952 fps= 40 q=31.0 size= 24163kB time=117.96 bitrate=1678.1kbits/s
frame= 2971 fps= 39 q=31.0 size= 24361kB time=118.72 bitrate=1680.9kbits/s
frame= 2990 fps= 39 q=31.0 size= 24531kB time=119.49 bitrate=1681.8kbits/s
frame= 3009 fps= 39 q=31.0 size= 24735kB time=120.23 bitrate=1685.3kbits/s
frame= 3026 fps= 39 q=31.0 size= 24953kB time=120.93 bitrate=1690.3kbits/s
frame= 3048 fps= 39 q=31.0 size= 25136kB time=121.81 bitrate=1690.4kbits/s
frame= 3076 fps= 40 q=31.0 size= 25215kB time=122.95 bitrate=1680.1kbits/s
frame= 3103 fps= 40 q=31.0 size= 25304kB time=123.99 bitrate=1671.8kbits/s
frame= 3130 fps= 40 q=31.0 size= 25398kB time=125.11 bitrate=1663.0kbits/s
frame= 3157 fps= 40 q=29.0 size= 25492kB time=126.15 bitrate=1655.4kbits/s
frame= 3183 fps= 40 q=31.0 size= 25597kB time=127.20 bitrate=1648.5kbits/s
frame= 3212 fps= 40 q=31.0 size= 25704kB time=128.36 bitrate=1640.4kbits/s
frame= 3243 fps= 40 q=31.0 size= 25781kB time=129.59 bitrate=1629.7kbits/s
frame= 3272 fps= 40 q=31.0 size= 25870kB time=130.75 bitrate=1620.8kbits/s
frame= 3298 fps= 40 q=31.0 size= 25974kB time=131.80 bitrate=1614.5kbits/s
frame= 3317 fps= 40 q=31.0 size= 26149kB time=132.56 bitrate=1616.0kbits/s
frame= 3336 fps= 40 q=31.0 size= 26355kB time=133.33 bitrate=1619.3kbits/s
frame= 3353 fps= 40 q=31.0 size= 26608kB time=134.00 bitrate=1626.6kbits/s
frame= 3372 fps= 40 q=31.0 size= 26842kB time=134.77 bitrate=1631.6kbits/s
frame= 3395 fps= 40 q=31.0 size= 27053kB time=135.67 bitrate=1633.4kbits/s
frame= 3413 fps= 40 q=31.0 size= 27260kB time=136.39 bitrate=1637.3kbits/s
frame= 3433 fps= 40 q=29.0 size= 27461kB time=137.21 bitrate=1639.6kbits/s
frame= 3452 fps= 40 q=31.0 size= 27671kB time=137.95 bitrate=1643.2kbits/s
frame= 3469 fps= 40 q=29.0 size= 27881kB time=138.67 bitrate=1647.1kbits/s
frame= 3493 fps= 40 q=29.0 size= 28048kB time=139.60 bitrate=1645.9kbits/s
frame= 3516 fps= 40 q=31.0 size= 28183kB time=140.53 bitrate=1642.9kbits/s
frame= 3541 fps= 40 q=29.0 size= 28296kB time=141.53 bitrate=1637.9kbits/s
frame= 3563 fps= 40 q=31.0 size= 28448kB time=142.41 bitrate=1636.5kbits/s
frame= 3583 fps= 40 q=31.0 size= 28613kB time=143.20 bitrate=1636.9kbits/s
frame= 3606 fps= 40 q=31.0 size= 28771kB time=144.13 bitrate=1635.3kbits/s
frame= 3627 fps= 40 q=31.0 size= 28939kB time=144.99 bitrate=1635.1kbits/s
frame= 3647 fps= 40 q=31.0 size= 29107kB time=145.75 bitrate=1635.9kbits/s
frame= 3665 fps= 40 q=31.0 size= 29310kB time=146.47 bitrate=1639.3kbits/s
frame= 3682 fps= 40 q=31.0 size= 29530kB time=147.17 bitrate=1643.8kbits/s
frame= 3699 fps= 40 q=31.0 size= 29779kB time=147.86 bitrate=1649.8kbits/s
frame= 3717 fps= 40 q=31.0 size= 29961kB time=148.58 bitrate=1651.8kbits/s
frame= 3736 fps= 40 q=31.0 size= 30142kB time=149.33 bitrate=1653.6kbits/s
frame= 3757 fps= 40 q=29.0 size= 30318kB time=150.16 bitrate=1654.0kbits/s
frame= 3777 fps= 40 q=31.0 size= 30518kB time=150.95 bitrate=1656.2kbits/s
frame= 3797 fps= 40 q=31.0 size= 30692kB time=151.77 bitrate=1656.7kbits/s
frame= 3817 fps= 40 q=29.0 size= 30860kB time=152.60 bitrate=1656.6kbits/s
frame= 3839 fps= 40 q=31.0 size= 31023kB time=153.44 bitrate=1656.3kbits/s
frame= 3856 fps= 40 q=31.0 size= 31230kB time=154.11 bitrate=1660.1kbits/s
frame= 3877 fps= 40 q=29.0 size= 31428kB time=154.97 bitrate=1661.3kbits/s
frame= 3900 fps= 40 q=31.0 size= 31591kB time=155.88 bitrate=1660.3kbits/s
frame= 3915 fps= 40 q=31.0 size= 31777kB time=156.50 bitrate=1663.4kbits/s
frame= 3934 fps= 40 q=31.0 size= 31979kB time=157.25 bitrate=1666.0kbits/s
frame= 3950 fps= 40 q=31.0 size= 32179kB time=157.87 bitrate=1669.8kbits/s
frame= 3967 fps= 40 q=31.0 size= 32423kB time=158.57 bitrate=1675.1kbits/s
frame= 3991 fps= 40 q=31.0 size= 32553kB time=159.52 bitrate=1671.7kbits/s
frame= 4009 fps= 40 q=29.0 size= 32697kB time=160.24 bitrate=1671.6kbits/s
frame= 4009 fps= 35 q=29.0 size= 32705kB time=160.26 bitrate=1671.7kbits/s
frame= 4027 fps= 35 q=31.0 size= 32900kB time=160.96 bitrate=1674.4kbits/s
frame= 4046 fps= 35 q=31.0 size= 33106kB time=161.73 bitrate=1676.9kbits/s
frame= 4068 fps= 35 q=31.0 size= 33295kB time=162.61 bitrate=1677.4kbits/s
frame= 4092 fps= 35 q=31.0 size= 33429kB time=163.56 bitrate=1674.3kbits/s
frame= 4114 fps= 35 q=31.0 size= 33594kB time=164.44 bitrate=1673.6kbits/s
frame= 4132 fps= 35 q=31.0 size= 33754kB time=165.16 bitrate=1674.2kbits/s
frame= 4152 fps= 35 q=31.0 size= 33943kB time=165.95 bitrate=1675.5kbits/s
frame= 4170 fps= 35 q=31.0 size= 34146kB time=166.67 bitrate=1678.3kbits/s
frame= 4188 fps= 35 q=31.0 size= 34352kB time=167.39 bitrate=1681.1kbits/s
frame= 4206 fps= 35 q=31.0 size= 34571kB time=168.11 bitrate=1684.6kbits/s
frame= 4225 fps= 35 q=29.0 size= 34784kB time=168.88 bitrate=1687.3kbits/s
frame= 4244 fps= 35 q=31.0 size= 35010kB time=169.64 bitrate=1690.6kbits/s
frame= 4263 fps= 35 q=31.0 size= 35187kB time=170.39 bitrate=1691.7kbits/s
frame= 4286 fps= 35 q=31.0 size= 35338kB time=171.32 bitrate=1689.8kbits/s
frame= 4313 fps= 35 q=31.0 size= 35458kB time=172.41 bitrate=1684.8kbits/s
frame= 4345 fps= 35 q=29.0 size= 35536kB time=173.71 bitrate=1675.9kbits/s
frame= 4413 fps= 36 q=31.0 size= 35546kB time=176.40 bitrate=1650.8kbits/s
frame= 4451 fps= 36 q=2288831.0 Lsize= 35649kB time=177.82 bitrate=1642.3kbits
/s
video:34192kB audio:1360kB global headers:1kB muxing overhead 0.272037%
[libx264 @ 0x3afa50]slice I:371 Avg QP:28.63 size: 14438
[libx264 @ 0x3afa50]slice P:4080 Avg QP:29.87 size: 7269
[libx264 @ 0x3afa50]mb I I16..4: 24.3% 0.0% 75.7%
[libx264 @ 0x3afa50]mb P I16..4: 17.6% 0.0% 0.0% P16..4: 66.8% 0.0% 0.0%
0.0% 0.0% skip:15.6%
[libx264 @ 0x3afa50]final ratefactor: 34.72
[libx264 @ 0x3afa50]SSIM Mean Y:0.9753285


Return to posts index
Reply   Like  


Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 10, 2010 at 2:08:53 am

Seems strange that it is not consistent across files.

You should certainly be able to achieve those bitrates at those image sizes.

You are running an old version of FFmpeg. libx264 requires presets to work in newer builds. Try adding "-vpre hq" to your command.

The latest stable build is 0.5.2. I would also recommend investigating the latest SVN build which is what I use.

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  

Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 10, 2010 at 5:40:04 pm

I'm afraid that it couldn't find the preset file. I seem to be using version 0.5. I've never got make to work before, so I downloaded a prebuilt windows binary from somewhere. Do you know anywhere that gives a good make tutorial?


Return to posts index
Reply   Like  

Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 11, 2010 at 12:12:10 am

For windows help look at:
http://ffmpeg.arrozcru.org/ from http://www.ffmpeg.org

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  


Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 11, 2010 at 3:35:52 pm

Hey,

I've downloaded r23571, the most recent build, and I get an error message from libx264 stating that there are broken ffmpeg default settings detected, and that I should use a preset, but it still doesn't recognise -vpre hq.

Thanks,

Ben


Return to posts index
Reply   Like  

Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 11, 2010 at 3:56:43 pm

I've just tried encoding it with normal mp4, and I still got an output bitrate larger than the input or the bitrate I spexcified.

:S

If you hae any ideas, I'd appreciate it greatly.

Cheers.


Return to posts index
Reply   Like  

Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 11, 2010 at 11:45:27 pm

I am stumped.

Try to force the q factor with -qmin 1 -qmax 1 and see if this has an effect.

For the presets: look into your installed FFmpeg folder and open the subfolder called ffpresets. The file for the -vpre hq setting is called "libx264-hq.ffpreset". Does that exist on your install?

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  


Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 12, 2010 at 2:13:24 pm

I'm afraid that this made the bitrate even larger!?!?!?

I tried this with flv as well, and the same thing happened. I could understand if this was on just one pc, but I've tried it on three, with different os, and astilll, it seems to ignore me.


In the end, I downloaded mencoder instead, and that works pretty well.
Thanks for all your help anyway,
Ben


Return to posts index
Reply   Like  

Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 13, 2010 at 1:02:54 am

[Ben Southall] "I'm afraid that this made the bitrate even larger!?!?!?"

Good. This means these are overriding the -b setting. -qmin 1 -qmax 1 should produce the highest quality. (1 is highest, 31 is lowest) Now reduce them until you get the result you desire (or to see the lowest, set them to -qmin 31 -qmax -31) You can also use -qscale n to set an average but it will deviate during encoding.

From the FFmpeg documentation:
The parameter 'q' which is displayed while encoding is the current quantizer. The value 1 indicates that a very good quality could be achieved. The value 31 indicates the worst quality. If q=31 appears too often, it means that the encoder cannot compress enough to meet your bitrate. You must either increase the bitrate, decrease the frame rate or decrease the frame size.

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  

Michael RampeRe: MPEG-4 bitrate troubles.
by on Jun 13, 2010 at 1:09:42 am

Did some digging and found out that:

AVC (H.264) uses a different quantizer scale (1-51) than most other codecs (1-31)

Try -qmin 51 -qmax 51

This should give you the absolute minimum for AVC/H.264/Mpeg4Layer10 video.

Michael

"half-way to world domination A.K.A. the belligerent blue bike shed"


Return to posts index
Reply   Like  


Ben SouthallRe: MPEG-4 bitrate troubles.
by on Jun 13, 2010 at 9:32:25 am

Thanks for that,

I always got q=31 during conversion, so I assumed that 31 was the highest possible as the videos were the same as the originals. I will try using the q scale as soon as I can.


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]