Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th November 2010, 20:02   #1  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
FFmpeg : 2-Pass encoding - Xvid vs h264

Hi all !

I think I once saw this kind of question asked once on this forum, but I couldn't find it back. And anyways I believe no clear answer had been given on this particular subject, so I prefer to ask it again.

So I'm trying to test 2-pass encoding, and I'm having a hard time juste making my command lines work in FFmpeg.

First, here are the command lines I use. The first ones were to encode to Xvid :
Code:
ffmpeg.exe -y -i "C:/Documents and Settings/user/Desktop/video test/big_buck_bunny.avi" -pass 1 -passlogfile 2passtry.log -threads 2 -vcodec libxvid -vtag XVID -f mp4 -aspect 16:9 -r 25 -s 1280x720 -b 2000kb -minrate 2000kb -maxrate 2000kb -bufsize 2048k -an "C:/Documents and Settings/user/Desktop/video test results/bbb_2pass_tryr2_1.mp4"
ffmpeg.exe -y -i "C:/Documents and Settings/user/Desktop/video test/big_buck_bunny.avi" -pass 2 -passlogfile 2passtry.log -threads 2 -vcodec libxvid -vtag XVID -f mp4 -aspect 16:9 -r 25 -s 1280x720 -b 2000kb -minrate 2000kb -maxrate 2000kb -bufsize 2048k -acodec libfaac -ac 2 -ab 128kb -ar 44100 "C:/Documents and Settings/user/Desktop/video test results/bbb_2pass_tryr2_1.mp4"
And the second set was to encode in h264 :

Code:
ffmpeg.exe -y -i "C:/Documents and Settings/user/Desktop/video test/big_buck_bunny.avi" -pass 1 -passlogfile 2passtry.log -threads 2 -vcodec libx264 -f mp4 -aspect 16:9 -r 25 -s 1280x720 -b 512kb -minrate 512kb -maxrate 512kb -bufsize 2048k -an "C:/Documents and Settings/user/Desktop/video test results/bbb_2pass_tryr2_1.mp4"
ffmpeg.exe -y -i "C:/Documents and Settings/user/Desktop/video test/big_buck_bunny.avi" -pass 2 -passlogfile 2passtry.log -threads 2 -vcodec libx264 -f mp4 -aspect 16:9 -r 25 -s 1280x720 -b 512kb -minrate 512kb -maxrate 512kb -bufsize 2048k -acodec libfaac -ac 2 -ab 128kb -ar 44100 "C:/Documents and Settings/user/Desktop/video test results/bbb_2pass_tryr2_1.mp4"
(The code was given to me on another forum and I wanted to see if it worked "as is" and then adapt it to my needs)

As you can see, both sets are fairly similar, except for the -vcodec.
When I run the Xvid lines, it works perfectly. But when I run the h264 lines, it won't process the 2nd pass. Instead the command prompt will give me :
[libx264 @ 0x1725010]using SAR=1/1
[libx264 @ 0x1725010]using cpu capabilities: MMX2 SSE2Fast SSSE3 PHADD SSE4.2

And then stop and prevent me from writing anything more in the window. Also, my .log file is empty (don't know if it's normal)...

Any idea why it would do that ?

Note that I only use Windows' command prompt. I don't know if some GUIs are made to circumvent this problem, but I don't use any and don't really intend to...

Last edited by Klagar; 4th November 2010 at 20:03. Reason: Error in the code
Klagar is offline   Reply With Quote
Old 4th November 2010, 20:03   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,690
You're not following the guide.
Dark Shikari is offline   Reply With Quote
Old 4th November 2010, 20:35   #3  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
In fact I did follow the guide. At first.

First the -vpre parameter didn't work for me because I don't know where the .ffpreset files are supposed to be. I found people with the same problem, tried their solutions, but they didn't work in my particular build, and right now I don't have either the time or the skill to rebuild my FFmpeg and retry. So I simply tested the lines without the -vpre :
Code:
ffmpeg -y -i INPUT -an -pass 1 -vcodec libx264 -b 15000kb -bt 15000kb -threads 0 OUTPUT
ffmpeg -y -i INPUT -acodec libfaac -ab 128k -pass 2 -vcodec libx264 -b 15000kb -bt 15000kb -threads 0 OUTPUT
and it gave me the following error :
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

I asked around for explanations/solutions, and the best I came up with is this guy who gave me his lines, which I presented in my last post, pretending they worked for him, and I decided to give it a try.

So maybe you can help me demystify what goes wrong with Swain's lines ? That would be at the very least as good as figuring out the first lines I presented. Though I would also appreciate if someone could clarify why my first commands worked with Xvid but didn't with h264.

BTW, sorry if I give a lot of code and write large messages, but I want to give as much detail as possible so nobody has to ask me for more, and I don't always know exactly what info you might need to better understand where my errors lie...
Klagar is offline   Reply With Quote
Old 4th November 2010, 20:38   #4  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,690
Quote:
Originally Posted by Klagar View Post
In fact I did follow the guide. At first.

First the -vpre parameter didn't work for me because I don't know where the .ffpreset files are supposed to be.
They come with ffmpeg. If you don't have them, go redownload the latest version.

Quote:
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
ffmpeg prints the following right above that in GIANT RED LETTERS:

[libx264 @ 01891220] broken ffmpeg default settings detected
[libx264 @ 01891220] use an encoding preset (vpre)
Dark Shikari is offline   Reply With Quote
Old 4th November 2010, 21:05   #5  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Quote:
Originally Posted by Dark Shikari View Post
They come with ffmpeg. If you don't have them, go redownload the latest version.
I know they do. I have the C:\Program Files\ffmpeg5\ffpresets folder, and all .ffpreset files are in it. But looks like FFmpeg refuses to see them. I tried to copy them in the root folder (C:\Program Files\ffmpeg5) but it did nothing more.

I use version 0.5. Has there been such a major update since ? I'll look up if I can update to the latest version. But in the environment I'm in, it's just not the most optimal solution at the present time, because the group I work for uses version 0.5 and it would be very time- and resource-consuming to change it. So I'll see what arguments I can find (other than "being up to date") to convince them to update. But in the meantime, if a solution can be found that doesn't require it, that'd be the best.

Quote:
Originally Posted by Dark Shikari View Post
ffmpeg prints the following right above that in GIANT RED LETTERS:
[libx264 @ 01891220] broken ffmpeg default settings detected
[libx264 @ 01891220] use an encoding preset (vpre)
No. What I have is :
[libx264 @ 0x177d010]using SAR=1/1
[libx264 @ 0x177d010]using cpu capabilities: MMX2 SSE2Fast SSSE3 PHADD SSE4.2
[libx264 @ 0x177d010]ratecontrol_init: can't open stats file
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

I found nowhere the warning you mention...
Klagar is offline   Reply With Quote
Old 4th November 2010, 21:09   #6  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,690
Quote:
Originally Posted by Klagar View Post
I know they do. I have the C:\Program Files\ffmpeg5\ffpresets folder, and all .ffpreset files are in it. But looks like FFmpeg refuses to see them. I tried to copy them in the root folder (C:\Program Files\ffmpeg5) but it did nothing more.

I use version 0.5. Has there been such a major update since ? I'll look up if I can update to the latest version. But in the environment I'm in, it's just not the most optimal solution at the present time, because the group I work for uses version 0.5 and it would be very time- and resource-consuming to change it. So I'll see what arguments I can find (other than "being up to date") to convince them to update. But in the meantime, if a solution can be found that doesn't require it, that'd be the best.
Your ffmpeg and x264 are years old and vastly worse as a result (speed and compression wise). Furthermore, by not using a -vpre, you're using the incredibly broken ffmpeg default settings, which will produce terrible results, both speed-wise and compression-wise.
Dark Shikari is offline   Reply With Quote
Old 4th November 2010, 22:05   #7  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Is version SVN-r25669 really the latest version for Windows ? Would seem so, but I just want to be sure.
If so, does this version operate on Linux as well ?
Klagar is offline   Reply With Quote
Old 4th November 2010, 22:22   #8  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,643
Quote:
Originally Posted by Klagar View Post
Is version SVN-r25669 really the latest version for Windows ?
Latest can be current SVN if you build it yourself. But r25669 is recent enough.

Quote:
If so, does this version operate on Linux as well ?
Well, why wouldn't it? Most of the FFmpeg developers use Linux.
nm is offline   Reply With Quote
Old 4th November 2010, 22:37   #9  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Thought so, it's just that I am currently greatly misled by developpers who used FFmpeg without knowing really what they were doing, and someone assured me that SVN version were for Windows, and others were made for Linux.
So thank you for removing yet one more doubt from my mind !

Also, thanks so much Dark Shikari, thanks for your patience, I downloaded (what I believe is) the latest version and it worked just fine... Except for some details, but I'll figure it out. I will still have many questions in the future, but I think much of the info I'll dig out by myself from the web will make much more sense.

Much of my concern was that the SVN version would not work on Linux. That being clear, I will proceed to encouraging my department to update to the latest version possible.
Klagar is offline   Reply With Quote
Old 4th November 2010, 22:52   #10  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,643
Quote:
Originally Posted by Klagar View Post
Much of my concern was that the SVN version would not work on Linux. That being clear, I will proceed to encouraging my department to update to the latest version possible.
I'm guessing that the admins like to use a distribution-packaged version, which is usually 1 to 3 years old. It saves them trouble, but since FFmpeg is critical for your work, a newer version is definitely necessary.
nm is offline   Reply With Quote
Old 5th November 2010, 03:34   #11  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,301
Recent ffmpeg is always a very good idea, as is never using a version that comes with your distro
Blue_MiSfit is offline   Reply With Quote
Reply

Tags
2-pass, ffmpeg, h264, x264, xvid

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:53.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.