digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Video Encoding and Conversion (http://www.digitalfaq.com/archives/encode/)
-   -   KVCD: Using templates in linux (transcode/ffmpeg) (http://www.digitalfaq.com/archives/encode/4440-kvcd-templates-linux.html)

japie 07-10-2003 11:59 AM

Using templates in linux (transcode/ffmpeg)
 
Hello,

Has someone succesfully created a kvcd or ksvcd with one off the linuxtools like transcode or ffmpeg?
I've been trying for the past 2 days, but I don't know how to pass the right options to transcode for the ksvcd/120min. template.
Another option would be ffmpeg for creating kvcd, the newer versions have excelent quality (option -hq) and are bleeding fast (4x tmpgenc), but only makes mpeg1 video.
Can someone help me out?

kwag 07-10-2003 12:33 PM

Hi japie,

You need to recompile the encoders with KVCD's Q. Matrix. I believe the GOP can be set in ffmpeg. Not sure about transcode.
Just get the source for ffmpeg and change the matrix :)

Here's the matrix
Code:

Intra:
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
Non-Intra:
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



-kwag

japie 07-10-2003 02:22 PM

Quote:

Originally Posted by kwag
You need to recompile the encoders with KVCD's Q. Matrix. I believe the GOP can be set in ffmpeg.
Just get the source for ffmpeg and change the matrix :)

Wow, not every linux user is a coder ;)
But I looked at the source and found mpeg12data.h with:
Code:

const int16_t ff_mpeg1_default_intra_matrix[64] = {
        8, 16, 19, 22, 26, 27, 29, 34,
        16, 16, 22, 24, 27, 29, 34, 37,
        19, 22, 26, 27, 29, 34, 34, 38,
        22, 22, 26, 27, 29, 34, 37, 40,
        22, 26, 27, 29, 32, 35, 40, 48,
        26, 27, 29, 32, 35, 40, 48, 58,
        26, 27, 29, 34, 38, 46, 56, 69,
        27, 29, 35, 38, 46, 56, 69, 83
};

const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
};

So I suppose this is what I'am looking 4.
There's also a possibility to define the gop_size but how do I "extract" the data I need from the tmpgenc_sheets?

kwag 07-10-2003 02:30 PM

Quote:

Originally Posted by japie
Quote:

Originally Posted by kwag
You need to recompile the encoders with KVCD's Q. Matrix. I believe the GOP can be set in ffmpeg.
Just get the source for ffmpeg and change the matrix :)

Wow, not every linux user is a coder ;)
But I looked at the source and found mpeg12data.h with:
Code:

const int16_t ff_mpeg1_default_intra_matrix[64] = {
        8, 16, 19, 22, 26, 27, 29, 34,
        16, 16, 22, 24, 27, 29, 34, 37,
        19, 22, 26, 27, 29, 34, 34, 38,
        22, 22, 26, 27, 29, 34, 37, 40,
        22, 26, 27, 29, 32, 35, 40, 48,
        26, 27, 29, 32, 35, 40, 48, 58,
        26, 27, 29, 34, 38, 46, 56, 69,
        27, 29, 35, 38, 46, 56, 69, 83
};

const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
    16, 16, 16, 16, 16, 16, 16, 16,
};

So I suppose this is what I'am looking 4.

That's exactly it :D
Quote:

There's also a possibility to define the gop_size but how do I "extract" the data I need from the tmpgenc_sheets?
I think the GOP would be set on a command line argument :!:
I'm not sure if the tar file in the CVS is compilable in Windows environment. Maybe I'll get my hands dirty with the code, and see if it compiles :cool:

-kwag

japie 07-10-2003 03:13 PM

Quote:

Originally Posted by kwag
I think the GOP would be set on a command line argument :!:
I'm not sure if the tar file in the CVS is compilable in Windows environment. Maybe I'll get my hands dirty with the code, and see if it compiles :cool:

Youll won't be sorry :)
Maybe I'am a bit rude now, but I'am posting the command line ffmpeg options so if it won't compile, you can atleast see what your missing ;)
Code:

Main options are:
-L                  show license
-h                  show help
-formats            show available formats, codecs, protocols, ...
-f fmt              force format
-img img_fmt        force image format
-i filename        input file name
-y                  overwrite output files
-t duration        set the recording time
-title string      set the title
-author string      set the author
-copyright string  set the copyright
-comment string    set the comment
-pass n            select the pass number (1 or 2)
-passlogfile file  select two pass log file name
-b bitrate          set video bitrate (in kbit/s)
-r rate            set frame rate (in Hz)
-s size            set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-croptop size      set top crop band size (in pixels)
-cropbottom size    set bottom crop band size (in pixels)
-cropleft size      set left crop band size (in pixels)
-cropright size    set right crop band size (in pixels)
-vn                disable video
-bt tolerance      set video bitrate tolerance (in kbit/s)
-maxrate bitrate    set max video bitrate tolerance (in kbit/s)
-minrate bitrate    set min video bitrate tolerance (in kbit/s)
-bufsize size      set ratecontrol buffere size (in kbit)
-sameq              use same video quality as source (implies VBR)
-ab bitrate        set audio bitrate (in kbit/s)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                disable audio

Advanced options are:
-map file:stream    set input stream mapping
-re                read input at native frame rate
-pix_fmt format    set pixel format
-g gop_size        set the group of picture size
-intra              use only intra frames
-qscale q          use fixed video quantiser scale (VBR)
-qmin q            min video quantiser scale (VBR)
-qmax q            max video quantiser scale (VBR)
-mbqmin q          min macroblock quantiser scale (VBR)
-mbqmax q          max macroblock quantiser scale (VBR)
-qdiff q            max difference between the quantiser scale (VBR)
-qblur blur        video quantiser scale blur (VBR)
-qcomp compression  video quantiser scale compression (VBR)
-rc_init_cplx complexity  initial complexity for 1-pass encoding
-b_qfactor factor  qp factor between p and b frames
-i_qfactor factor  qp factor between p and i frames
-b_qoffset offset  qp offset between p and b frames
-i_qoffset offset  qp offset between p and i frames
-rc_eq equation   
-rc_override qualities for specific intervals  Rate control override
-vd device          set video grab device
-vc channel        set video grab channel (DV1394 only)
-tvstd standard    set television standard (NTSC, PAL (SECAM))
-dv1394            set DV1394 grab
-vcodec codec      force video codec ('copy' to copy stream)
-me method          set motion estimation method
-dct_algo algo      set dct algo
-idct_algo algo    set idct algo
-er                set error resilience
-ec                set error concealment
-bf frames          use 'frames' B frames (only MPEG-4)
-hq                activate high quality settings
-4mv                use four motion vector by macroblock (only MPEG-4)
-part              use data partitioning (only MPEG-4)
-bug param          workaround not auto detected encoder bugs
-ps size in bits    packet size
-strict how strictly to follow the standarts  strictness
-debug              print specific debug info
-ad device          set audio device
-acodec codec      force audio codec ('copy' to copy stream)
-deinterlace        deinterlace pictures
-benchmark          add timings for benchmarking
-hex                dump each input packet
-psnr              calculate PSNR of compressed frames
-vstats            dump video coding statistics to file
-bitexact          only use bit exact algorithms (for codec testing)
-vhook module name and parameters  insert video processing module
-aic                enable Advanced intra coding (h263+)
-umv                enable Unlimited Motion Vector (h263+)

A lot off options are bogus, the package contains ffmpeg AND ffserver, wich is an streaming_video_daemon.
It reads from file or video device and spits it's data on the web in a variety off different formats on rtsp, http, whatever U want.

But how do I place the GOP size here?
I started with the KVCD-CQ-352x576-_PAL_-PLUS.mcf and I gues I have to use:
352x576
800 kbits/sec.
ratecontrol buffer size 40K.
gop size ?
I don't know, will try again tomorrow.
b.t.w; compiling with the new matrix went fine, it's in place and (hopefully) working.

kwag 07-10-2003 03:27 PM

Right there it is :arrow: "-g gop_size set the group of picture size" :)

So the parameter in the command line would be -g 24 :wink:

Edit: Do you have a Windows executable :?:

-kwag

japie 07-10-2003 11:19 PM

Quote:

Originally Posted by kwag
Edit: Do you have a Windows executable :?:
-kwag

Sorry, I was wrong, there is no windows exe.
It is possible to build it under windows using MinGW, I yust downloaded it and will try to build it 4 U, but don't know or it will run stand-alone on win.
There are win-project who use the codec doo.

I decoded a 10 min. divx with the new matrix in 4 min. with a terrible result:
http://japie.is.dreaming.org/ftp/test.jpg
:(

kwag 07-10-2003 11:24 PM

Quote:

Originally Posted by japie

I decoded a 10 min. divx with the new matrix in 4 min. with a terrible result:
http://japie.is.dreaming.org/ftp/test.jpg
:(

You probably have to adjust the CQ or quality settings. They will not be the same as with the standard MPEG matrix.

-kwag

japie 07-11-2003 09:40 AM

Quote:

Originally Posted by kwag
You probably have to adjust the CQ or quality settings. They will not be the same as with the standard MPEG matrix.

Where do I find these in the template?

I tryed to compile ffmpeg with mingw32 but didn't suxeed :( maybe you have more luck using you native windowz compiler.

girv 07-11-2003 11:12 AM

@japie: FWIW I'd be interested in a Win32 build of ffmpeg as well, should you ever make one :)

japie 07-11-2003 12:57 PM

Quote:

Originally Posted by girv
@japie: FWIW I'd be interested in a Win32 build of ffmpeg as well, should you ever make one :)

I'am not a coder and surtanly not a windowz one ;)
I tryed to build it but did not suxeed.
On the other hand, the binairy isn't available but the actual coding part is available 4 windowz as libavcodec and is used in quite a lott apps. like ffdshow.
So if those guys can port the lib, the bin is portable as well too (I think).
I have no clue. My knowledge doesn't go any further than doing a ./configure and make.

japie 07-11-2003 11:58 PM

Quote:

Originally Posted by kwag
You need to recompile the encoders with KVCD's Q. Matrix. I believe the GOP can be set in ffmpeg. Not sure about transcode.

Yust found the next mailing about transcode:
http://zebra.fh-weingarten.de/~maxi/.../msg00035.html
Where can I find the matrix for ksvcd?

kwag 07-12-2003 12:14 AM

Quote:

Originally Posted by japie
Quote:

Originally Posted by kwag
You need to recompile the encoders with KVCD's Q. Matrix. I believe the GOP can be set in ffmpeg. Not sure about transcode.

Yust found the next mailing about transcode:
http://zebra.fh-weingarten.de/~maxi/.../msg00035.html
Where can I find the matrix for ksvcd?

KVCD's matrix is patched on all TMPGEnc templates on this site ;)
It's the same matrix for all resolutions :)
http://www.kvcd.net/e107/article.php?21.255

-kwag

japie 07-12-2003 10:17 AM

Quote:

Originally Posted by kwag

That's the info I'am looking 4, so if I understand correctly the only 3 things changed against normal vcd/svc are; matrixes, GOP size and resolution?
I will try to make an kvcd and an ksvcd and will post my findings and used commandline for next generations. ;)

japie 07-13-2003 04:41 AM

Hello guys,

Here's how to make a ksvcd_pal_120min under linux in a bleeding fast 8 frames per seconds :( (but it works)
Youll need transcode and mplayer 4 this.
Create 3 files and place them in /usr/lib/transcode

ksvcd.prof
Code:

gop_size = 25
frame_rate = 25.0
fixed_vbv_delay = 1
cbr = 0
max_bitrate = 64000.0
min_bitrate = 3000000.0
dc_prec = 0
iqname = intra.txt
niqname = non_intra.txt

cat intra.txt
Code:

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

non_intra.txt
Code:

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

Next, create a script mkksvcd
Code:

transcode -x mplayer -i "$1" -y mpeg -Fs,/usr/lib/transcode/ksvcd.prof -E 44100 -b 128 -Z 528x576 -j -56 -o "ksvcd"
#the above is one line
mplex -f 5 -o "ksvcd%d.mpeg" "ksvcd.m2v" "ksvcd.mpa"
rm ksvcd.m2v
rm ksvcd.mpa

Make it executable and place it in /usr/bin
Run from comandline:
mkksvcd /path/to/your/file.avi and go to bed, wake up go to your work, take a shower, go to bed again and optionaly have sex and maybe the next morning you can burn the thing :)

kwag 07-13-2003 11:15 AM

Hi japie,

Aren't your bitrates inverted :cool:
Code:

max_bitrate = 64000.0
min_bitrate = 3000000.0

:?:

Also, remove the "cat" from the "cat intra.txt" ( we don't want to type that line ;) )

-kwag

japie 07-15-2003 06:56 AM

Quote:

Originally Posted by kwag
Hi japie,
Aren't your bitrates inverted :cool:
Code:

max_bitrate = 64000.0
min_bitrate = 3000000.0

:?:
-kwag

Oops :)

Anyway, I sucsesfuly created the streams only one problem...
I have a video stream of 600Mb. and a audio stream of 90Mb. but after multiplexing I have a 950Mb. video, that doesn't fit on a cd :O

Also I did some benchmarks in vcd format. (to show how fast ffmpeg is, altough it's unuseable for kvcd at the moment)
Testvideo reloaded_superbowl.avi 01:02
VIDEO: [DX50] 640x480 24bpp 24,72 fps 1175,6 kbps (143,5 kbyte/s)
AUDIO: [MP3] 44100 Hz, 2 ch, 16 bit (0x10), ratio: 16000->176400 (128,0 kbit)

benchmarks:
ffmpeg 00:15 mpeg
mpeg2enc 01:43 m1v + mp2
bbmpeg 01:39 m1v + mp2
tmpgenc 00:59 mpeg
mainconcept 00:20 mpeg

Nice to see that an opensource project like ffmpeg beets the mainconcept encoder :)

serrabastien 07-15-2003 07:50 AM

Quote:

Originally Posted by japie
Anyway, I sucsesfuly created the streams only one problem...
I have a video stream of 600Mb. and a audio stream of 90Mb. but after multiplexing I have a 950Mb. video, that doesn't fit on a cd :O

Maybe there's a problem with the header. Try to remux it with bbmpeg.

Quote:

Originally Posted by japie
Also I did some benchmarks in vcd format. (to show how fast ffmpeg is, altough it's unuseable for kvcd at the moment)
Testvideo reloaded_superbowl.avi 01:02
VIDEO: [DX50] 640x480 24bpp 24,72 fps 1175,6 kbps (143,5 kbyte/s)
AUDIO: [MP3] 44100 Hz, 2 ch, 16 bit (0x10), ratio: 16000->176400 (128,0 kbit)

benchmarks:
ffmpeg 00:15 mpeg
mpeg2enc 01:43 m1v + mp2
bbmpeg 01:39 m1v + mp2
tmpgenc 00:59 mpeg
mainconcept 00:20 mpeg

Nice to see that an opensource project like ffmpeg beets the mainconcept encoder :)

What about the quality ?

I'm very happy coz i've post some weeks ago about help to make kvcd under Linux. If we work together I think it will be possible.
I've read somewhere that someone is porting avisynth under Linux.

'Z

japie 07-15-2003 09:17 AM

Quote:

Originally Posted by 'Z
Maybe there's a problem with the header. Try to remux it with bbmpeg.

It's a linux mplex problem, using standard vcd I get a big file, and when using userbitrate -V (variable) I have to specify the max bitrate but ends up with a/v not not sync.
I used tmpgenc_mplex_variable_bitrate and alzwell now.

Quote:

Originally Posted by 'Z
What about the quality ?

All good. I used 4 all apps default settings exept for ffmpeg, I used that one with option -hq (high quality) because standard it's bad. (but faster)
These were creating a standard vcd mpeg.

kwag 07-15-2003 11:05 AM

I'm going to put this on my schedule :)
I have ffmpeg and ffmpegX (graphical front end) on a PowerPC G4 running Mac OS X 10.2.
I just need to get the latest source and recompile it with the matrix. I'll do some tests later today.

-kwag


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

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.