View Full Version : x264 encoding with too low of a bitrate
morphinapg
6th May 2008, 08:51
I've been testing my ASXGui program and I seem to notice that sometimes (not always) x264 is giving me bad quality due to it encoding with the wrong bitrates sometimes. I usually see this type of error in the log:
x264 [warning]: target: 924.00 kbit/s, expected: 35.62 kbit/s, avg QP: 1.0000
x264 [warning]: try reducing target bitrate or reducing qp_min (currently 1)
It's almost as if during the first pass it's only reading pure black frames and then second pass it's reading the file right. But, it is reading the same AVS script both times so I can't figure this out.
Here is an example of a command that produced that same error:
x264 --pass 1 --bitrate 924 --stats "video.stats" --level 3.0 --ref 3 --mixed-refs --no-fast-pskip --no-cabac --subme 6 --partitions p8x8,b8x8,i4x4,p4x4 --qpmin 1 --vbv-maxrate 10000 --merange 24 --threads auto --thread-input --sar 639:640 --progress --no-psnr --no-ssim --output NUL Avisynth.avs
x264 --pass 2 --bitrate 924 --stats "video.stats" --level 3.0 --ref 3 --mixed-refs --no-fast-pskip --no-cabac --subme 6 --partitions p8x8,b8x8,i4x4,p4x4 --qpmin 1 --vbv-maxrate 10000 --merange 24 --threads auto --thread-input --sar 639:640 --progress --no-psnr --no-ssim --output video.mp4 Avisynth.avs
Dark Shikari
6th May 2008, 08:54
Apparently you're not the only one; someone else reported a similar error a bit ago. But I can't imagine its an x264 issue; it is more likely to be an issue with DirectShow crapping out.
Have you tried outputting during the first pass, and looking at what the actual video looks like from the first pass?
morphinapg
6th May 2008, 09:04
Apparently you're not the only one; someone else reported a similar error a bit ago. But I can't imagine its an x264 issue; it is more likely to be an issue with DirectShow crapping out.
Have you tried outputting during the first pass, and looking at what the actual video looks like from the first pass?
Hmm, just tried that now and this is what I got: (every frame)
http://i32.tinypic.com/j9v5a1.png
Hmm, this is weird. Not sure what that error means.
Dark Shikari
6th May 2008, 09:18
Avisynth/Directshow problem. Nothing to do with x264.
morphinapg
6th May 2008, 09:54
Avisynth/Directshow problem. Nothing to do with x264.
Ah, yes it seems the problem is with CoreAVC. Unfortunately, I can't use ffdshow because it doesn't run fast enough for some of my clips. The weird thing is though, why does it give this error only on first pass? And why does it not happen every time?
Dark Shikari
6th May 2008, 10:14
Ah, yes it seems the problem is with CoreAVC. Unfortunately, I can't use ffdshow because it doesn't run fast enough for some of my clips. The weird thing is though, why does it give this error only on first pass? And why does it not happen every time?Possible reasons for only happening on the first pass: maybe x264 is reading frames fast enough that a certain threshold is reached?
Possible reasons why it doesn't happen every time: Windows sucks?
DarkZell666
6th May 2008, 15:22
Ah, yes it seems the problem is with CoreAVC. Unfortunately, I can't use ffdshow because it doesn't run fast enough for some of my clips. The weird thing is though, why does it give this error only on first pass? And why does it not happen every time?
So you're re-encoding some h.264 stuff back to h.264 right ? Not so much of a problem really (just checking I understood that right), but you're stuck with using ffdshow for encoding, and switching back to CoreAVC for playback, no matter what.
Actually, what's your avs script ? You can also try using FFmpegSource() instead of AviSource() or DirectShowSource(). Do note that AviSource() won't work with h.264 inside AVI unless you have the x264vfw build from DeathTheSheep (with the decoder included), or ffdshow's VFW helper (and enabled it's h.264 support).
LoRd_MuldeR
6th May 2008, 15:45
You can try DGAVCDec instead of CoreAVC/ffdshow + DirectShowSource()
http://neuron2.net/dgavcdec/dgavcdec.html
And of course FFmpegSource() is worth a try:
http://forum.doom9.org/showthread.php?t=127037
[P]ako
6th May 2008, 16:21
While FFDshow doesn't run fast enough, I take it won't crap out on you as often, thus saving you time in the long run, right? If I had a decoder that every now and then would give me trouble, I will ditch it for a slower solution any time. I'd rather be certain that something will work when is required to do so than to cross my fingers expecting it to work.
I was about to suggest you to try Mencoder or FFmpeg but I soon realized that both are based on the same library as ffdshow (libavcodec). So, I thought I could point you to this:
http://www.cccp-project.net/wiki/index.php?title=CCCP_Insurgent
It may or may not help you to solve your problem, but it's worth a spin.
morphinapg
6th May 2008, 21:30
So you're re-encoding some h.264 stuff back to h.264 right ? Not so much of a problem really (just checking I understood that right), but you're stuck with using ffdshow for encoding, and switching back to CoreAVC for playback, no matter what.
Actually, what's your avs script ? You can also try using FFmpegSource()
My source video was a 1920x800 MOV with h264 video, and I'm outputting to 640x272 for my iPhone.
I was using DirectshowSource, but will ffmpegsource() work with an MOV?
DarkZell666
6th May 2008, 21:42
My source video was a 1920x800 MOV with h264 video, and I'm outputting to 640x272 for my iPhone.
I was using DirectshowSource, but will ffmpegsource() work with an MOV?
It should yeah, just have a try :] (http://forum.doom9.org/showthread.php?t=127037&highlight=ffmpegsource)
LoRd_MuldeR
6th May 2008, 22:28
I was using DirectshowSource, but will ffmpegsource() work with an MOV?
Yes, it does. It handles dozens of container, audio and video formats :)
Nevertheless DGAVCDec/AVCSource() (http://neuron2.net/dgavcdec/dgavcdec.html) was especially developed for AVC aka H.264 sources.
It doesn't support MOV, but it likes raw streams. So you'd have to extract/demux the MOV file first (using MP4Box/YAMB).
And you must index the H.264 with DGAVCIndex to create the .dga file...
morphinapg
6th May 2008, 23:23
Yes, it does. It handles dozens of container, audio and video formats :)
Nevertheless DGAVCDec/AVCSource() (http://neuron2.net/dgavcdec/dgavcdec.html) was especially developed for AVC aka H.264 sources.
It doesn't support MOV, but it likes raw streams. So you'd have to extract/demux the MOV file first (using MP4Box/YAMB).
And you must index the H.264 with DGAVCIndex to create the .dga file...
I would use DGAVCIndex if it supported mp4/mkv/mov as input, I use DGIndex for mpg files already in ASXGui, but the demuxing to raw stream first would just add another step, making the encode time even longer. For now, ffmpegsource() seems to be fixing my problem. I'll stick with ffmpegsource until DGAVCIndex has support for more than just raw streams (such as mp4/mkv/mov)
LoRd_MuldeR
6th May 2008, 23:30
I don't think DGAVCIndex will support any "containers", except for Raw/Elementary Streams and Transport Streams...
morphinapg
6th May 2008, 23:33
I don't think DGAVCIndex will support any "containers", except for Raw/Elementary Streams and Transport Streams...
Well, that's unfortunate. Is there any reason why not?
LoRd_MuldeR
7th May 2008, 00:18
Well, that's unfortunate. Is there any reason why not?
Streams that already are embedded in a suitable container don't need to be indexed :p
Blue_MiSfit
7th May 2008, 21:44
Indeed.
It's sort of a pain I agree, but it does work surprisingly well, and provides a very familiar workflow if you're used to DGIndex.
The naming conventions confuse me - but I'm sure Donald has his reasons!
Anyway, I find ffmpegsource to be very useful for decoding H.264 into AviSynth. The first open takes a long time (because - big surprise - it's building an index), but after that it's quite responsive.
I use it a lot for doing frame by frame comparisons of different encodes, along with Import(...) - StackVertical(...), StackHorizontal(...), or Interleave(...) - or ShowFiveVersions() if I'm feeling saucy and have a 30" LCD handy :D
~MiSfit
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.