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 ASP

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th January 2008, 18:31   #1  |  Link
drunken_clam
Registered User
 
Join Date: Aug 2006
Posts: 15
Xvid encoding with ffmpeg

Hi everybody,

i'm using ffmpeg for encoding video with xvid. My problem is that i can't get out which options from ffmpeg i can use for xvid, because in the documentation the options are mostly not codec related.

So perhaps i can find any experienced ffmpeg+xvid users here who can tell me some good options for xvid encoding. My current commandline looks like this:
Code:
ffmpeg -y -i IN.avi -aspect 4:3 -vcodec libxvid -s 640x480 -r 25 -b 1000k -flags +trell -g 250 -me_method epzs -qmin 2 -qmax 15 -acodec libmp3lame -ac 2 -ar 44100 -ab 80k -benchmark OUT.avi
Can somebody tell me what the option "-coder XX" do?

Is the "flag +aic" an option which is supported by standalone players?

Things if already tried are "gmc, qpel,4mv"...
drunken_clam is offline   Reply With Quote
Old 17th January 2008, 11:14   #2  |  Link
20-40
Registered User
 
20-40's Avatar
 
Join Date: Oct 2007
Posts: 43
Try for example (change in/out files):
Code:
ffmpeg -i "sara.mpg" -vcodec libxvid -trell -max_bframes=2 -s 576x432 -b 800k -r 23.976 -acodec libmp3lame -ac 2 -ar 48000 -ab 128k -y -f avi my_dog.avi
for single pass.
For two pass encoding try for example
Code:
ffmpeg -i "sara.mpg" -vcodec libxvid -trell -max_bframes=2 -s 576x432 -b 800k -r 23.976 -acodec libmp3lame -ac 2 -ar 48000 -ab 128k -y -pass1 "xvid.stats" -f avi my_dog.avi

ffmpeg -i "sara.mpg" -vcodec libxvid -trell -max_bframes=2 -s 576x432 -b 800k -r 23.976 -acodec libmp3lame -ac 2 -ar 48000 -ab 128k -y -pass2 "xvid.stats" -f avi my_dog.avi
Ffmpeg prefer libavcodec, and for xvid is better to use mencoder, avisynth/encraw_xvid or avisynth/avs2avi for much faster and better results.

FYI, qpel (and GMC partially) is incompatible with almost all standalone players.

ffmpeg -h > ffmpeg_help.txt will dump help into file
ffmpeg -formats help > formats.txt will dump info on formats into file, etc…

Ffmpeg is constanly developed, so - ALL options vary from one revision/version to another.

For instance, above examples works for ffmpeg.exe I've compiled for myself:
Code:
FFmpeg version SVN-r10822, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/mingw --enable-static --disable-shared --
enable-pp --enable-swscaler --enable-libmp3lame --enable-libfaac --e
nable-libfaad --enable-libx264 --enable-libxvid --enable-libogg --en
able-libvorbis --enable-liba52 --enable-gpl --enable-libamr-nb --ena
ble-libamr-wb --enable-avisynth --extra-cflags=-g0 -O2 -D_GNU_SOURCE
 -ffast-math --enable-memalign-hack --disable-debug --enable-w32thre
ads --extra-libs=-lwinmm -lavisynth --arch=prescott --cpu=prescott -
-extra-ldflags=-static
  libavutil version: 49.5.0
  libavcodec version: 51.46.0
  libavformat version: 51.16.0
  built on Oct 23 2007 23:57:14, gcc: 4.3.0 20070831CYBORG (experimental) (by_20-40)
In any case, happy encoding.
20-40 is offline   Reply With Quote
Old 28th August 2010, 00:29   #3  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,603
I have a similar issue ... http://ffmpeg.arrozcru.org/autobuilds/ offers a quite versatile and current build; unfortunately there are so many options that I am hardly able to filter which of them are relevant for Xvid encoding with ffmpeg at all.

Let's imagine I'd like to encode "anything" to MP4 with Xvid MPEG4-ASP video and LAME MP3 audio because that's quite the best size/quality ratio my mobile media player supports. To get rather optimal results, I'd try to have the video encoded with fixed quantizer (because Xvid does not really support a good "constant quality" algorithm like x264's CRF ... yet?) and the audio with a constant quality as offered by LAME's VBR mode. Which command line options of ffmpeg can I use / should I use for rather optimal results?

It seems to me that ffmpeg does not support codec specific options (like "-xvidencopts" in mencoder) but offers a lot of generic options instead, which may be supported by a specific codec or not. So e.g. there is the command line option "-trellis #", and because Xvid supports trellis quantization, encoding to MPEG4-ASP using libxvid probably uses Trellis if I add this option -- but which (integer) parameter for this option would make sense? In case of Xvid possibly 0 and 1; in case of x264 possibly 0, 1 and 2. And in case of a constant quantization possibly not at all.

There are just too many options and provided by ffmpeg (with too briefly documented value ranges), I am losing track of which have any relation to Xvid at all, and which range of values is useful in case of Xvid as video encoder. The same applies to LAME as MP3 encoder - although I try to use parameters which should create a quality based VBR MP3 audio stream, I am not certain if the result is as desired until I demultiplex the result and check it (and may the reason just be that ffmpeg writes a constant bitrate into its console output).

So - which options would you recommend to get a quality based but small sized VBR result for a mobile media player (like a cell phone) in addition to my first try?

ffmpeg.exe -y -i %1 -vcodec libxvid -bf 1 -qscale 4 -s 320x240 -acodec libmp3lame -aq 2 -ar 22050 -ac 2 -f mp4 "%~n1.mp4"
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 28th August 2010, 21:29   #4  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,603
I found a solution: There are ffmpeg GUIs (like FFCoder) which know more about command line options than me. They helped me building useful parameter sets.

So I found that B frames can confuse players and make MediaInfo report movies as "variable frame rate" even though they have constant frame rates. Probably only with certain containers (MP4, 3GPP) written by ffmpeg.

Interesting that the latest ffmpeg builds contain an AAC encoder too. I thought the author of FAAC got nearly sued if he didn't stop his project ... even if the LAVC AAC encoder has low quality and needs to be enabled with "-strict experimental" -- be careful with license lawyers.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 28th August 2010 at 21:34.
LigH is offline   Reply With Quote
Old 9th September 2010, 11:51   #5  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
mencoder's muxer has bugs producing mpeg4 asp or avc with b-frames. I'm not sure if it applies to ffmpeg too.
henryho_hk is offline   Reply With Quote
Old 12th September 2010, 03:41   #6  |  Link
MOS-Marauder
Registered User
 
Join Date: Apr 2006
Posts: 134
Quote:
Originally Posted by henryho_hk View Post
mencoder's muxer has bugs producing mpeg4 asp or avc with b-frames. I'm not sure if it applies to ffmpeg too.
Yep it does... I wanted to usse mencoder or ffmpeg to cut samples out of a video...with mencoder it makes out of a 1bframe encoded vid an 2bframes one...


If i use ffmpeg to cut it does the same but u can add "-bf 1" or howmany bframes u want......BUT it crashes my vbr mp3 and writes CBR in the header witch leads to play errors.

Suggestions?


Chris
MOS-Marauder is offline   Reply With Quote
Old 2nd November 2010, 15:32   #7  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 512
Quote:
Originally Posted by MOS-Marauder View Post
Yep it does... I wanted to usse mencoder or ffmpeg to cut samples out of a video...with mencoder it makes out of a 1bframe encoded vid an 2bframes one...


If i use ffmpeg to cut it does the same but u can add "-bf 1" or howmany bframes u want......BUT it crashes my vbr mp3 and writes CBR in the header witch leads to play errors.

Suggestions?


Chris
If you use VBR MP3 in an avi you will have problems. It is better to use MP3 CBR, in fact, VirtualDubMod recommended to save the audio to WAV and then encode to MP3 CBR. Greetings.
GMJCZP is offline   Reply With Quote
Old 2nd November 2010, 16:36   #8  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,603
No panic. VBR audio is no problem for the AVI container. Alexander No proved it. AviMux-GUI and Avidemux can handle it. Even VirtualDubMod only warns if you don't disable the warning - a relic from Avery Lee's original VirtualDub.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 5th November 2010, 04:51   #9  |  Link
GMJCZP
Registered User
 
GMJCZP's Avatar
 
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 512
The subject matter is to be cut a video with audio variable, a way to avoid trouble would pass the audio to CBR. Once I had problems joining two pieces of a avi with VBR audio, Not only the audio was not synchronized but also part of the sound at the beginning of the second piece was cut. I took to get a WAV and synchronized. In short, this proposal is just one solution, so that there may be others.
GMJCZP is offline   Reply With Quote
Old 23rd February 2012, 19:06   #10  |  Link
raymng
Registered User
 
Join Date: Feb 2007
Posts: 12
Quote:
Originally Posted by drunken_clam View Post
Hi everybody,

i'm using ffmpeg for encoding video with xvid. My problem is that i can't get out which options from ffmpeg i can use for xvid, because in the documentation the options are mostly not codec related.

So perhaps i can find any experienced ffmpeg+xvid users here who can tell me some good options for xvid encoding. My current commandline looks like this:
Code:
ffmpeg -y -i IN.avi -aspect 4:3 -vcodec libxvid -s 640x480 -r 25 -b 1000k -flags +trell -g 250 -me_method epzs -qmin 2 -qmax 15 -acodec libmp3lame -ac 2 -ar 44100 -ab 80k -benchmark OUT.avi
Can somebody tell me what the option "-coder XX" do?

Is the "flag +aic" an option which is supported by standalone players?

Things if already tried are "gmc, qpel,4mv"...

I have exactly the same question.
Where can I check the available options for libxvid on FFmpeg?

Thanks.
raymng is offline   Reply With Quote
Old 9th March 2012, 04:19   #11  |  Link
JeanMarc
Registered User
 
Join Date: Aug 2006
Location: USA
Posts: 59
Xvid encoding with ffmpeg

I am also using ffmpeg a lot for encoding xvid (except when I have a 5.1 channel audio that I want to keep, in which case I have to use virtualdub).

I have been using 'libxvid' most of the time, and 'mpeg4' when I wanted to use b-frames -- I haven't been able to get a good result with b-frames and libxvid, for whatever reason.

Here is a good site that offers a useful discussion of a number of xvid options for ffmpeg: http://helpful.knobs-dials.com/index...or%20divx/xvid.
Naturally, the complete list that you get when you do 'ffmpeg -h' is not self-explanatory, but is helpful to verify syntax and spelling. Some commands have evolved with newer versions of ffmpeg, and the console gives all the information pertaining to your version of ffmpeg.

There is also the Unofficial XVID FAQ: http://kaitsuburi.tripod.com/crusty_xvid_faq_v20040406.pdf , somewhat dated, but Xvid is not that new. It doesn't provide the ffmpeg commands, but, with a little guesswork, it is almost always possible to find out what is the command corresponding to the feature described.

Hope that helps.

Last edited by JeanMarc; 9th March 2012 at 04:44. Reason: Better link to xvid faq
JeanMarc is offline   Reply With Quote
Old 9th March 2012, 09:05   #12  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,390
Quote:
and the console gives all the information pertaining to your version of ffmpeg
an example of all the information?

say i'd like to convert "vpxenc -v --rt -p 2 --pass=1 --bias-pct=100 --fpf="$tmp.log" --threads=8 --target-bitrate=55000 --end-usage=cq --cq-level=20 --kf-min-dist=0 --kf-max-dist=100 --auto-alt-ref=1 --lag-in-frames=16 --drop-frame=0 --min-q=0 --max-q=60" to ffmpeg with some slightish guesswork?
__________________
certain other member
smok3 is offline   Reply With Quote
Old 9th March 2012, 14:24   #13  |  Link
JeanMarc
Registered User
 
Join Date: Aug 2006
Location: USA
Posts: 59
Quote:
and the console gives all the information pertaining to your version of ffmpeg
Allright, 'all' the information is overstated, although I did mention it was not self-explanatory. May be the right phrase should have been: 'a list of the commands accepted by your version of ffmpeg'.

Now, my post was intended to help people like raymng understand the XVID options when encoding with ffmpeg.

I wouldn't say anything about translating a webm command into ffmpeg, especially since I have never used vpxenc. Do you imply that ffmpeg can do the same encoding as your vpxenc command ?
JeanMarc is offline   Reply With Quote
Old 9th March 2012, 14:26   #14  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,390
well it should, since it is compiled with the same version of libvpx..., but i'am not really implying anything.
__________________
certain other member
smok3 is offline   Reply With Quote
Old 16th May 2012, 05:31   #15  |  Link
unknownsoldierX
Registered User
 
Join Date: Jun 2005
Posts: 234
I've just started trying to use ffmpeg (via MCEBuddy). Is there a way to set a target size for the final AVI? I'm used to using MeGUI, which automatically does it for you. I'd like to use MCEBuddy to automate my encoding, but I need to my files to be a set size. Can ffmpeg do this while taking the audio size into account, so I can get a final product that is, for example 700MB?
unknownsoldierX is offline   Reply With Quote
Old 14th January 2013, 17:44   #16  |  Link
Gew
Observer
 
Gew's Avatar
 
Join Date: Jul 2008
Location: Kingston, Jamaica.
Posts: 110
Guys, I think that the "default" preset in xvidcore.dll (or xvidvfw.dll, for that matter) is pretty darn okey, just to fulfill in produce a descent video with desired bitrate/quantizer, which is still playble with most stand-alones.

However, running an ffmpeg encode with '-c:v libxvid' and switch(es) '-q:v' or '-b:v' does indeed produce an output with desired bitrate or quantizer, but it seems to disregard some of the settings from the "default" preset from the XviD library. For instance, it disables all B-frames, so I need to add '-bf 2' to make it fit my bill. Also, trellis is checked, and I'm not sure if it should be '-trellis 1' or '-trellis 2' to make the encode fit what Xvid library would have done per default. Also, in some ffmpeg command line examples I've seen even more switches being add, like '-subcmp' for instance. I'm not even sure what this does, or if the default (when not specified) encode from ffmpeg differs from how Xvid would do.

Hey, here comes the short [TLDR] version.

Could anyone who's skilled about this video stuff write a xvid_defaults.preset and upload it someplace, with settings that would match the actual Xvid encoding library in every aspect? Would be awesome.

Cheers!
Gew is offline   Reply With Quote
Old 10th April 2013, 11:34   #17  |  Link
cord-factor
Registered User
 
Join Date: Jan 2008
Location: Kharkov, UA
Posts: 105
Hi all,
I have just tried to encode video with libxvid (using ffmpeg)... So, comparing to embedded ffmpeg's 'mpeg4' codec the quality has been significantly decreased.
__________________
Gentoo linux
cord-factor is offline   Reply With Quote
Old 10th April 2013, 13:40   #18  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,603
Bold statement without proof; at least both your CLI parameters would be interesting, just to see if their purpose is comparable.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 10th April 2013, 16:05   #19  |  Link
mousemurder
Registered User
 
Join Date: Jun 2007
Posts: 120
have you thought about looking into xvidenc ?; although it is based on mencoder instead of ffmpeg.
mousemurder is offline   Reply With Quote
Old 10th April 2013, 16:56   #20  |  Link
cord-factor
Registered User
 
Join Date: Jan 2008
Location: Kharkov, UA
Posts: 105
Quote:
Originally Posted by LigH View Post
Bold statement without proof; at least both your CLI parameters would be interesting, just to see if their purpose is comparable.
$ ffmpeg -i input.avi -an -c:v libxvid -qscale 1.4 out.avi
$ ffmpeg -i input.avi -an -c:v mpeg4 -qscale 1.4 out.avi

Quote:
Originally Posted by mousemurder View Post
have you thought about looking into xvidenc ?; although it is based on mencoder instead of ffmpeg.
This topic is about ffmpeg and it doesn't recognize 'xvidenc' option.
__________________
Gentoo linux
cord-factor is offline   Reply With Quote
Reply

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 22:09.


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