KVCD using Menkoder?
http://www.digitalfaq.com/archives/error.gif
It is a template script, not interactive. If you are a developer (I'm a not) you can encapsulate into interactive script or GUI, gtk preferable. In the script you have at least to chose resolution width*height, fps (if you change them), mpeg (1 or 2) and vcd type for multiplexing and imaging. Video bitrate can be entered in commad line, so don't edit it. Edit the section between dash lines. The script is capable to scale into NTSC/PAL dimensions if the source is fit - width is used as a base to scale (with original aspect ratio), so scaled height have to be within allowed height for NTSC or PAL. It is assumed that you know xvcd and svcd specifications and familiar with mencoder options. (I've just checked on a stream capture that telecine from 10fps to 27.97fps is bearable, but still the problems with video-audion sync. The same situation with inverse telecine from 27.97fps to 25fps). |
Code:
#!/bin/bash |
Scaling to correct VCD and SVCD aspects is not implemented in this script. There is useful page about video resolutions and aspect ratio conversions:
:arrow: http://www.uwasa.fi/~f76998/video/conversion/ :arrow: http://hkfanatic.com/widescreen/ Currently I use the script for pre- and post-processing for XVCD and SVCD. If somebody can add scaling into the script? Code:
#!/bin/bash |
Russiansexpat:
You appear to be having an interesting discourse with yourself! Can you or someone else explain what it is you are talking about? :roll: |
Quote:
This is an advanced topic, and very good information :cool: This is related to Linux and Unix systems. -kwag |
Sorry, I guess this is just out of my league :oops:
I was just curious what he was talking about, as noone else was responding. |
|
:lol:
|
Quote:
I use the following: (you need mplayer-cvs for this) Code:
#!/bin/bash Quote:
|
Below is a version of the script with constant quality encoding, and I put some comments in the code.
It appears to be faster and easy to use, just watch output line of mencoder - last field of this line is a current encoding bitrate, and also in this line you can see estimated time of completion and file size, so you can terminate the script if you don't like them. Compression is improved, maybe because of ":naq:dia=2:last_pred=2" adaptive quantisation and motion prediction parameters. Currently I can fit 1.5 hour movie at SVCD resolution with vbitrate around 1200 kbps into single CD. Constant quality is less than 6. (some minor problem with maxrate - when you select high quality, the maxrate is exceeded; nevertheless tcmplex clipped bitrates to 2300 max and vcdimager didn't complain.) Code:
#!/bin/bash |
That is a really nice thread, got some ideas. But to give you something back, here some thoughts:
if you use mplayer-cvs you can do it like japie wroteabove: audio encoding directly with mencoder, but can using a three pass method, in which you only encode audio once and get a prediction in the end of the first pass, which gives you an estimation of the bitrate one should use for video encoding. This can be used for setting the vbitrate automatically (as this estimation isn't meant for kvcds, it probably must be trimmed somewhat). Also, you can use cropdetect and crop to get rid of the black bands and the scale and expand to have your aspect ratio correct. So here are my modifications of the vbr script for trying yourself: Code:
#!/bin/bash Have Fun with KVCD in Linux! Greetings, Neturmel |
Quote:
cropdetect is nice to have, but you looking only into for first 50 frames. For ppl who wants to automate something in this cript, try use http://mpgtx.sourceforge.net and tcscan for transcode to get inormation about the source. |
Hi,
in my case, expand just adds enough black bands (below and above the movie) to keep the original aspect ratio of the movie without the need for the player to get its aspect correct by itself (infamous "feature" of the windows media player). But honestly, that was only added by trial and error and by verifying the result on different hard- and software players. So it is possible that it is utterly useless for anyone else... Cropdetect on only 50 frames is no problem if you only encode the main movie. If there are trailers or menus etc. , you certainly should use more frames. Otherwise, the bands really shouldn't change in the main movie. But if you really want to be sure that your crop parameters are correct, just do it for 10min of movie ( would be at most 30*60*10= 18000 frames ) 2) By coincidence, I just started to test mpgtx myself (for splitting movies longer than the size of the CD before burning). Works well for mpeg1, but not for mpeg2. P.S.: Since I make KVCDs out of VDR-Recordings, I have found vdrsync.pl (http://vdrsync.vdr-portal.de) for remultiplexing and joining of cutted VDR material extremely useful (also uses parts of transcode) Hope that others won't find this just boring... neturmel |
Another hint:
it really seems that by using 2-pass encoding and vqscale=2 in the first pass, you really hit your vbitrate value for the second pass pretty perfect, so it should be possible to use the predicted bitrate for the planned CD size which was printed in the first (audio encoding) pass, see above. But have to test a little bit further... Greetings, neturmel |
"The audio stream must be MPEG-1 layer II, with a bit-rate ranging
from 32 to 384 kbits/sec bit-rate (i.e. the audio stream _is_ allowed to be VBR!) with up to 2 stereo or 4 mono channels, or 1 extended MPEG-1/2 multichannel (5+1) surround sound stream." -- http://www.vcdimager.org/pub/vcdimag.../vcdimager.txt Thus the script now uses toolame for audio encoding, http://mikecheng.d2.net.au/ also toolame can encode joint stereo and use diffrent acoustic models. If you choose AUDIORATE in editable section equal "VAR" the script will downsample frequency to 22050 Hz and encode with variable audio bitrate in 8 - 160 Kbps band. Audio is still stereo! See results below in this thread. mplex from http://mjpeg.sourceforge.net/ is used for multiplexing audio and video (tcmplex can't handle variable rate mp2) and it is not bad after all, you don't have to install heavyweight transcode package. Code:
#!/bin/bash |
I've been doing some testing and must say that 2-pass encoding doesn't change much... (in the mencoder a+v commandline), it only broke a/v_sync (as reposted on mailinglist)
vbr mp2 is actualy very interesting, anyone now how to handle it with mencoder? |
1) Just bumped into the ugly fact that tcmplex can't multiplex variable rate mp2 properly, so I'm switching to mplex usage.
Unfortunately, mplex rely on mpeg2enc to insert sequence break points. mplex option: -S This option specifies the maximum size of output files in MBytes (2^10). The default is 2000 Mbytes (splitting output before 2G limits can hit). When the limit is reached a new file is started. Note: This option is _n_o_t suitable for splitting a long video across multiple VCD's or SVCD's. It simply splits a single long sequence into in a way that prevents bits of a video GOP(group of pic* tures) or audio frame being split between chunks. frame reasonable. This is fine for formats like that used for DVDs where all stream parameters appear every GOP. However, for VCD / SVCD it won't work as the players expect each file to start a new MPEG sequence. For VCD / SVCD a different technique is used. If mplex encounters a sequence break (sequence end followed by start) in the input video stream it starts a new output stream and file at the sequence start. Thus to split a long video across VCD's/SVCD's you have to get the MPEG video encoder to introduce sequence splits at the right points (see mpeg2enc(1) for details of how to do this). I just ignore suggested mpeg2enc and use -S option of mplex. It works. 2) Limitations of toolame encoding: Bitrate Ranges When making a VBR stream, the bitrate is only allowed to vary within set limits: 48kHz Stereo: 112-384kbps Mono: 56-192kbps 44.1kHz & 32kHz Stereo: 192-384kbps Mono: 96-192kbps 24kHz, 22.05kHz & 16kHz Stereo/Mono: 8-160kbps It is expected in VCD and SVCD that sampling rate is 44.1 KHz; it is nice to have variable lower bitrates, so the question is: can we stretch VCD/SVCD standard by using 48kHz dvd standard? Can standalone players handle that? ..Resampling from 44.1KHz to 48kHz is bad quality with standard tools, so I put resampling to 22kHz instead. This is test on 1.5 hour film: with stereo: VBR stats: 8 16 24 32 40 48 56 64 80 96 112 128 144 160 186 0 16 31 138 494 1104 2025 8672 19671 38521 21557 2752 336 Avg slots/frame = 705.675; b/smp = 4.90; bitrate = 108.056 kbps with joint stereo: VBR stats: 8 16 24 32 40 48 56 64 80 96 112 128 144 160 186 0 16 40 153 544 1242 2260 9837 24930 42033 13886 376 0 Avg slots/frame = 681.046; b/smp = 4.73; bitrate = 104.285 kbps The result is very good dispersion (not distortion) of audio bitrate. |
Quote:
However, if you do testing, maybe you can try vrc_eq= option mencoder, that is to specify rate control depends on the source. Quote:
|
Hi,
yes, acknowledged, 2-pass encoding doesn't change much, so one pass can be dumped. I just did a one pass encoding (first one pass audio) of a 90min movie using the mencoder predicted bitrate for a 650MB CD and hit (or should I say missed) the target with a bin file of 742MB. It is more than 50MB short of the CD capacity, so next time, I'll try the 700MB value and keep you informed. VBR Audio encoding directly with mencoder (with lavc=ffmpeg) is not possible at the moment :( Is VBR Audio encoding valid for a DVD ? To meet DVD recommendations, a sample rate of 48kHz is a must, but what about VBR ? Most DVD-Players play (S)VCD with 48kHz audio without any problem and as I sometimes burn those mpegs to DVD, I only encode with 48kHz audio, so that I don't have to reencode audio. BTW: My cheapo DVD-Player also plays (S)VCD and DVD with MP3 (also VBR) Audio, but since I like to encode to be compatible with more than my player, I don't use that. |
"Is Variable Bit Rate allowed in MPEG-1 Audio?
For Layer III, the answer is simply 'yes'. The average bit rate is the one given in the header of a Layer III frame, but as the bits may be distributed over several frames, this effectively implies a variable bit rate. For Layers I and II, according to the standard, it is not mandatory for decoders to support Variable Bit Rate (VBR). However, in practice the majority of the decoders do support Variable Bit Rate, and it is perfectly in line with the standard to specify for a certain application that decoders should support VBR. This is implemented by specifying for each audio frame separately the bit rate at which it is encoded. " -- http://www.chiariglione.org/mpeg/faq...mp1-aud.htm#15 As for DVD Book: http://www.mpeg.org/MPEG/DVD/Book_B/Audio.html it does not say that audio should be constant rate. SVCD specifications explicitely state that audio bitrate can be variable. So, if you see SVCD sticker on a DVD player and it does not play variable rate audio, you can take seller/vendor for legal ride. Of course, before that you have to purchase copy of ISO/IEC 13818-3 (MPEG-2 Audio) ISO/IEC 11172-3 (MPEG-1 Audio) Dolby AC-3 standard from ISO baggers, CHF44 each. As for DVD, you know, you are only allowed to play your region DVDs and pre-approved by Bill Hates. http://www.digitalfaq.com/archives/error.gif |
FYI:
Just terminated an encoding using mencoder predicted 700MB bitrate: a perfect hit with 793MB .bin ! So if you are heading for 1CD-KVCDs perfectly filled, try it this way! (only true for CBR audio...) Greetings, neturmel |
Quote:
Most of audio bitrates will gather around 192 kbps, but depends on audio demand they can go up and down in a band 112-384kbs. http://www.digitalfaq.com/archives/error.gif |
Code:
#!/bin/bash |
Quote:
Actualy I can't find ANY setting wich changes much to the libavcodec quality, even changing max and min bitrates doesn't change that much (unless using very weird values) |
This version of the script uses mencoder 1.0pre3, it is availabe now in source and rpm. Mencoder now is capable to encode mp2 audio.
The script contains part with encoding to variable mp2 with resampling to frequency 48kHz in 112-384kbs band; usually, audio encoded around 160kbs with good audio rate dispersion. Other important changes: vrc_eq=tex:vrc_buf_size=$VBuffer (default parameters maybe not good for xvcd, svcd encoding). mbd=1 (previously mbd=2 produced streams with bitrate spikes, not suitable for multiplexing). You can experiment with vrc_eq, mbd, mbcmp parameters - maybe you can find better. So far, I have achieved 1CD fit for 480*576 mpeg2 of 1h23m movie video quality 4, gop 15, audio 192. Code:
#!/bin/bash |
:bugeyes:
Changes in -lavcopts string and minimum video quality. Depends on video source, the script sometimes failed to produce valid stream, becase of video bitrate control - bitrate going over the top and therefore video/audio failed to multiplex. Code:
#!/bin/bash |
Quote:
|
I use mplex (or tcmplex) to split the result into multiple CDs
and for separate audio encoding with variable audiorate. By the way, do you know any video bitrate viewer in unix? |
Apparently root of previous reported problems was broken audio-video sync in a source avi file.
In my case, the source has 24.999 frame rate instead of standard 25 fps PAL, it is enough to cause the problem of audio/video sync encoding. It appears that use of the same algorithm for decoding and encoding can fix frame rate deviation from ugly encoded source (see idct=0 in -lavdopts and -lavcopts). I still use mplex, because tcmplex produced muted audio with variable audio rate, however tcmplex is more tolerant to input video/audio files. Also, I have restored vqmin=2, added :vmax_b_frames=1:vb_strategy=1 encoding with B frames and :tcplx_mask=0.05:scplx_mask=0.05 quantisation adjustment to complexity (have to be used with :naq). Video buffer is default size, but you can increase it. Code:
#!/bin/bash |
Added expand to scaling, changed order in video processing chain, because frame rate conversion and video filters like denoise should be done before frame resolution scaling.
Video buffer size for encoding and multiplexing is 46Kbytes for XVCD and 112 Kbytes for SVCD (46/112 is approximately 1152/2778 video+audio bitrates for XVCD/SVCD). If you have buffer underruns warnings during multiplexing, you can try to increase video buffer size. Usually you can encode 1h30min movie as SVCD mpeg2 480x576 resolution with variable audio rate around 160kbps and video quality 5 or even 4 to fit single 80min CD. Code:
#!/bin/bash |
I have added audio filter to the script, it is requred if source have audio sample rate different from 44.1kHz.
I use variable audio rate encoding, but keep the section with standard frequency 44.1kHz for purists. To say again, variable audio is completely according to SVCD standard (the only deviation from the standard that I use frequency 48kHz like dvd) and it is playable on every standalone I tried. I have added crop option for sources with ugly black bands; use extend option according to aspect view you choose, for example use 480:360 if aspect ratio is 4/3. Template script below is mpeg1 encoding; with celeron 933mHz and RAM 512MB the speed of encoding is 1x movie time. Code:
#!/bin/bash |
First off, thanks for these excellent scripts.
I have tried out your latest version (posted Dec.29) w/o any success in multiplexing. I get: ++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=41652225 required(DTS)=41609503 ++ WARN: [mplex] Audio c0: buf= 4096 frame=017695 sector=00002742 ++ WARN: [mplex] Video e0: buf= 45075 frame=011555 sector=00025060 **ERROR: [mplex] Too many frame drops -exiting Any ideas as to what causes this or what parameter I can change? I am doing VCD mpeg1 encoding w/ CBR audio of 96 |
I using that script but audio have delay ....
U no have these problem ? |
Yes, I have had a problem with video and audio out of sync (slightly), but since the last verson of the script with "-srate 44100" and "-af resample=44100" the problem is gone.
If you read mencoder manpage, it is saying the -srate option adjusts video frame rates according to audio frequency. In all my cases video and audio out of sync was caused the the source (avi file) had a frame rate slightly diffrent from the standard, for example 24.999 fps instead of 25 fps. As result, I think, video got out of sync after splitting mpg file into video and audio and then re-multiplexing. If you do only constant audio bitrate it is not necessary to split video and audio, resample audio into 48kHz and encode into variable audio bitrate; just take .mpg file produced by mencoder and create .bin and .cue with vcdimager. I think that DTS and SCR delayes gettig out of hand because video buffer (see corresponding varibale in the script) become too small for incoming video packets. There is no standard specs for the size of video buffer, so it can be changed and 46KB and 112KB buffer sizes is far too low then all moder standalones buffer memory. I'll try to keep you posted and if you can run some tests, the help is appreciated. Because current results are promising; I just encoded 2h07m movie into standard SVCD quality 5 with resolution 480x576 and gop 25. and i use varibale audio bitrate with toolame encoder, so audio quality is excellent and if you use mctoolame audio encoder you can put 5.1 surround audio (unfortunately i don't have this audio at home, only left-right and subwoofer). |
russiansexpat, thanks ... can u copy the last script here ?
I am using script mkxvcd.sh you know this ? in your opinion its good ? Thanks again :D |
mkxvcd.sh script is interactive script, and of course it is good - a few people worked it out in kvcd4nix project. It is based on mjpegtools (and optionally transcode). encoder mpeg2enc in fact is origin of tmpgenc (another name tsunami) for windose folks and currently have K-matrix option.
Still it is at least twice slower than mencoder or ffmpeg. I was trying to create a script that it is using just one mencoder/ffmpeg library because the number of option in mencoder is many and allow to tune the result (see ulavcopts options in my script). If you are not interested in VBR audio, you don't have to re-multiplex video/audio and also you can use tcmplex instead of mplex or original mplex from http://www.linuxtv.org/download/dvb/ it multiplexes prefectly, but can't handle vbr audio, only constant bitrate audio. Current verson of my script is below: Code:
#!/bin/bash |
Correct me if I am wrong, but tcmplex can't split the mpg for multiplexing over several CDs, only mplex can do that?
|
Of course, tcmplex also can split mpeg files into multiple CDs.
Look at my modifications of these 2 scripts (please pass respects to original authors): http://dvdripping-guid.berlios.de/fo...?t=157&start=1 they entirely based on mjpegtools and use tcmplex for multiplexing. I fully tested them but then start using K-matrix and mencoder. |
Note, in new version of mplex (1.6.1.92)need remove "-m" in that lines :
SVCD MUXMODE="-f 5 -m 2 -V -b 112" VCD MUXMODE="-f 2 -m 1 -V -b 46" |
This is a release of the script, version 0.2.
I have tested it on many avi files and tv captures. For example, in a last test on tv capture 320*240 wmv the script fitted single 80 min CD with 150 minutes quality=4 of standard vcd mpeg1 at 1.4x speed on celeron 933MHz. It is working with both cbr and vbr mp2 audio; you can take out normalize out of the script and feed toolame from fifo pipe, but I found normalize is significantly improving soundtrack hearing. Compared to the previous version vlelim and vcelim quantisation thresholds have been taken out, and trell quantisation has been added. I put compulsary parameters in capital caps and optional parameters in small cups in editable section; however optional parameters worked well on all sources. Code:
#!/bin/bash |
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.