Log in

View Full Version : FFmpeg FLV encoding


AlexeyS
1st November 2007, 12:45
Hello guys,

I'm trying to encode .avi, .mov, .mpg videos uploaded to my site to flv format to upload these videos to YouTube without re-encoding.

I've installed latest FFmpeg on my linux server without any configure options.

I have few questions about FFmpeg and FLV, can you answer these ones please:

- What options should I use to encode videos with HIGHEST possible quality. I mean how to use 2 pass/Highest Quality with FFmpeg command line?
- Should I deinterlace uploaded videos (DV AVI for example) or FFmpeg will do it automatically?
- How to resize videos and what size is better to encode for YouTube?

Sorry for maybe stupid questions, but I never used anything like FFmpeg before.

unskinnyboy
1st November 2007, 14:03
- Read up on -sameq and -qscale flags in the ffmpeg docs.
- You must deinterlace. The -deinterlace flag.
- ffmpeg will resize for you. Specify -s qvga. QVGA = 320X240, the preferred YouTube frame size.

AlexeyS
1st November 2007, 22:05
- Read up on -sameq and -qscale flags in the ffmpeg docs.
I've run FFmpeg and I can't find sameq or qscale in descriptions. I use last version. Are these options called by another names in new version?

- You must deinterlace. The -deinterlace flag.
Will FFmpeg automatically detect progressive video clips and will deinterlace only interlaced videos? What method will be used?

- ffmpeg will resize for you. Specify -s qvga. QVGA = 320X240, the preferred YouTube frame size.
Thanks.

Dark Shikari
1st November 2007, 22:17
I think if I recall correctly the Youtube framesize is 448x336.

AlexeyS
1st November 2007, 22:21
I'm trying this now:

ffmpeg -i test.avi -vcodec flv -b 400 -s qvga test.flv

And I get really ugly video (with square blocks) at 155 Kbps. I wonder why does it happen?

AlexeyS
2nd November 2007, 11:35
Ok. I'm trying these settings right now for 2 pass encoding:

ffmpeg -i testbig.mov -vcodec flv -r 15 -b 350k -s 448x336 -y -pass 1 -passlogfile log.txt test4.flv
ffmpeg -i testbig.mov -vcodec flv -r 15 -b 350k -s 448x336 -y -pass 2 -passlogfile log.txt test4.flv

Video is 350 Kbps, but when I upload it to YouTube, it reencodes video. I wonder why does it happen?

I've also tried 320 Kbps versionwithout sound, YouTube re-encodes it too:

http://rapidshare.com/files/66911804/test5.flv.html

Also, are there any tips to increase video quality? My video looks blocky and ugly even with 350 Kbps bitrate and 2 pass encoding.

unskinnyboy
2nd November 2007, 15:02
I've run FFmpeg and I can't find sameq or qscale in descriptions. I use last version. Are these options called by another names in new version?Did you read the ffmpeg documentation (http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html)? What exactly is "last version"? I am on SVN-r10464. Typing ffmpeg -version will tell you which version you have.

Will FFmpeg automatically detect progressive video clips and will deinterlace only interlaced videos? What method will be used?Like I said before, you must manually deinterlace using the -deinterlace flag.

I think if I recall correctly the Youtube framesize is 448x336.From here (http://www.youtube.com/t/howto_makevideo), "We specifically recommend the MPEG4 (Divx, Xvid) format at 320x240 resolution with MP3 audio. Resizing your video to these specifications before uploading will help your clips look better on YouTube."

So basically, the video is always 320x240, but the Flash Player will resize it on-the-fly during playback. If you click on the rectangular button next to the volume button in the player, the video gets reset to its original resolution.

And I get really ugly video (with square blocks) at 155 Kbps. I wonder why does it happen?

Also, are there any tips to increase video quality? My video looks blocky and ugly even with 350 Kbps bitrate and 2 pass encoding.Your best bet is to use -sameq. With that, ffmpeg will try and maintain the same quality as the input file. Or play around with the -qscale values till you hit a sweet spot.

All that said, AFAIK, YouTube will reencode the video whatever format you upload it in. If you upload an FLV, they will reencode it again to FLV, so you are better off with sticking to what they recommend - MPEG-4, preferrably Xvid. That way, you are at least uploading a good source.

Dark Shikari
2nd November 2007, 15:18
All that said, AFAIK, YouTube will reencode the video whatever format you upload it in. If you upload an FLV, they will reencode it again to FLV, so you are better off with sticking to what they recommend - MPEG-4, preferrably Xvid. That way, you are at least uploading a good source.Wrong... Youtube will not re-encode if the FLV appears to be within spec. Video Sorenson H.263, audio MP3 22khz mono 48kbps, and total bitrate <350kbps.

AlexeyS
2nd November 2007, 19:14
Did you read the ffmpeg documentation (http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html)? What exactly is "last version"? I am on SVN-r10464. Typing ffmpeg -version will tell you which version you have.
FFmpeg version SVN-r10892. Yes, I've read this doc.

Like I said before, you must manually deinterlace using the -deinterlace flag.
I mean if I will add -deinterlace to all videos, what will FFmpeg do with progressive videos then?

Wrong... Youtube will not re-encode if the FLV appears to be within spec. Video Sorenson H.263, audio MP3 22khz mono 48kbps, and total bitrate <350kbps.
But how can I create such file? My files are without audio, they're less than 350 Kbps, I'm not sure about codec. I use - vcodec flv with FFmpeg.

Dark Shikari
3rd November 2007, 06:56
But how can I create such file? My files are without audio, they're less than 350 Kbps, I'm not sure about codec. I use - vcodec flv with FFmpeg.here... (http://forum.videohelp.com/topic336882.html)

AlexeyS
3rd November 2007, 10:48
here... (http://forum.videohelp.com/topic336882.html)
You already gave me this link. :)

Actually, I've read it few times before, butit seems I do not understand something. This article says I should encode my FLV video under 350 Kbps. So, if my FLV is under 350 Kbps, YouTube shouldn't re-encode my video. But it does.

I do not tell about Hex editor, because, as I understand, I shouldn't modify anything if my video is under 350 Kbps.

What am I doing wrong?

Dark Shikari
3rd November 2007, 11:30
You already gave me this link. :)

Actually, I've read it few times before, butit seems I do not understand something. This article says I should encode my FLV video under 350 Kbps. So, if my FLV is under 350 Kbps, YouTube shouldn't re-encode my video. But it does.

I do not tell about Hex editor, because, as I understand, I shouldn't modify anything if my video is under 350 Kbps.

What am I doing wrong?1. How do you know Youtube is re-encoding your video? Explain what methodology you used to determine this.

2. Did you check your resulting file in MediaInfo to see if the total bitrate is below 350kbps?

AlexeyS
3rd November 2007, 12:23
1. How do you know Youtube is re-encoding your video? Explain what methodology you used to determine this.
Well, when uploading is finished, video is not available for few minutes and YouTube says "uloaded, processing...".

2. Did you check your resulting file in MediaInfo to see if the total bitrate is below 350kbps?
Yes, video is 342 Kbps.

mgh
3rd November 2007, 16:56
only way to check is to download from you tube the file you have uploaded.
below 350 kbps you tube does not reencode but it does change some info in the header. sometimes it is almost instantaneous but not always. guess it depends on traffic

AlexeyS
5th November 2007, 10:24
only way to check is to download from you tube the file you have uploaded.
below 350 kbps you tube does not reencode but it does change some info in the header. sometimes it is almost instantaneous but not always. guess it depends on traffic
It seems downloaded video has same bitrate. But video look different before upload and when I view it at YouTube. Also, it's strange that YouTube processing video for few minutes.

What about -deinterlace? What will happen with proressive videos if I will use - deinterlace flag?

And the last question. What is the best way to add logo to videos and to add 2 seconds video before each video on Linux server? Avisynth? Or there is something better/easier?

Dark Shikari
5th November 2007, 10:26
Youtube does the processing anyways, though its shorter when it doesn't have to re-encode. I assume its setting up the video in its database.

foxyshadis
5th November 2007, 11:15
Just redownload it and compare frames with some tool, new blocks will stand out right away. Or upload some insanely large resolution, see if it comes back the same.

nm
5th November 2007, 14:32
What about -deinterlace? What will happen with proressive videos if I will use - deinterlace flag?The deinterlacing filter will be applied regardless of video content (and FFmpeg doesn't do IVTC either). However, when the progressive content will be downscaled and re-encoded, the unnecessary deinterlacing step probably won't affect quality much.

And the last question. What is the best way to add logo to videos and to add 2 seconds video before each video on Linux server? Avisynth? Or there is something better/easier?AviSynth is probably easiest for rendering a logo. There are many approaches to joining video files. For example, you could decode the two files to raw video/audio streams with the same properties (frame size, rate) and then simply concatenate the raw streams and feed the result to ffmpeg.

AlexeyS
5th November 2007, 18:31
The deinterlacing filter will be applied regardless of video content (and FFmpeg doesn't do IVTC either). However, when the progressive content will be downscaled and re-encoded, the unnecessary deinterlacing step probably won't affect quality much.
I understand, but I will keep original videos for future use.

AviSynth is probably easiest for rendering a logo. There are many approaches to joining video files. For example, you could decode the two files to raw video/audio streams with the same properties (frame size, rate) and then simply concatenate the raw streams and feed the result to ffmpeg.
Thanks. I will try Avisynth for logo.

Are you talking about joining videos with Avisynth or something else?

nm
5th November 2007, 22:08
Are you talking about joining videos with Avisynth or something else?
With other tools. Most command-line encoders can read raw video, so you can write scripts for simple operations such as joins. AviSynth is probably a better option for this too since you're using it for other stuff anyway.

AlexeyS
5th November 2007, 23:51
With other tools. Most command-line encoders can read raw video, so you can write scripts for simple operations such as joins. AviSynth is probably a better option for this too since you're using it for other stuff anyway.
I've just tried to install Avisynth for Linux and it's really buggy. There is only 3.0 version available for Linux and it seems stable versions 2.0 or 2.5 are available for Windows only. :(

I wonder does Linux has some analog of Avisynth? I'd like to use some stable software, but not pre-alpha.

akupenguin
6th November 2007, 00:52
I've just tried to install Avisynth for Linux and it's really buggy. There is only 3.0 version available for Linux and it seems stable versions 2.0 or 2.5 are available for Windows only.
There's gstreamer, but it's not all that usable either. Your best bet is Avisynth + Wine.

AlexeyS
6th November 2007, 09:45
There's gstreamer, but it's not all that usable either. Your best bet is Avisynth + Wine.
Thanks for advice. Did you use Avisynth + Wine? I guess perfomance will be much lower than native Avisynth?

I'm asking because I will use it on my server (so I need fast software) and also my server is slow itself.

akupenguin
6th November 2007, 11:16
Thanks for advice. Did you use Avisynth + Wine?
Yes.
I guess perfomance will be much lower than native Avisynth?
Not really. The only reasons some programs are slower in Wine than in Windows are that the Wine developers have had less time/manpower to optimize their implementation, and that a few of the win32 functions don't map well to Linux functions and thus need a significant wrapper. But those reasons don't apply to Avisynth, because most Avisynth filters spend all their cpu-time doing pure number crunching, not system calls.
So the only significant overhead is copying the uncompressed video data from avs2yuv (wine) to ffmpeg (native). The copy can cost up to a few % of the total encode time, or relatively less if you use slow filters and codecs.
If you have an x86_64 build of Linux (which I'm assuming most linuxes are these days, at least among users who care about speed), then don't run the encoder under wine even though that would allow you to avoid the copy. The speed benefit of a 64bit encoder is greater than the cost of a copy. (Corollary: the whole process including Wine is faster than the equivalent on 32bit Windows. Of course, Windows users could get the same boost from win64, but somehow that's less common.)

unskinnyboy
6th November 2007, 16:41
Wrong... Youtube will not re-encode if the FLV appears to be within spec. Video Sorenson H.263, audio MP3 22khz mono 48kbps, and total bitrate <350kbps.OK, so I uploaded a test video to YouTube, downloaded the uploaded file, compared the two and they are certainly different, namely file size, frame count and bitrate.


File 1 (source file uploaded to YouTube)

--- File Information ---
File Name: bad_decode_test01_340.flv
File Size (in bytes): 189,131

--- Video Information ---
Video Codec Type(e.g. "DIV3"): FLV1
Video Codec Name(e.g. "DivX 3, Low-Motion"): Flash/Sorenson
Video Codec Status(e.g. "Codec Is Installed"): Codec Status Undetermined
Duration (hh:mm:ss): 0:14.083
Frame Count: 11143504
Frame Width (pixels): 320
Frame Height (pixels): 240
Storage Aspect Ratio("SAR")" 1.333
Frames Per Second: 24.072
Pics Per Second: 24.072
Video Bitrate (kbps): 107
Quality Factor (bits/pixel)/frame: 0.058"

File 2 (resultant file downloaded from YouTube)

--- File Information ---
File Name: bad_decode_test01_340_youtubed.flv
File Size (in bytes): 190,178

--- Video Information ---
Video Codec Type(e.g. "DIV3"): FLV1
Video Codec Name(e.g. "DivX 3, Low-Motion"): Flash/Sorenson
Video Codec Status(e.g. "Codec Is Installed"): Codec Status Undetermined
Duration (hh:mm:ss): 0:14.083
Frame Count: 11143600
Frame Width (pixels): 320
Frame Height (pixels): 240
Storage Aspect Ratio("SAR")" 1.333
Frames Per Second: 24.072
Pics Per Second: 24.072
Video Bitrate (kbps): 108
Quality Factor (bits/pixel)/frame: 0.058"

I am open to any other suggestions which you may have which can support your theory.

AlexeyS
6th November 2007, 17:03
Not really.
Then I'd really like to use Avisynth + Wine, because I have some experience (I used it under Windows).

Could you answer few questions please. I've created new thread in Linux forum (http://forum.doom9.org/showthread.php?t=131554).

Dark Shikari
6th November 2007, 18:22
I am open to any other suggestions which you may have which can support your theory."Theory"? I think it qualifies as a fact considering videos like this (http://youtube.com/watch?v=-23Opat5zDE) and this (http://youtube.com/watch?v=WBWCxrsUh14) ;)

unskinnyboy
6th November 2007, 19:12
"Theory"? I think it qualifies as a fact considering videos like this (http://youtube.com/watch?v=-23Opat5zDE) and this (http://youtube.com/watch?v=WBWCxrsUh14) ;)
Considering the specs of these videos you linked to have nothing in common with the specs at which you claim YouTube won't re-encode videos, I fail to see your point (or humor).

EDIT: Just to add, File 2 referenced in post #25, have these in it's headers added by YouTube:

Creator: YouTube, Inc.
Muxer: YouTube Metadata Injector.

I'd go out on a limb and say that YouTube re-encoded this.

Dark Shikari
6th November 2007, 19:44
Considering the specs of these videos you linked to have nothing in common with the specs at which you claim YouTube won't re-encode videos, I fail to see your point (or humor).My point is that those videos were uploaded in a manner in which they were not re-encoded. Unless you're claiming that Youtube intentionally encoded a video at 720p/8 megabits?

To be exact, they have everything in common with the specs at which Youtube won't re-encode videos; Youtube thinks the total bitrate is below 350kbps, because the header was edited to fake a longer duration.
EDIT: Just to add, File 2 referenced in post #25, have these in it's headers added by YouTube:

Creator: YouTube, Inc.
Muxer: YouTube Metadata Injector.

I'd go out on a limb and say that YouTube re-encoded this.Actually, Youtube rewrites the headers of the file regardless. That is why you get "Processing..." even if Youtube doesn't re-encode the file.

unskinnyboy
6th November 2007, 20:33
Oh, I didn't look at it from that perspective. So basically you just modified the duration in the header using a Hex Editor to report a lower duration. Peachy. I see that 45tripp has demonstrated this in VideoHelp (found that thread now).

Dark Shikari
6th November 2007, 21:58
Oh, I didn't look at it from that perspective. So basically you just modified the duration in the header using a Hex Editor to report a lower duration. Peachy. I see that 45tripp has demonstrated this in VideoHelp (found that thread now).Yup, I love doing it for everything I upload, its loads of fun :cool:

mikeytown2
18th February 2008, 11:16
I've been playing around with the various switches and reading posts.

I'm using the feb-05-2008 bin from here
http://ffdshow.faireal.net/mirror/ffmpeg/

Here are most of the command line options for ffmpeg (post size limits)
Main options:
-h show help
-version show version
-formats show available formats, codecs, protocols, ...
-f fmt force format
-i filename input file name
-y overwrite output files
-fs limit_size set the limit file size in bytes
-ss time_off set the start time offset
-itsoffset time_off set the input ts offset
-v verbose control amount of logging
-sn disable subtitle

Video options:
-b set bitrate (in bits/s)
-vb set bitrate (in bits/s)
-vframes number set the number of video frames to record
-r rate set frame rate (Hz value, fraction or abbreviation)
-s size set frame size (WxH or abbreviation)
-aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-vn disable video
-vcodec codec force video codec ('copy' to copy stream)
-sameq use same video quality as source (implies VBR)
-pass n select the pass number (1 or 2)
-passlogfile file select two pass log file name


Advanced Video options:
-pix_fmt format set pixel format, 'list' as argument shows all the pixel formats supported
-intra use only intra frames
-vdt n discard threshold
-qscale q use fixed video quantizer scale (VBR)
-qdiff q max difference between the quantizer scale (VBR)
-rc_override override rate control override for specific intervals
-me_threshold motion estimaton threshold
-strict strictness how strictly to follow the standards
-psnr calculate PSNR of compressed frames
-vstats dump video coding statistics to file
-vstats_file file dump video coding statistics to file
-intra_matrix matrix specify intra matrix coeffs
-inter_matrix matrix specify inter matrix coeffs
-top top=1/bottom=0/auto=-1 field first
-dc precision intra_dc_precision

AVCodecContext AVOptions:
-b <int> E.V.. set bitrate (in bits/s)
-ab <int> E..A. set bitrate (in bits/s)
-bt <int> E.V.. set video bitrate tolerance (in bits/s)
-flags <flags> EDVA.
mv4 E.V.. use four motion vector by macroblock (mpeg4)
obmc E.V.. use overlapped block motion compensation (h263+)
qpel E.V.. use 1/4 pel motion compensation
loop E.V.. use loop filter
gmc E.V.. use gmc
mv0 E.V.. always try a mb with mv=<0,0>
part E.V.. use data partitioning
gray EDV.. only decode/encode grayscale
psnr E.V.. error[?] variables will be set during encoding
naq E.V.. normalize adaptive quantization
ildct E.V.. use interlaced dct
low_delay EDV.. force low delay
alt E.V.. enable alternate scantable (mpeg2/mpeg4)
trell E.V.. use trellis quantization
bitexact EDVAS use only bitexact stuff (except (i)dct)
aic E.V.. h263 advanced intra coding / mpeg4 ac prediction
umv E.V.. use unlimited motion vectors
cbp E.V.. use rate distortion optimization for cbp
qprd E.V.. use rate distortion optimization for qp selection
aiv E.V.. h263 alternative inter vlc
slice E.V..
ilme E.V.. interlaced motion estimation
scan_offset E.V.. will reserve space for svcd scan offset user data
cgop E.V.. closed gop
-me_method <int> E.V.. set motion estimation method
zero E.V.. zero motion estimation (fastest)
full E.V.. full motion estimation (slowest)
epzs E.V.. EPZS motion estimation (default)
log E.V.. log motion estimation
phods E.V.. phods motion estimation
x1 E.V.. X1 motion estimation
hex E.V.. hex motion estimation
umh E.V.. umh motion estimation
iter E.V.. iter motion estimation
-g <int> E.V.. set the group of picture size
-qcomp <float> E.V.. video quantizer scale compression (VBR)
-qblur <float> E.V.. video quantizer scale blur (VBR)
-qmin <int> E.V.. min video quantizer scale (VBR)
-qmax <int> E.V.. max video quantizer scale (VBR)
-qdiff <int> E.V.. max difference between the quantizer scale (VBR)
-bf <int> E.V.. use 'frames' B frames
-b_qfactor <float> E.V.. qp factor between p and b frames
-rc_strategy <int> E.V.. ratecontrol method
-b_strategy <int> E.V.. strategy to choose between I/P/B-frames
-ps <int> E.V.. rtp payload size in bits
-lelim <int> E.V.. single coefficient elimination threshold for luminance (negative values also consider dc coefficient)
-celim <int> E.V.. single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)
-strict <int> .DVA. how strictly to follow the standards
very E.V.. strictly conform to a older more strict version of the spec or reference software
strict E.V.. strictly conform to all the things in the spec no matter what consequences
normal E.V..
inofficial E.V.. allow inofficial extensions
experimental E.V.. allow non standardized experimental things
-b_qoffset <float> E.V.. qp offset between p and b frames
-mpeg_quant <int> E.V.. use MPEG quantizers instead of H.263
-qsquish <float> E.V.. how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)
-rc_qmod_amp <float> E.V.. experimental quantizer modulation
-rc_qmod_freq <int> E.V.. experimental quantizer modulation
-rc_eq <string> E.V.. set rate control equation
-maxrate <int> E.V.. set max video bitrate tolerance (in bits/s)
-minrate <int> E.V.. set min video bitrate tolerance (in bits/s)
-bufsize <int> E.VA. set ratecontrol buffer size (in bits)
-rc_buf_aggressivity <float> E.V.. currently useless
-i_qfactor <float> E.V.. qp factor between p and i frames
-i_qoffset <float> E.V.. qp offset between p and i frames
-rc_init_cplx <float> E.V.. initial complexity for 1-pass encoding
-dct <int> E.V.. DCT algorithm
auto E.V.. autoselect a good one (default)
fastint E.V.. fast integer
int E.V.. accurate integer
mmx E.V..
mlib E.V..
altivec E.V..
faan E.V.. floating point AAN DCT
-lumi_mask <float> E.V.. compresses bright areas stronger than medium ones
-tcplx_mask <float> E.V.. temporal complexity masking
-scplx_mask <float> E.V.. spatial complexity masking
-p_mask <float> E.V.. inter masking
-dark_mask <float> E.V.. compresses dark areas stronger than medium ones
-idct <int> EDV.. select IDCT implementation
auto EDV..
int EDV..
simple EDV..
simplemmx EDV..
libmpeg2mmx EDV..
ps2 EDV..
mlib EDV..
arm EDV..
altivec EDV..
sh4 EDV..
simplearm EDV..
simplearmv5te EDV..
h264 EDV..
vp3 EDV..
ipp EDV..
xvidmmx EDV..
-pred <int> E.V.. prediction method
left E.V..
plane E.V..
median E.V..
-aspect <rational> E.V.. sample aspect ratio

-skipcmp <int> E.V.. frame skip compare function
-precmp <int> E.V.. pre motion estimation compare function
-subcmp <int> E.V.. sub pel me compare function
-mbcmp <int> E.V.. macroblock compare function
-ildctcmp <int> E.V.. interlaced dct compare function
-cmp <int> E.V.. full pel me compare function
sad E.V.. sum of absolute differences, fast (default)
sse E.V.. sum of squared errors
satd E.V.. sum of absolute Hadamard transformed differences
dct E.V.. sum of absolute DCT transformed differences
psnr E.V.. sum of squared quantization errors (avoid, low quality)
bit E.V.. number of bits needed for the block
rd E.V.. rate distortion optimal, slow
zero E.V.. 0
vsad E.V.. sum of absolute vertical differences
vsse E.V.. sum of squared vertical differences
nsse E.V.. noise preserving sum of squared differences
w53 E.V.. 5/3 wavelet, only used in snow
w97 E.V.. 9/7 wavelet, only used in snow
dctmax E.V..
chroma E.V..

-dia_size <int> E.V.. diamond type & size for motion estimation
-last_pred <int> E.V.. amount of motion predictors from the previous frame
-preme <int> E.V.. pre motion estimation
-pre_dia_size <int> E.V.. diamond type & size for motion estimation pre-pass
-subq <int> E.V.. sub pel motion estimation quality
-me_range <int> E.V.. limit motion vectors range (1023 for DivX player)
-ibias <int> E.V.. intra quant bias
-pbias <int> E.V.. inter quant bias
-coder <int> E.V..
vlc E.V.. variable length coder / huffman coder
ac E.V.. arithmetic coder
raw E.V.. raw (no encoding)
rle E.V.. run-length coder
deflate E.V.. deflate-based coder
-context <int> E.V.. context model
-mbd <int> E.V.. macroblock decision algorithm (high quality mode)
simple E.V.. use mbcmp (default)
bits E.V.. use fewest bits
rd E.V.. use best rate distortion
-sc_threshold <int> E.V.. scene change threshold
-lmin <int> E.V.. min lagrange factor (VBR)
-lmax <int> E.V.. max lagrange factor (VBR)
-nr <int> E.V.. noise reduction
-rc_init_occupancy <int> E.V.. number of bits which should be loaded into the rc buffer before decoding starts
-inter_threshold <int> E.V..
-flags2 <flags> EDVA.
fast E.V.. allow non spec compliant speedup tricks
sgop E.V.. strictly enforce gop size
noout E.V.. skip bitstream encoding
local_header E.V.. place global headers at every keyframe instead of in extradata
bpyramid E.V.. allows B-frames to be used as references for predicting
wpred E.V.. weighted biprediction for b-frames (H.264)
mixed_refs E.V.. one reference per partition, as opposed to one reference per macroblock
dct8x8 E.V.. high profile 8x8 transform (H.264)
fastpskip E.V.. fast pskip (H.264)
aud E.V.. access unit delimiters (H.264)
brdo E.V.. b-frame rate-distortion optimization
skiprd E.V.. RD optimal MB level residual skipping
ivlc E.V.. intra vlc table
drop_frame_timecode E.V..
non_linear_q E.V.. use non linear quantizer
-error <int> E.V..
-qns <int> E.V.. quantizer noise shaping
-mb_threshold <int> E.V.. macroblock threshold
-dc <int> E.V.. intra_dc_precision
-nssew <int> E.V.. nsse weight
-skip_threshold <int> E.V.. frame skip threshold
-skip_factor <int> E.V.. frame skip factor
-skip_exp <int> E.V.. frame skip exponent
-border_mask <float> E.V.. increases the quantizer for macroblocks close to borders
-mblmin <int> E.V.. min macroblock lagrange factor (VBR)
-mblmax <int> E.V.. max macroblock lagrange factor (VBR)
-mepc <int> E.V.. motion estimation bitrate penalty compensation (1.0 = 256)
-bidir_refine <int> E.V.. refine the two motion vectors used in bidirectional macroblocks
-brd_scale <int> E.V.. downscales frames for dynamic B-frame decision
-crf <float> E.V.. enables constant quality mode, and selects the quality (x264)
-cqp <int> E.V.. constant quantization parameter rate control method
-keyint_min <int> E.V.. minimum interval between IDR-frames (x264)
-refs <int> E.V.. reference frames to consider for motion compensation (Snow)
-chromaoffset <int> E.V.. chroma qp offset from luma
-bframebias <int> E.V.. influences how often B-frames are used
-trellis <int> E.VA. rate-distortion optimal quantization
-directpred <int> E.V.. direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)
-complexityblur <float> E.V.. reduce fluctuations in qp (before curve compression)
-deblockalpha <int> E.V.. in-loop deblocking filter alphac0 parameter
-deblockbeta <int> E.V.. in-loop deblocking filter beta parameter
-partitions <flags> E.V.. macroblock subpartition sizes to consider
parti4x4 E.V..
parti8x8 E.V..
partp4x4 E.V..
partp8x8 E.V..
partb8x8 E.V..
-sc_factor <int> E.V.. multiplied by qscale for each frame and added to scene_change_score
-mv0_threshold <int> E.V..
-b_sensitivity <int> E.V.. adjusts sensitivity of b_frame_strategy 1
-timecode_frame_start <int> E.V.. GOP timecode frame start number, in non drop frame format


After reading this http://forum.videohelp.com/topic342608.html and doing some experimenting i used the idea more=better. (replace -pass 0 with 1 or 2)ffmpeg.exe -i in.avs -pass 0 -y -vcodec flv -b 500000 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 1 -coder 5 -mbd 2 -flags2 mixed_refs+brdo+skiprd+non_linear_q -refs 5 -trellis 1 -partitions parti4x4+parti8x8+partp4x4+partp8x8 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 out.flv
Anyone want to improve? This is video only right now. Don't use "-mbd 3" (rd: use best rate distortion) or b frames, other then that, just about anything can be changed. -cmp 4 (dct: sum of absolute DCT transformed differences) crashes ffmpeg btw.

Run this after (add keyframes to the metadata for seeking)
http://www.buraks.com/flvmdi/

mikeytown2
18th February 2008, 22:16
I added the Notch matrix to the mix, the video looks wrong/off in some areas. Any ideas?
ffmpeg.exe -i in.avs -pass 0 -y -vcodec flv -b 358400 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 1 -coder 5 -mbd 2 -flags2 mixed_refs+brdo+skiprd+non_linear_q -refs 5 -trellis 1 -partitions parti4x4+parti8x8+partp4x4+partp8x8 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -intra_matrix "8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,31,36,37,38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79" -inter_matrix "16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44" out.flv

EDIT

I've been playing around with the matrix settings as well as some others. This is what i've come up with
For Low Bitrate 2pass Encodes (notch matrix (http://www.kvcd.net/portal/articles.php?lng=en&pg=20)); using the idea more=better
Pass 1ffmpeg.exe -i in.avs -pass 1 -y -vcodec flv -b 346112 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 9 -coder 5 -mbd 2 -trellis 10 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -flags2 mixed_refs+brdo+skiprd+non_linear_q -partitions parti4x4+parti8x8+partp4x4+partp8x8 -inter_matrix "16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44" out.flv
Pass 2ffmpeg.exe -i in.avs -pass 2 -y -vcodec flv -b 346112 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 9 -coder 5 -mbd 2 -trellis 10 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -flags2 mixed_refs+brdo+skiprd+non_linear_q -partitions parti4x4+parti8x8+partp4x4+partp8x8 -inter_matrix "16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44" out.flv

For Higher Bitrate 2pass Encodes (h.264 HighDetail-V3.1 matrix (http://forum.doom9.org/showthread.php?p=887125)); using the idea more=better
Pass 1ffmpeg.exe -i in.avs -pass 1 -y -vcodec flv -b 716800 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 9 -coder 5 -mbd 2 -trellis 10 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -flags2 mixed_refs+brdo+skiprd+non_linear_q -partitions parti4x4+parti8x8+partp4x4+partp8x8 -inter_matrix "12,12,12,12,13,16,19,25,12,12,12,12,13,16,21,27,12,12,13,15,18,21,26,33,12,12,15,21,25,30,37,45,13,13,18,25,34,43,54,64,16,16,21,30,43,60,76,94,19,21,26,37,54,76,102,132,25,27,33,45,64,94,132,177" out.flvPass 2ffmpeg.exe -i in.avs -pass 2 -y -vcodec flv -b 716800 -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g 250 -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 9 -coder 5 -mbd 2 -trellis 10 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -flags2 mixed_refs+brdo+skiprd+non_linear_q -partitions parti4x4+parti8x8+partp4x4+partp8x8 -inter_matrix "12,12,12,12,13,16,19,25,12,12,12,12,13,16,21,27,12,12,13,15,18,21,26,33,12,12,15,21,25,30,37,45,13,13,18,25,34,43,54,64,16,16,21,30,43,60,76,94,19,21,26,37,54,76,102,132,25,27,33,45,64,94,132,177" out.flv