Quantcast FFmpeg: Using Other Matrix (e.G. Notch)? - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Video Encoding and Conversion

Reply
 
LinkBack Thread Tools
  #1  
09-06-2003, 06:03 PM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
Is it possible? I couldn't find anything on the web (there isn't a real documentation... is there?)
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
09-06-2003, 07:05 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Razorblade2000
Is it possible? I couldn't find anything on the web (there isn't a real documentation... is there?)
I think japie already did that.
I'll take a look. It should only be a matter of changing the matrix in the source, and recompiling.

-kwag
Reply With Quote
  #3  
09-07-2003, 12:16 AM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
I think japie already did that.
I'll take a look. It should only be a matter of changing the matrix in the source, and recompiling.
I did that and it gave a very bad result, after some postings in the mailinglist one of the developers answerd:
> I tryed to replace the standard one in mpeg12data.h, but that didn't
> work ut as I expected.
ohh u can do that too, but u forgot to change the default matrixes of every
other mpeg1/2 codec
> Sorry to bother, but how do I use a custom matrix?
set AVCodecContext.inter_matrix / intra_matrix

Only I still don't know how to pass this to the commandline...
__________________
Groetjes Japie
Reply With Quote
  #4  
10-07-2003, 06:04 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
It's perfectly possible using mencoder.
Reply With Quote
  #5  
10-07-2003, 06:36 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
mencoder is based on ffmpeg?
I never really got it... Searching for ffmpeg always gave me various mencoder results... (looking for mplayer gave me too)
Reply With Quote
  #6  
10-07-2003, 06:51 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, mplayer/mencoder is heavily based on ffmpeg (only libavcodec).
Although you can encode with mencoder with divx or xvid too, encoding with the ffmpeg family is the recomended option.
Since version 1.0pre1, they added the option to pass custom /inter/intra matrices to ffmpeg when encoding in mpeg1video or mpeg2video, even in the new documentation is an example using the kvcd notch matrix, which I have used since I saw it.

Personally, I find it very convenient to encode with mencoder because it includes a series of filters (resizing, cropping, adding black bars, deblocking, deringing, denoise3d, etd).
In my tests I am able to obtaing really surprising KSVCD encodes (480x756, mpeg2, notch matrix) with average bitrates of 1000 to 1500 (I never thought it was possible to get good quality with mpeg2 in this resolution with this bitrates, now I'm trying to lower it even more). The only problem I find is with the ratecontrol (I get peaks of more than 6000) but it's a problem in ffmpeg, I follow the development lists, and they are going to try a new ratecontrol system, I hope they honor in it the max bitrate!
Reply With Quote
  #7  
10-07-2003, 09:46 AM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Can you please, please, please, share your commandline options with us?
__________________
Groetjes Japie
Reply With Quote
  #8  
10-07-2003, 10:06 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
mencoder -nosound -of mpeg -ovc lavc -lavcopts
vcodec=mpeg2video:vmax_b_frames=2:mbd=2:keyint=15: vpass=1:aspect=4/3:vbitrate=1500:vrc_maxrate=2500:vrc_minrate=128:v rc_buf_size=1840:vlelim=-4:vcelim=7:vstrict=1recmp=2:cmp=2:subcmp=2:trell :cbp:vqcomp=0: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,2 6,27,31,36,37,38,40,26,27,29,36,39,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,2 6,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30, 32,34,36,38,40,42,44
-vf pp=hb/vb/dr,hqdn3d,scale=480:432,expand=480:576 -sws 9 -o out_file.mpg Homeworld1024.avi

Then, the same but with vpass=2 for the second pass.

Here I have used keyint=15, that means one I-Frame every 15 = GOP of 15 frames, can be changed to whatever you want.
Also vmax_b_frames=2, so 2 B frames (IBBPBBPBBPBBPBB)
intra_matrix and inter_matrix are the notch matrices (I haven't checked, but the documentation says that in the example, and I just copied the matrices from there).
vrc_maxrate and vrc_minrate are, supposedly, max and min bitrate, but they don't work as intended (I have got peaks of 6000 sometimes)
-vf pp (Video Filters PostProcessing), hb= horizontal deblock, vb=vertical deblock, dr = deringing, hqdn3d = high quality denoise 3d, scale to 480x432, expand with black bars to 480x576
sws is the scaling algorithm (lanczlos)
and buf_size is in kbits, so 1840 kbits=230 kBytes.
vqcomp is to follow bitrate more than quality (although even with this I get exagerated peaks). Seems they are working on it, though.

Then, you must do 'mplayer -dumpvideo -dumpfile out_file.m2v out_file.mpg' to get the m2v that will be muxed with the mp2.

I get impressive quality... but these bitrate peaks give me headaches.
Some people have posted all kind of tricks to make it follow the bitrate, but none of them works really OK. I wait for the new bitrate control code in ffmpeg, and hope it will be better!
Reply With Quote
  #9  
10-07-2003, 11:12 AM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Encoding time is far below what ffmpeg itself does, I've made an kvcd (I hope) with:
Code:
mencoder -nosound -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video:vmax_b_frames=2:mbd=2:keyint=15:aspect=4/3:vbitrate=1150:vrc_maxrate=2400:vrc_minrate=300:vrc_buf_size=320:vlelim=-4:vcelim=7:vstrict=1:precmp=2:cmp=2:subcmp=2:trell:cbp:vqcomp=0: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,29,36,39,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 -vf pp=hb/vb/dr,hqdn3d,scale=352:240 -sws 9 -o out_file.mpg Downloads/my_movie.avi
But it's slower than mpeg2enc.
Is there a way to add the matrix option to ffmpeg itself? (I've been looking in the source for that, but can't find any)
__________________
Groetjes Japie
Reply With Quote
  #10  
10-07-2003, 11:36 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Well, you have made something strange then, it's MUCH FASTER than mpeg2enc. It's exactly the same speed as ffmpeg, 'cause in fact it's ffmpeg.
Anopther thing is all the filters you are using, etc.

Try using only the matrices, but taking out mbd, precmp, cmp and subcmp, trell, cbp, pp (all three) and hqdn3d and you'll see. If you activate the ffmpeg options (mbp, all three cmp, trell and cbp) in fmpeg, they have the same effect as here. And for the filters, both scaling and denoise3d are faster than the equivalents yuvscale and yuvdenoise from mjpegtools.

I use this options (not always, sometimes others) for maximum quality, don't use them and nothing will rival on speed.
Reply With Quote
  #11  
10-09-2003, 01:14 PM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by lemon
Well, you have made something strange then, it's MUCH FASTER than mpeg2enc. It's exactly the same speed as ffmpeg, 'cause in fact it's ffmpeg.
I feel a bit stupid, your right.
While encoding I viewed in the meentime with mplayer and it was showing me that after 10min. encoding the movie lasted 3min.
I was a bit fooled by that.
Is there a way to encode audio in the same line?
__________________
Groetjes Japie
Reply With Quote
  #12  
10-09-2003, 03:45 PM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Well. now I have been trying some more, and using only hqdn3d, taking out all other filters/special comparators/etc, it goes much faster and I don't see much difference in the final quality.
I'm finding now when trying to make SKVCDs at 1500, that they are at end at about 750/800 (it makes q=3 for I and P frames, q=5 for B frames), but with peaks of between 3000 and 4000. I don't know why but it makes some I frames q=2 even when I specify vqmin=3...
When I have time I'll look to the ratecontrol code to see if something can be done about these peaks (no one seems to find a solution in the devel list, perhaps is because they are trying the new ratecontrol system).

Well, if you look with mplayer, it will take the max bitrate for doing calculations (so, a 1 hour movie with medium bitrate 1000 and max bitrate 3000 will shou up as having only 20 min).
Anyone knows how to 'repair' this thing?
Reply With Quote
  #13  
10-10-2003, 12:44 PM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
could you give me a "sample" command line...
2 much man pages *g*
Reply With Quote
  #14  
10-16-2003, 12:44 AM
tetra tetra is offline
Free Member
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Hello all,

I've been using the two examples (KSVCD and KVCD) lemon and japie have given in this thread.

The movie I'm trying to convert is a DivX/25 FPS. Problem is, the resulted .mpg video goes out of sync with audio. Also I get LOTS of weird messages during encoding (I'm encoding in 2 passes), something like these:
Code:
Warning: DTS to SCR delay is too small  31min 275mb  A-V:0.000 [881:0]
Error in stream: PTS earlier than SCR!
Error in stream: PTS to SCR delay 0 is too little!
Error in stream: PTS earlier than SCR!
Error in stream: PTS to SCR delay 0 is too little!
The procedure which I'm doing the encodings goes like this:

1) Run both passes on the movie with either lemon's or japie's example commandlines.
2) Dump the video from the .mpg which came out of step 1. Command is this:
Code:
mplayer -dumpvideo -dumpfile outfile.m2v test.mpg
3) Dump audio from original .avi, pipe it to mp2enc, with these commands:
Code:
mkfifo -m 660 outfile.pcm
cat outfile.pcm | mp2enc -v 0 -b 112 -r 44100 -s -o outfile.mp2 &
mplayer -noframedrop -ao pcm -aofile outfile.pcm -vo null movie.avi"
4) Marry the two separated streams, with this:
Code:
tcmplex -i outfile.m2v -p outfile.mp2 -m 2 -o result.mpg
Any help on this is greatly appreciated!

/tetra
Reply With Quote
  #15  
10-16-2003, 09:19 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
I get these weird messages when the mpeg stream gets out of bitrate/buffersize specified.

I have managed to create one SVCD more or less 'compliant'. The audio was out of sync, bit I arranged it manually with the -O option of mplex.

Right now, my commandline doesn't have ANY filter (except crop, resize and expand, of course), I seem to get more quality these way, strange, and of course much more speed.
I have checked also that I get more quality if I don't use the knotch matrix. In both cases the final medium bitrate is much lower than what I specify, but with the normal matrix is is just a bit higher (just a bit) and I get much more quality.
Reply With Quote
  #16  
10-16-2003, 09:29 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
doesn't the 2 pass option create accurate results (as in ffmpeg)?
Reply With Quote
  #17  
10-16-2003, 09:36 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Nor in mencoder nor in ffmpeg creates acurate results.
Only medium bitrate is accurate. Maximum bitrate is not respected.
Reply With Quote
  #18  
10-29-2003, 11:51 AM
lemon lemon is offline
Free Member
 
Join Date: Oct 2003
Location: Berlin (PAL)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Well, it seems that the new ratecontrol system respects now the limits. I have been able to create a standard SVCD without problems.
Reply With Quote
  #19  
10-29-2003, 02:32 PM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
I've made a little script to create a full kvcd_3 stream, in the past I always stuck to 352x240 but I tryed the 528:480 this time.
http://japie.is.dreaming.org/ftp/KVC...d_ffmpeg.sh.gz
It has a really nice quality untill the action start, very blocky.
If someone has any ideas about this?

p.s. You need mplayer-1.x, ffmpeg-0.4.8 and lsdvd http://acidrip.thirtythreeandathird.net/lsdvd.html
__________________
Groetjes Japie
Reply With Quote
  #20  
12-03-2003, 02:06 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
http://www.kvcd.net/forum/viewtopic.php?t=7771
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Notch matrix the default matrix from the KDVD template? jzhao66 Video Encoding and Conversion 2 06-29-2005 03:25 AM
FFMPEG: Ffvfw help needed with the notch matrix Zyphon Video Encoding and Conversion 3 04-29-2004 02:39 AM
FFMPEG: NOTCH Matrix for ffvfw mpeg2 encoding, get it here... incredible Video Encoding and Conversion 3 02-01-2004 12:03 PM
KVCD notch matrix! jorel Video Encoding and Conversion 1 08-28-2003 11:25 AM
Old KVCD Matrix verses new Notch Matrix jamesp Avisynth Scripting 4 03-20-2003 03:48 PM




 
All times are GMT -5. The time now is 01:57 PM  —  vBulletin © Jelsoft Enterprises Ltd