![]() |
Very nice sripty, well done!
Can I put subtitles in the same directory as the .avi to make mencode add these subtitles to the kvcd/skvcd (hardsubbed) If not is there another way to add subs ? Thanx in advance |
I was not doing subtitles or used this script for dvd authoring.
(Look into 'man mplayer' in OSD/SUB OPTIONS section and vobsubout options of mencoder)? The only thing I remember that video buffer size should be 224Kb (twice the the size of svcd video buffer) and gop should be less or equal 15 for pal and 18 for ntsc. Another way to add subtitles and menu, I guess, can be done by vcdimager .xml descriptors. If you know how to add dvd authoring to the script - do it and let us know. My priority now is to find some gui wrapper for the script, so that you don't have to edit the scrupt everytime before use. Also, it would be helpful to add features like source analysis before encoding; it can be done by mplayer -v -identify options and -cropdetect. |
Sorry but I lack the coding skills to help you out with a GUI wrapper or vcdimager implementation for authoring (haven't used xml yet)
But it would be great to see this script with a usefull GUI to avoid changing settings all the time indeed. One short question: is it possible to use this script for encoding to 2 CD's as well? Imho movies >120 minutes look a lot better when you make it a 2 CD skvcd rip. I hope that's not that hard to ask, And thanx again.. |
The script splits the resulting .mpg .bin .cue files automatically according CDSIZE variable.
That's why mpeg file produced by mencoder has to be de-multiplexed into video and audio and then multiplexed again by external multiplexer (mplex or tcmplex) with usage of CDSIZE break point. (Maybe this can be done by mplayer itself, by counting frames and determing the stream size.) If mpeg produced by mencoder is fit for single CD, you can just pass it to vcdimager to produce .bin and .cue files. (Meanwhile I use separate audio encoding by toolame with variable audio bitrate and normalize sound level, but it is not necessary; i just found that the quality of soundtrack is better with this separate audio encoding). |
What I actually mean is: can I set cdsize to something like CDSIZE=1600 #(2x 795MB to fit on 2 700 MB cdr's) so that it encodes to an mpeg with increased bitrate & quality to fit on 2 cd's.
Or is this script/mencoder limited to these 3 settings only? Code:
#CDSIZE=735 # 74min CDWould it also be possible to use this script in order to try using kdvd templates to create Res : 720x480 rips ? Or doesn't it make sense using this script for this purpose. eg: Code:
ASPECT="1.7777"/me hopes no to bother too much with asking all these questions ;) |
The script does not calculate quality (or video bitrate in earlier versions) for CD size and their numbers, because it is simply not possible to predict the size of resulting mpeg file accurately.
However, it is not a big drama: chose AUDIORATE constant and any constant quality, start the script and watch mencoder output bottom line - it displays estimated completion time, estimated final size and current birates. I recommend to run it at least for 10% of encoding, it displayes in brackets after current fame number. Then you choose quality in command line according desired final size. (For variable audio rate initial encoding is 384Kbs, but resulting variable audio is usually can be around 160Kbs, so you need to do simple math :D) |
can't execute script - russiansexpat
I am visitor from the "linux media" forum and thought I'd get a few ideas from here.
I tried your script but can't get it to work. I left it pretty much alone and only commented and uncommented a few lines. When I do "./[name of script] [file.avi], I get the following message: Usage: $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]" "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED." or something close...I copied this message from the script as it is the closest. I'm away from my linux box now. Here is a copy of the script if you care to look. As I said, I only changed a few "#" to make it work for the file. ------------------------------------------------------------------------------------- #!/bin/bash # # Copyright (C) 2003-2038 russiansexpat # # script: mpeg(1,2,3,4) conversion to (S,X)VCD with quantisation matrix # and auto-splitting into multiple CDs and writing them. # # requires: mencoder mplayer ffmpeg tcmplex vcdimager cdrdao for exe in mencoder mplayer ffmpeg tcmplex vcdimager cdrdao; do if [ -z "`which $exe`" ]; then echo "ERROR: $exe must be in your path $PATH" exit 1 fi done MATRIX="\ 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\ " VBITRATE=1152 # 1 = 1000 bits #---------- below you can edit parameters ---------- SWS=0 # fast bilinear #SWS=2 # bicubic (for upscaling) #SWS=9 # lanczos (quality? slow) VFILTER="denoise3d,eq2," #FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97" FPS=" -ofps 29.97" # NTSC #FPS=" -ofps 25" # PAL #FPS=" -ofps 23.976" # NTSC pulldowned #FPS=",ivtc=1 -ofps 23.976" #FPS=" -ofps 10" # must for variable and progressive fps # for vcd WID=352 HEI=240 #HEI=288 VCODEC=mpeg1video AUDIORATE=128 MUXMODE="-m 1 -F tcmplex.tmp" IMAMODE="-t vcd2" # for svcd #WID=480 #HEI=480 #HEI=576 #VCODEC=mpeg2video #AUDIORATE=224 #MUXMODE="-m s -F tcmplex.tmp" #IMAMODE="-t svcd" LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01" PASS="single" #PASS="1st 2nd" NOTverbose="2> /dev/null" #NOTverbose="&> /dev/null" #CDSIZE=735 # 74min CD CDSIZE=130 # 80min CD #CDSIZE=895 # 90min CD CDOPT="--force --reload --eject" CDDEV="--device 0,0,0" #---------- above you can edit parameters ---------- function usage() { echo echo "Usage: $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]" echo echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED." echo exit 1 } HOWCALLED=`basename $0` [ $# -lt 2 ] && usage case $1 in -*) usage ;; *) NAME=$1 shift 1 ;; esac DIR="`pwd`" FILE=$1 if [ "$1" == "`basename \"$1\"`" ]; then FILE="$DIR/$1" fi shift 1 if [ "$1"x != "x" ]; then VBITRATE=$1 shift 1 fi COMMAND_LINE_MENCODER=$* rm -rf divx2pass.log rm -rf frameno.avi for word in $PASS ; do VIDEO="video.mpg" [ "$word" == "single" ] && pass="" [ "$word" == "1st" ] && pass=":vpass=1" [ "$word" == "1st" ] && VIDEO="/dev/null" [ "$word" == "2nd" ] && pass=":vpass=2" command="mencoder -sws $SWS -vf ${VFILTER}scale=$WID:-3,expand=0:$HEI${FPS} \ -forceidx -of mpeg -nosound \ -ovc lavc -lavcopts vcodec=$VCODEC:$MATRIX:mbd=2:vbitrate=$VBITRATE:vr c_minrate=300:vrc_maxrate=2300:vrc_buf_size=320:ke yint=25${LAVCOPTS}$pass \ $COMMAND_LINE_MENCODER $FILE -o $VIDEO" echo "$command $NOTverbose" eval "$command $NOTverbose" done rm -rf $NAME.mpv eval "mplayer -noframedrop -vc dummy -vo null -dumpvideo -dumpfile $NAME.mpv $VIDEO &> /dev/null &" AUDIO="audio.wav" rm -f $AUDIO mkfifo -m 660 $AUDIO eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -aofile $AUDIO $FILE &> /dev/null &" eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa &" #eval "lame -h --abr $AUDIORATE --resample 44.1 - $NAME.mpa < $AUDIO &" wait rm -f $VIDEO rm -f $AUDIO rm -f $NAME??.mpg echo "maxFileSize = $CDSIZE" > tcmplex.tmp eval "tcmplex $MUXMODE -i $NAME.mpv -p $NAME.mpa -o $NAME.mpg" rm -f tcmplex.tmp for i in $NAME??.mpg; do cue="`basename $i .mpg`.cue" bin="`basename $i .mpg`.bin" rm -f $cue $bin eval "vcdimager $IMAMODE -c $cue -b $bin $i" done echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n" for cue in $NAME??.cue; do bin="`basename $cue .cue`.bin" echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:" read -n 1 null eval "cdrdao write $CDOPT $CDDEV $cue" echo "CD WRITING IS COMPLETED." done exit 0 # last line of this script :idea: :idea: :arrow: :idea: |
Simply your usage was wrong.
Example: ./name_of_the_script result_base file.avi 5 will produce the resulting files with result_base names from source file.avi and quality=5. |
Simply your usage was wrong.
Example: ./name_of_the_script result_base file.avi 5 will produce the resulting files with result_base names from source file.avi and quality=5. |
I think you didn't use the latest version of mencoder and all other required software.
At least I didn't check my version of mplayer before running the script and I got the same output. maybe this'll help. russiansexpat; what will be the difference fo your script when it's build in a programm like avidemux as gui, compared with the kvcd conversion that is already available? is there a difference or is it the same? |
#(rpm -qa | grep mplayer | sort ; rpm -qa | grep mencoder)
mozilla-plugin-mplayer-1.0pre2-2 mplayer-1.0pre3-1 mplayer-codecs-extralite-1.0-1 mplayer-codecs-linux-real-9.0-2 mplayer-codecs-linux-xanim-1.1-1 mplayer-codecs-linux-xanim-3ivx-1.1-1 mplayer-codecs-win32-1.1-1 mplayer-codecs-win32-dmo-9.0-2 mplayer-codecs-win32-indeo-1.1-1 mplayer-codecs-win32-mjpeg2k-1.0-2 mplayer-codecs-win32-qt-6.0-2 mplayer-codecs-win32-qt-extras-1.1-1 mplayer-common-1.0pre3-1 mplayer-font-cp1250-1.1-1 mplayer-font-iso1-1.1-1 mplayer-font-iso2-1.1-1 mplayer-font-iso7-1.1-1 mplayer-font-iso9-1.1-1 mplayer-font-koi8r-1.1-1 mplayer-gui-1.0pre3-1 mplayer-skin-default-1.0-2 mplayer-skin-slim-1.0-2 mplayer-tools-1.0pre3-1 mplayer-vidix-1.0pre3-1 mplayer-vidix-nvidia-1.0pre3-1 mencoder-1.0pre3-1 # I use both mplayer and mencoder version -1.0pre3-1 from rpm binaries for RedHat Linux. It could be a problem with parsing command line if you use other compiled versions, but it is not difficult to figure it out at your end. Check what shell do you use to run the script; it is bash script and also it can be run from shell (bourne shell) but not ksh or csh. Try to run "sh -x scriptname resultname sourcename 6" There is a topic http://www.kvcd.net/forum/viewtopic.php?t=8017 where I am asking for volunteers to develop simple gui for example in tcl/tk for the script. At this moment I don't have enough resources (brains and time) to do it myself. |
**ERROR: [mplex] Too many frame drops -exiting
I'm trying to make a SVCD with the menkoder script posted here, but when mplex runs I get a lot of warnings like this:
++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=25198602 required(DTS)=7261342 ++ WARN: [mplex] Video e0: buf= 112397 frame=001925 sector=00002237 and finally : **ERROR: [mplex] Too many frame drops -exiting and the mpg doesn't get builded. I'm using mplayer and mencoder 1.0pre3 and mplex 1.6.1.92, the version of menkoder is 0.2. Somebody also gets this problem ? |
I have had a long struggle with these errors.
Usually they appear when the source has problems with a frame rate. Try to specify explicitly FRC parameter with -fps and -ofps (you have to know frame rate of your source); if it does not help, then try FRC with filmdint (aka reverse telecine) parameter. Alternatively, chose a constant audio rate and use tcmplex instead of mplex; tcmplex does not produce these kind of errors, but check audio/video sync of the result. |
W/ version 0.2 I have same problem ...
My audio not sync w/ video ..in constant bit rate .. in variable bit rate i have error in mplex ... dpkg -l|egrep mjpe\|toolame\|normali\|mencoder\|mplayer\|ffmp\|v cd |awk '{print $2,"\t"$3}' ffmpeg 0.4.8-sarge0.0 libmjpegtools0 1.6.1.92-0.1 mencoder-k7 1.0-pre3-0.0 mjpegtools 1.6.1.92-0.1 mplayer-fonts 3.3-0.1 mplayer-k7 1.0-pre3-0.0 normalize 0.7.6-3 toolame 02i-2 vcdimager 0.7.14-1 vcdtools 0.4-2 anybody can help-me ? |
I don't have these errors to fatal extent, so I've been able to multiplex video and audio by mplex.
De-multiplexing part of the code is here: Code:
if [ $AUDIORATE != 384 ]; thenwithout de-mux and re-mux. (Unfortunately, then you don't have ability to split the result into multiple CDs, so $MOVIE should be less $CDSIZE to fit single CD). I appreciate your feedback. Thanks |
I have solved my problem :D
problem is FPS .... #FRC="-fps 29.97 -ofps 29.97 -vf telecine,lavcdeint," # example to increase fps #FRC="-fps 29.97 -ofps 29.97 -vf " # NTSC #FRC="-fps 25 -ofps 25 -vf " # PAL #FRC="-fps 23.976 -ofps 23.976 -vf " # NTSC pulldowned FRC="-fps 29.97 -ofps 23.976 -vf filmdint=fast=3," # example to decrease fps #FRC="-vf " # fps not changed only, work w/ this FRC .... russiansexpat |
Quote:
I'm also having difficulties trying to understand why the sound is resampled to 48 kHz. I thought VCD/SVCD is 44.1 kHz, or is the 48 kHz also related to KSVCD? Last one: I just tried to make a very simple GUI, which isn't that hard (glade/python), but I can hardly test it if I can't even encode video myself :-( |
Quote:
Finally, I've used tcmplex with constant audio rate, and it worked ok, with audio/video synced all the movie. Another thing I dont understand of the menkoder script, is why first encode the audio with mencoder, then generate a .wav, and then again encode it with toolame ? Is for something related to the frame rate ? Why not dump the original audio to .wav and then encode with toolame ? Each encode looses quality. Regards |
If your source is avi file, then it has header and this header can be wrong
(and real frame rate = number_of_frames/movie_time can be different) because it was encoded with corrupted encoder. avi files are not original sources - original sources are mpeg or analog video. transcode has tools to analyze source and fix avi header: tcprobe, tcscan and avifix, but transcode itself is very-very slow encoder. Try FRC="-fps 25 -ofps 25 -vf filmdint=fast=3," it will de-interlace the source and do frame rate conversion regardless. 48 KHz frequency aduio was discussed earlier - it is a limitation of mp2 variable rate encoding, see http://mikecheng.d2.net.au/layer2/vbr.html You can have variable audiorate encoding in 44.1KHz and stereo 192-384kbps bitrate range. Standalone DVD players accept 48KHz and all standalones I've tried play variable mp2 also, so I chose 48KHz because of wider bitrate band 112-384kbps. Quote:
If you dump .wav from the source, and encode video separately, it is another risk of adio/video being not in sync. Maybe it is a time to sipmplify the script (as mentioned already) - not de-mux and then re-mux audio and video, but instead just pass $MOVIE result file from mencoder straight to vcdimager and use only fixed audiorate. Mpeg files can be splitted by mpgtx tool according to $CDSIZE, see http://mpgtx.sourceforge.net/ |
Quote:
Quote:
As I sidenote, I like VBR, so I'd opt to leave it in the script. Not because it sounds better (haven't done any comparison), but because I think the technique is nice... |
I have put
-srate 44100 -af resample=44100 to ensure encoding audio into (S)VCD compliant format, and because source can have audio with any frequency sample rate. My problems with frame rate and audio/video sync resolved after introduction of -srate (it adjusts video frame rate according to audio while encoding, see man mplayer) and -lavdopts idct=0 option. Try to avoid frame rate conversion if possible, with FRC="-vf " # fps not changed (even it is a contradiction with my prevous postings), because for me frame rate in sources was the root of audio/video sync problems. For multichannel audio (5.1) you can use http://mctoolame.sourceforge.net/ or use mecoder audio options for multichannel audio. It uses ffmpeg audio codec for mp2. Again, ensure that you have mplayer and mencoder 1.0pre3 - it was audio/video sync bug in previous versions, reported in a mailing list. |
Quote:
Quote:
Quote:
Quote:
PS: Even though it seems that every answer you give results in two more questions from me, I appreciate your script, time and answers! |
http://www.digitalfaq.com/archives/error.gif
important Enable Real Time Clock (RTC) for mplayer. It is the first thing I did before start developing the script, and this affects the whole syncing in mplayer/mencoder. The description is here: http://www.mplayerhq.hu/DOCS/HTML/en/rtc.html |
Quote:
in mencoder line, according to the case fixed or variable audiorate. Somehere in the coder before mencoder line should be 'case' or 'if' statement to set $SRATE variable and in menoder line it should be: -srate $SRATE -af resample=$SRATE I just was trying to keep the script as simple as possible, and double resampling did not reduce sound quality in my results. |
russiansexpat , can I modify u script to suport subtitles and post here ?
|
Quote:
Who is interested in developing GUI for the script, join the topic: http://www.kvcd.net/forum/viewtopic.php?t=8017 |
russiansexpat, if I set audio bitrate in 128 I need use mplex ?
script with subtitle suport is done I need more test to post . |
If you chose to use fixed audiorate only,
you can use tcmplex from transcode or dvb-mplex from libdvb http://www.metzlerbros.org/dvb/libdvb-0.5.3.tar.gz they are less sensitive to sync errors, but they are unable to multiplex with variable audiorate (I've tested them both). Alternatively (as mentioned before) don't de-multiplex and re-multiplex at all, just pass $MOVIE mpeg file from mencoder line to vcdimager (I've not tested it myself, but developers say it suppose to be working). |
That work 100% for my ....
I use file generated by mencoder to vcdimager and this work ... god bye mplex errors :D :wink: |
I'm using constant audio rate and tcmplex, or directly the output from mencoder and it works ok to create VCDs.
Now my problem is that I cant fit more than 150 minutes of video at VCD resolution (352x288 at 25 fps) at quality 4 or 5. All kind of video compress the same ? I'm using a 640x480 high bitrate tv capture from satellite, no transmision noise, and its a mix of animation and real footage. |
So, if you use fixed audio rate only, there is no need for (de)multiplexing at all.
You can use http://mpgtx.sourceforge.net/ for splitting $MOVIE mpeg file before vcdimger according to desired size or time. In case of SVCD it is required, because vcdimger has a limit of 100min for one SVCD track, but you can have multiple tracks (mpeg files) on a single CD. Thanks everybody for feedbacks and continue publish your results and modified scripts, especially if you added interactive or simplified feautures to the script. |
Quote:
|
This version of menkoder suport subtiles you need have video and subtitle with a same name.
This suport only .sub and .srt I copy tetra script subtitle parts and add suport to more video types (ogm wma) and make changes example : myvideo.avi - myvideo.srt Code:
./menkoder myvcd myvideo.avi 4Code:
#!/bin/bash |
Lots of skipped frames while encoding
Thanks for posting this wonderful script. I have converted an AVI to MPEG1 but when I did so there were a lot of skipped frames when encoding:
Code:
...Is there any way to overcome the skipping? I have seen this for every AVI I have thus far encoded, except for one which had the occasional (two or three times per minute) duplicate frame. FYI, I am using the defaults and have encoded with quality betweeo 4 and 8. thanks in advance, |
I have same problem ... i solved it changing FRC ... try all parameters ...
frame skip is nota problem is a frame rate .. example have films with 29 fps .. u convert to 25 fps ... 4 frames per seconds is been skipped :D I think it russianexplat can solve that question :D |
Thanks otzi. I switched from the default first options (-fps 29.97 -ofps 29.97 -vf telecine,lavcdeint,) to the second set (-fps 29.97 -ofps 29.97 -vf) and now only see a few skipped frames per AVI.
|
Some mpeg4 encoders produce broken or duplicated frames in AVI source, so if a few frames are skipped - it is normal.
If frames skipping is consistent, it means that you need to choose FRC (frame rate conversion) appropriate to your source. For example, if you have NTSC source and try to encode it to PAL with -fps 25 -ofps 25 without filmdeint or telecine, frames will be skipped. Another example is wmv microsoft source with variable (1000fps) frame rate; in this case you have to use FRC -fps and -ofps to specify resulting frame rate. |
Now I'm having problems creating a VCD image using vcdimager. Note that I am not demuxing then muxing the stream, so that may be a problem:
Code:
INFO: scanning mpeg sequence item #0 for scanpoints...I haven't tried to burn the resulting image as I am SSHing from home. |
These are not errors, only warnings.
Image should be ok; let us know otherwise. |
I have menkoded a couple AVIs using my new FRC settings. Both AVIs gave me many "Duplicate frame" errors when mencoding. The resulting video still looks good, but the audio drifts significantly behind the video. Towards the beginning the audio is a few seconds behind, which quickly turns into minutes.
Is this a case of mencoder dropping video frames but not adjusting the audio to compensate? I am going to play a little with the FRC settings to see if that will change anything. |
Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.