View Full Version : FreeEnc: New High Quality MPEG2 Encoder
vmesquita
31st July 2004, 04:00
Hi Everyone,
I just created a new libavcodec based encoder. This encoder takes AVS input and outputs MPEG2 like QuEnc, but the main difference is that every parameter is tweakable, plus it comes with the optimized parameters of MencodeMe, which are known to produce great quality. Download here:
http://www.downloadcounter.com/cgi-bin/download.pl?username=vmesquita&account=5
This encoder is also compatible with QuEnc command-line options, meaning it can replace QuEnc in any app that suppots it. Just rename the executable to QuEnc.exe and overwrite.
Enjoy! :D
EDIT:
0.2 is out
changes:
- Fixed the P4 crashes by disabling SSE2 code in avcodec. Finally! Thanks Mean from doom9 for pointing the problem.
- It's now possible to use different .ini templates
- new command-line option "-template". Usage: -template FreeEnc (do not put the .ini in the end, it's added automatically)
- New Status bar that shows if it's in first or second pass (to avoid confusion)
- Added Incredible KDVD alpha settings
Paced
31st July 2004, 11:54
Great to see yet another new tool, thanks. But, after a few tests, I have found that it doesn't respect the average bitrate (I'm not sure why) - I originally set it at 2113, but the output (according to VirtualDub / BitrateView) was reported to be approximately 1300.
vmesquita
31st July 2004, 13:25
Hi Paced,
This is knows as the "can't quantisize more" libavcodec feature. The encoder simply is already using the lowest quatisizer possible in every area of the video.
You may want to tweak the parameters scplx_mask and lmin to get higher bitrates, since the encoder comes tweaked to lower bitrates (you can find it in freeenc.ini)
In the old mencoder forum, you'll find tons of info and tests about libavcodec:
http://kvcd.net/forum/viewforum.php?f=81
JDay
31st July 2004, 16:37
Well, I tried an avs from DVD-RB that gave me the error "could not locate libavcodec mpeg2" (or something like that), and "could not open avs" when I click go again. Here's the avs in question:
#------------------
# AVS File Created by DVD Rebuilder
# VOBID:01, CELLID:01
#------------------
LoadPlugin("C:\DVD Backup\DVD-RB\MPEG2Dec3dg.dll")
mpeg2source("C:\DVDS\KATAKURI\AUDIO_TS\D2VAVS\V05.D2V",idct=7)
trim(0,6443)
converttoyv12()
This was actualy output for cce, I just added the "converttoyv12()" (works fine in QuEnc). Also, its 16:9, interlaced, 23.976fps.
vmesquita
31st July 2004, 16:45
Very wierd, this error should not happen. But I don't understand this:
"Also, its 16:9, interlaced, 23.976fps."
Interlaced 23.976 fps? Maybe this is creating some trouble. :confused:
JDay
31st July 2004, 17:35
It's a hybrid source. A lot of it is progressive, but RB encodes the whole thing as interlaced, and sets the flags on rebuild. I still seem to get the error when I try to encode as progressive, however. I tried it again, with some different settings (1 pass, progressive) and got the error "could not read from avs line 6". Line 6 is the "converttoyv12()" line (my avs changed a little since my last post, switched to dgdecode- still works with QuEnc, though). After that, I get the could not open avs error, and the program crashes when I cose it.
JDay
31st July 2004, 17:46
I also did some tests, just changing the size and fps of blankclip(). Often, I would get errors, and it would not encode or it would get through the first pass then give an error at the beginning of the second. Also, some clips that I did encode had missing frames (300 frames->297 frames). This was a problem in QuEnc, that Nic was able to solve. You might want to check into what the issue was there.
Edit: I had the most trouble with 720x480 23.976fps content. I was able to encode 29.97fps ok (for blankclip(), anyway).
vmesquita
31st July 2004, 17:50
Well, looks like the initial error is related to this 23.976 interlaced source. I'll test later with this.
But there's something really wierd here: messages regarding specifically the avisynth script like this "could not read from avs line 6" are generated by avisynth itself, FreeEnc just detects that Windows failed to open the script video source and gets the error message from AVISynth.
The crash must be because I forgot to free the pointer in case of error... My mistake, I'll fix later.
EDIT: Indeed, 23.976 interlaced causes the error message, I just tested.
EDIT2: Even 29.97 interlaced crashes. I must have enabled a wrong flag.
EDIT3: Yes, I did enable the wrong flag, just fixed. Now let's see the missing frames problem.
JDay
31st July 2004, 18:49
Don't know why I got that avs error. Same script works in QuEnc, VirtualDub, MPC, etc (although I only got the error in FreeEnc once). Surely that's a problem on my end, rather than in your program.
Amnon82
31st July 2004, 23:17
vmesquita my friend. I'll try your encoder. Good work so far.:D
vmesquita
1st August 2004, 15:11
Ok, 0.12 is out fixing the interlaced problem. :)
yaz
2nd August 2004, 10:14
@vmesquita
great stuff ! thx a lot ! i've just made some short tests but seems to work. quality is fairly acceptable. however, i've got some questions. afais, the 'default' setting is that optimized for kvcd implementations (MencodeMe, PackShot, ... ) what if i wanted to use quite different settings ? so ...
- is it necessary to set all parameters in the ini file or is there some embedded defaults ? say, is there a default matrix or should i always set it in the ini file ?
- are these the only available parameters or can i add more ? say, i do prefer trellis optimization, is there a way of using/testing it with FreeEnc (or is it disabled) ?
- if there's some more options, is there a list of the opts available ?
- FreeEnc does not seem to accept bitrate settings strictly, i always got some deviation. is it a well known problem of libavcodec. have u improved this part too or just take it as it is ?
- ... :-)))
thx again for your efforts
y
Amnon82
2nd August 2004, 10:59
I had some troubles. It crashed always. Lets see if the new version solved the chrashing problems with PAL movies ... Good work! Go on
vmesquita
2nd August 2004, 12:03
afais, the 'default' setting is that optimized for kvcd implementations (MencodeMe, PackShot, ... )
Actually they are optimized for low bitrate. :D
what if i wanted to use quite different settings ? so ...
Be my guest, that's the whole design difference from QuEnc.
- is it necessary to set all parameters in the ini file or is there some embedded defaults ? say, is there a default matrix or should i always set it in the ini file ?
Everything must be set in the ini. Do not remove any line or the parameter you removed will go to zero, causing crazy results.
- are these the only available parameters or can i add more ? say, i do prefer trellis optimization, is there a way of using/testing it with FreeEnc (or is it disabled) ?
Every libavcodec parameter is there! But the name of it may be a little different from mencoder implementation. Trellis for instance is trell. You will find it disabled (trell=0), enable if you want.
- if there's some more options, is there a list of the opts available ?
All libavcodec options are tweakable via INI, only the name may be slightly different from mencoder notation. Teh defaults are set to mencoder defaults, except for the parameters with were optimized.
- FreeEnc does not seem to accept bitrate settings strictly, i always got some deviation. is it a well known problem of libavcodec. have u improved this part too or just take it as it is ?
It's just as it is, but:
The default settings are optimized for low bitrate, so it tend to produce undersize when you ask for higher bitrate, like 3000, 4000, etc (depends on source compressibility, of course). If you prefer high bitrate, tweak lmin and scplx_mask. You can find some info on this on the now locked Mencoder KVCD forum.
yaz
2nd August 2004, 12:11
@vmesquita
thx for the quick reply. weeks (months?) ago i'd made a very thorough test of mencoder. i'm about to brush that up w/FreeEnc. i'm curious what of those findings will work here & what not. hmmm ... i hope i still have the same sources.
thx again
y
lithoc
3rd August 2004, 02:15
I've happen to download Quenc & FreeEnc.
I've notice that both have avcodec.dll
Is this is the same?
Can I have Quenc & FreeEnc running on the same avcodec.dll?
I've run some test and found out that by using Quenc dll file.
The video size is bigger & lower quality.
Can anyone confirm this?
vmesquita
3rd August 2004, 04:01
I compiled my avcodec.dll using the latest CVS, linking only the needed .o (i.e., I didn't include h263 and other unneeded codecs). I don't know how Nic created his and what version he used.
Paced
3rd August 2004, 06:56
Originally posted by vmesquita
Hi Paced,
This is knows as the "can't quantisize more" libavcodec feature. The encoder simply is already using the lowest quatisizer possible in every area of the video.
You may want to tweak the parameters scplx_mask and lmin to get higher bitrates, since the encoder comes tweaked to lower bitrates (you can find it in freeenc.ini)
In the old mencoder forum, you'll find tons of info and tests about libavcodec:
http://kvcd.net/forum/viewforum.php?f=81
Thanks for the reply, much appreciated.
On another note, I too seem to be getting constant crashes (after the first pass) with FreeEnc (even with the latest version). I've found it happens when the Trim() command is used; it happens with SelectRangeEvery(1200,12) too. Not sure if this will help or not, but I have not been able to encode one PAL clip with the program. I have however, been able to encode some NTSC clips.
dragongodz
3rd August 2004, 07:48
my compile for QuEnc 0.53 is CVS from the 1st of August(my time). i didnt disable any codecs from normal compile. Nics compile from 0.51 is from before that was released(of course) and he said that he uses an old version of gcc(dont know exact version).
so basically mine and vmesquita should give similar results while Nics dll may not.
lithoc
3rd August 2004, 09:00
I've problem with crashing too.
After it crash once, it keep on crashing whenever I run the program & encode again.
I cannot confirm this but the problem goes away after I delete the files in prefetch folders in windows xp.
vmesquita
3rd August 2004, 14:11
@dragongodz
Thanks for the info. :)
@Paced
I did some tests here using trim and PAL sources and still, no crash...
:(
@lithoc
I don't know how the prefetch thing can be related.
@everyone with crashing problems
I was thinking that maybe there can be a DLL conflict, so maybe it would be worth temporarily removing all avcodec.dll copies (including the ones from QuEnc), reboot the system and try again.
I did a build of the DLL using the latest CVS, downloaded completelly (I have used CVS update previously), keeping all codecs and using no upx. Please do the solution above, and if still doesn't work, try this DLL:
<edit>removed old link</edit>
EDIT:
Looks like QuEnc 0.52 does not work in my system: it keeps increasing the ammount of used memory till there's no more memory left. QuEnc 0.51 still works fine. Maybe there's a DLL conflict, indeed.
vmesquita
3rd August 2004, 15:21
Just to make sure the DLL conflicts are out of the picture, I did a static build (does not use the DLL). Get it here:
<edit>removed old link</removed>
I can provie freeenc.o in case anyone wants to link with a different version of the library, as the LGPL requires. Let me know if this fixes the problem.
Paced
3rd August 2004, 15:53
Hey, it sucks to be reporting this, but the static version still 'crashes' on my system :(. Basically, it does the first pass with no problems, but before starting the second pass, the program just suddenly closes itself - a majority of the time there is no error prompt/pop-up, etc. (it just closes).
//Edit
Now that I think about it, the only time I've seen an error window/pop-up (when the program quits itself after the first pass), is whenever I use SelectEvery(xx) in the script.
vmesquita
3rd August 2004, 16:14
@Paced
Could you post a sample script that crashes on the start of the second pass?
Paced
3rd August 2004, 16:32
Originally posted by vmesquita
@Paced
Could you post a sample script that crashes on the start of the second pass?
Sure, I'll give you two:
#------------------
# AVS File Created by DVD Rebuilder
# VOBID:01, CELLID:01
#------------------
mpeg2source("C:\WUTEMP\TEST\D2VAVS\V01.D2V")
trim(0,1649)
ConvertToYV12()
AudioDub(BlankClip())
and..
AVISource("C:\AVIHere.avi")
LanczosResize(720, 448, 19, 0, 602, 352)
AddBorders(0, 64, 0, 64)
ConvertToYV12()
vmesquita
3rd August 2004, 18:32
@Paced
Thanks, this script did not crash on me but was making the encoder exit after the second pass, and I fixed.
@all
0.13 is out! Changelog in the first message. I have a hope that I might have fixed the problem (there were two leaking problems in the code), but don't get too happy, since this never happened to me, I can't garantee anything.
Encoder Master
3rd August 2004, 20:05
Very nice VMESQUITA.:D
Paced
4th August 2004, 01:06
Originally posted by vmesquita
@Paced
Thanks, this script did not crash on me but was making the encoder exit after the second pass, and I fixed.
@all
0.13 is out! Changelog in the first message. I have a hope that I might have fixed the problem (there were two leaking problems in the code), but don't get too happy, since this never happened to me, I can't garantee anything.
Yay for vmesquita! It works now :D
vmesquita
4th August 2004, 01:08
Originally posted by Paced
Yay for vmesquita! It works now :D
It's great to hear that! :D
Paced
4th August 2004, 01:16
Oh wait, I spoke too soon :( I didn't notice it at first, but it still doesn't start the second pass for me. Now, instead of quitting the program after the first pass, it just acts like it has finished encoding; but, the problem is, it has only done one pass. At least it's not quitting anymore :D Or, the only other reason I can come up with is: did you change the way the progress bar works? Because in your very first version, I remember that the progress bar went through twice in the entire process (one for first pass, and two for the second pass). Or does it only go through once, but half = one pass, and the second half = 2 pass ? I hope that made sense.
vmesquita
4th August 2004, 01:21
How do you know it has not started the second pass? You see, when you select two pass, the progress bars shows both the first and second pass, so when it reaches 50%, means that it has finished the first pass and it's starting the second. You can notice that until about 50%, the filesize doesn't grow (stays in 0kb).
EDIT: Looks like you got it before I finished writtng my reply. :D
Paced
4th August 2004, 01:48
Originally posted by vmesquita
EDIT: Looks like you got it before I finished writtng my reply. :D
Hehe, too fast ;) Thanks for the clarification, and the work you've put in.
dragongodz
4th August 2004, 04:08
Looks like QuEnc 0.52 does not work in my system: it keeps increasing the ammount of used memory till there's no more memory left.
do you mean QuEnc using the dll that comes with it ? if yes then what cpu and windows are you running ?
Wilbert
12th August 2004, 00:17
I just created a new libavcodec based encoder. This encoder takes AVS input and outputs MPEG2 like QuEnc, but the main difference is that every parameter is tweakable, plus it comes with the optimized parameters of MencodeMe, which are known to produce great quality.
I guess you forgot to mention the most important difference?
vmesquita
12th August 2004, 01:31
@dragongodz
I am running Windows XP SP1 on an AtlhonXP 2000+, 512 Mb. I'll do some additional tests to confirm it's still hapening, altrought on the day I reported, it was happening in every single try, using default avcodec.dll.
@Wilbert
I guess this part of my explanation you highlightned is the most important difference. There are others, like the plataform used (I used MinGW+WxWidgets, QuEnc was developed in Visual C++). So could please point what is "the most important difference" in your oppinion?
@all
After some test at KVCD.NET while this forum was down, we came to the conclusion that the crashes are happening with some P4 processors, right after FreeEnc calls avcodec routine that encodes a frame. What is interesting is that the crash doesn't happen in the first frame encoded, but generally in the third. Also it's interesting that the old avcodec.dll from QuEnc works with FreeEnc in this "crashing machines" but give bad quality. :confused:
My last idea was try to cross-compile from cygwin (like Nic did in the past) but I still could not make it work... :( In theory it should produce the same results of a straight compilation in MSYS, but how knows... :rolleyes: I'll keep trying.
dragongodz
12th August 2004, 06:20
vmesquita - hmm i am running XP on an athlon 2400+ with 256mb ram and dont get that problem. also i havent seen anyone else mentioning the ram being eaten on other forums either. so very strange.
the old avcodec.dll from QuEnc works with FreeEnc in this "crashing machines" but give bad quality
i asume you mean Nics dll. as i said that is an older compile so output may not be the same as more up to date cvs. it shouldnt output really bad quality though just slightly different. maybe you could ask some of those people that have tried to also test with my dll and see if that does the same. if it also gives bad quality then that will be really strange, since mine is much more up to date.
mean
12th August 2004, 07:40
There is still some alignment issue with sse2 code on win32
The following worked for me (also using mingw) :
look in MPV_common_init_mmx and comment out
if(mm_flags & MM_SSE2){
s->dct_quantize= dct_quantize_SSE2;
} else
Wilbert
12th August 2004, 11:05
@Wilbert
I guess this part of my explanation you highlightned is the most important difference. There are others, like the plataform used (I used MinGW+WxWidgets, QuEnc was developed in Visual C++). So could please point what is "the most important difference" in your oppinion?
Will the source be available one day?
vmesquita
12th August 2004, 12:47
Originally posted by dragongodz
vmesquita - hmm i am running XP on an athlon 2400+ with 256mb ram and dont get that problem. also i havent seen anyone else mentioning the ram being eaten on other forums either. so very strange.
I just tested with 0.53 and it keeps increasing the memory usage till there's no memory left yet. But a important data I forgot to mention: I am using a DivX source to test. Anyway I'll test today at work (where I have another AtlohXP :D ) and report back.
i asume you mean Nics dll. as i said that is an older compile so output may not be the same as more up to date cvs. it shouldnt output really bad quality though just slightly different. maybe you could ask some of those people that have tried to also test with my dll and see if that does the same. if it also gives bad quality then that will be really strange, since mine is much more up to date.
Yes, I was talking about Nic's DLL. I'll ask people to test with your compile. :)
Originally posted by mean
There is still some alignment issue with sse2 code on win32
The following worked for me (also using mingw) :
Thanks! You're right, this makes a lot of sense! Actually I think I'll go further and disable SSE2 from CPU detection (cputest.c) on, just rule out SSE2 problems of the picture.
Originally posted by Wilbert
Will the source be available one day?
Probably it won't. I don't think that's "the most important difference".
:rolleyes:
vmesquita
12th August 2004, 13:02
Hi everyone,
Following mean's advice, I compiled a special version of avcodec.dll with SSE2 completelly disabled. Replace the one that comes with FreeEnc and let me know if it fixes the crashes. :)
http://www.jltoca.uaivip.com.br/files/avcodec_no_sse2.zip
dragongodz
12th August 2004, 13:34
I just tested with 0.53 and it keeps increasing the memory usage till there's no memory left yet. But a important data I forgot to mention: I am using a DivX source to test
hmm well divx source shouldnt make any difference really. are you using avisource() or directshowsource() ?
this could be a problem aswell
http://forum.doom9.org/showthread.php?threadid=47893
but its strange how it doesnt on all peoples machines etc.
oh and you could also try eliminating any filters from your script just to make sure they do not have anything to do with it.
vmesquita
12th August 2004, 13:46
dragongodz,
I'll post about it in QuEnc 0.53 thread. ;)
vmesquita
13th August 2004, 15:16
Hi everyone
O.2 is out! Check the changelog and get it in the first post. :)
Amnon82
15th August 2004, 23:00
You solved the crashing-problem on my P4. Sorry I didn't told You that I also use a P4 ...
Can You explain me how the predictionmethod (prediction_method=0) works?
vmesquita
16th August 2004, 00:25
Hi Amnom,
I'm glad it's now working for you. I think this parameter doesn't do much with mpeg encoding. From ffmpeg code
/**
* prediction method (needed for huffyuv).
* - encoding: set by user
* - decoding: unused
*/
int prediction_method;
#define FF_PRED_LEFT 0
#define FF_PRED_PLANE 1
#define FF_PRED_MEDIAN 2
Amnon82
16th August 2004, 10:24
I coding a addon for Your encoder. Still have one Problem:
If I wrote this into the batchfile:
FreeEnc.exe /i D:\testfreeenc\matrix2_pred2.avs /o D:\testfreeenc\mat.mpv /1 /aspectratio 16:9 /nointerlaced /b 3550 /maxbitrate 7550 /auto /close
It works... but if I do this into the batch:
FreeEnc.exe /i D:\testfreeenc\matrix2_pred2.avs /o D:\testfreeenc\mat.mpv /1 /aspectratio 16:9 /nointerlaced /b 3550 /maxbitrate 7550 /template CYDVD1_1Alpha /auto /close
It won't ...
I readed also at KVCD.net about it ... I'm using the newest version of Your encoder (0.21)
Here the link to my app ESD 0.1 (http://www.brckomania.net/CYBERNETSOFTWARE/FILES/ESVCDDVD.exe)
Inc
16th August 2004, 21:15
@ Avalon
/template "CYDVD1_1Alpha" ... as I do remember
Before investing that much time in an add on, have a look at V 0.3
Amnon82
16th August 2004, 23:01
@Incredible
Nice graph ...
The problem with the Templates is still there!
Why stopping the addon? It will be like CQMatic for FreeEnc ...
@vmesquita
Here is the fullworking Batchfile:
@ECHO off
ECHO Batchfile created with EasySVCD/DVD - visit: www.cydvd.tk
ECHO Start encoding 25 percent of movie for prediction
E:\sources\ESVCDDVD\Encoder\FreeEnc.exe /i D:\testfreeenc\drunk1.avs /o D:\testfreeenc\drunk1.m2v /b 6811 /maxbitrate 7550 /1 /interlaced /aspectratio 4:3 /auto /close
exit
And this don't... :
@ECHO off
ECHO Batchfile created with EasySVCD/DVD - visit: www.cydvd.tk
ECHO Start encoding 25 percent of movie for prediction
E:\sources\ESVCDDVD\Encoder\FreeEnc.exe /i D:\testfreeenc\drunk1.avs /o D:\testfreeenc\drunk1.m2v /b 6811 /maxbitrate 7550 /1 /interlaced /aspectratio 4:3 /template CYDVD1_1Alpha /auto /close
exit
When I tip on the Combobox in your encoder and choose again my template it works. Can You post me a working Batchfile?
Inc
16th August 2004, 23:13
Why stopping the addon? It will be like CQMatic for FreeEnc
a) Nobody told to stop but to look first ...
b) In libavcodec its not possible to do a prediction like when using CQmatic. I know u used the slicer() function in DRPenc appl. to do a prediction based 1pass VBR but many and many tests on libavcodec based binaries did show that a "known" prediction is not possible. You cant set minrate and 2pass is obligatory if results should look good. The quantizer curve at 1pass behaves crazy and will only be set optimal finally at the 2nd pass.
Amnon82
17th August 2004, 09:16
I do now a test. I'll take the "chase-scene" of Matrix2.
Lets see if I get the size I want ... even in 1pass.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.