View Full Version : Audio delay
Swan
11th June 2003, 00:02
I hope this isn't a stupid question.
I want to make a 2-CD SVCD backup of one of my DVDs. I am used to encoding things I've captured from TV, but not backing up material from a DVD.
Downloaded Dvd2SVCD and was utterly confused. :)
Instead I found it easier to write a simple Avisynth script where I load the d2v project, resize the video, etc. I have "manually" (using Azid) converted the Ac3 audio to wav and then to mp2 with TooLame. So I'm all set.
But.. After encoding the video in CCE, how and with what software do I mux the mp2 audio and the SVCD-compliant Mpeg-2 video file together, with the delay (as reported by DVD2avi) intact?
My file, for example, has an audio delay of 7 milliseconds (movie_AC3_T02_3_2ch_448Kbps_DELAY_7ms.mp2).
wmansir
11th June 2003, 03:03
Your best bet would be to re-encode your audio with Besweet (using the GUI) and include the delay there.
BBmpeg can change the A/V offsets while muxing, but I find it can cause corruption in the stream. So it's best to just adjust the audio while encoding and then keep the default stream offsets.
But unless your a perfectionist you shouldn't even bother for 7ms. Think about it, at 29.97fps were talking about ~33ms per frame, so a 7ms difference isn't going to be perceptible anyway.
Swan
11th June 2003, 08:32
Originally posted by wmansir
Your best bet would be to re-encode your audio with Besweet (using the GUI) and include the delay there.
Thank you, wmansir.
Reencode the Ac3 to wav then to mp2? If I input the delay value in Beesweet, does Besweet then "eliminate" the offset? How?
BBmpeg can change the A/V offsets while muxing, but I find it can cause corruption in the stream. So it's best to just adjust the audio while encoding and then keep the default stream offsets.
OK. But if I wanted to test it, how would I do it in BBMpeg?
But unless your a perfectionist you shouldn't even bother for 7ms.
He, he. Yes. But the next time, it'll be -66 ms och 88 ms or something and that much is audible. I'd like to learn how to do it.;)
Also, what is the purpose of cropping the black bars on, say, a letterboxed video, then adding black bars and making some sort of "overscan adjustment" as I've seen in DVD2SVCD?
Why not leave the black bars that are already present on the video, why crop them and add new ones?
wmansir
11th June 2003, 09:36
1. Yes, BeSweet will eliminate the offset by either cutting or adding to the beginning of the track. And Besweet can convert/re-encode from just about anything to anything so you can go from AC3 directly to mp2 if you want. The Gui makes it simple, if your using DVD2AVI you just check the appropriate box and it will read the delay right from the file name.
2. For BBmpeg first read Doom9's Guide (http://www.doom9.org/mpg/bbmpeg.htm) for muxing. To adjust for delays you just click on the "Program Stream Settings" tab and at the bottom there are several fields for "Startup Delays(ms)" which have a default value of 180ms for Video, Audio1 and Audio2. To adjust for you subtract you delay from the Audio startup delay for that track. So if Audio1 has a delay of 7ms you would change it's startup to 173ms.
But as I stated before I have had problems with this method causing corruption in the stream. At first I thought it was burning errors, but after some testing I tracked it down to using this method. Since I switched to using BeSweet to adjust the delay I haven't encountered any problems.
3. Well cropping and letterboxing does 3 things.
First, it's faster. Basically the speed comes from reducing the size of the resize function input. Instead of wasting CPU time resizing black space you just cut it and add it back later. As a benfical side effect you can be sure that your black space is "clean" from noise, which while usually not a problem for DVD can be an issue for TV caps or other analog captures. Even a digital picture can have compression artifacts and noise in the black space. So by removing it you not only make it look better, but it will compress better.
Second, it allows you to control where your letterbox line is. The encoder can waste a lot of bits keeping a clean letterbox line if it doesn't lie on a macroblock boundary (a block of 16x16 pixels), so by cropping and reboxing you can be sure that at least one of them does (both if you get lucky or don't mind fudging the aspect ratio a bit).
And third, you can adjust for overscan if you want. Overscan is something that most TVs do, which is cut off some of the picture around the edges. If you think of your TV screen as a window in a stencil, the TV is painting a picture slightly bigger than the window, so the overscan is the part that never makes it thru the window. In order to compensate for this some programs allow you to add a black boarder around the image so you are sure to see the entire frame. The tradeoff is that the image size is reduced a little bit.
Personally I don't adjust for overscan because 1. I have a small TV and really don't need the picture any smaller and 2. a lot of times I watch my SVCDs on my computer, which doesn't overscan.
Swan
11th June 2003, 10:28
wmansir, thank you for taking the time to reply in such detail.
1. I will use Besweet and let it add or subtract as you describe. Great info, thank you! I assume this also could be done in an audio editor, like SoundForge or Wavelab?
2. I read the guide before (Doom9 is unaccessible right now for some reason) and didn't find a clear answer. Now I got one from you. Why is the default 180 in BBmpeg, by the way?
I trust you on the problem, though. Maybe BBmpeg doesn't add or subtract in the audio file as it should or something. In the past, I've just made an Avisynth script, with the audio delay in the script and fed it to TMPGEnc. That has worked for me. But now that I want to try CCE, and it doesn't have a good reputation on the audio encoding part, I figured I needed a different solution.
3. Overscan is important to me. I always watch on a TV, never on the computer monitor. I want the DVD backup to look exactly (or at least as close as possible) as the DVD (certainly don't want important content ending up in the overscan area or see more than I would if I watched the DVD). This has never been a problem when using TMPGEnc.
I want the title safe area and action safe area on my SVCD to be the same as on the DVD.
How do I make sure nothing ends up outside these areas when cropping and adding black bars? Or that I see more than I would if I popped in the DVD and watched it?
And how do I make sure the letterbox line lands on a macroblock boundary? I don't want to mess with the AR. :)
All of this goes into the Avisynth script that I give to CCE, right?
Resizing, cropping, letterboxing?
Would you share one of your avs-scripts for a letterboxed DVD backup (not an anamorphic backup, but a "widescreen DVD" which already has black borders added on the DVD), so I can see how an expert does it?
I fully understand I won't be able to use it as is, since not all DVDs are created alike, I just need to understand the letterboxing and cropping better.
wmansir
11th June 2003, 13:27
1. I'm sure any audio editing program could do, after all it's just cutting or appending silence.
2. I don't know why the default is 180.
3. If you want your picture to look just like the DVD just don't crop from the sides of the video, even if there are black bars there. If your source is anamorphic or letterboxed you can still crop the top and bottom. However, if your DVD doesn't take overscan into account, then neither will your SVCD. So you could still "lose" part of the picture, but you would when watching the DVD on your TV also.
4. As for creating scripts it's actually very easy if you use Gordian Knot. You basiclly open your .d2v file and then use the gui and preview window to adjust the crop lines, select anamorphic or non-anamorphic, the select your script options (resize method, noise reduction, de-intelace, ect) and save your .avs file. It even has a preset for SVCD resize so it does all the calculations for you.
Here's a peice of a script I used:
LoadPlugin("C:\easyenc\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("C:\easyenc\GORDIA~1\SimpleResize.dll")
#
# SOURCE
mpeg2source("E:\Rules\rules.d2v").addaudio()
#
crop(0,62,720,270)
#
SimpleResize(480,270)
#
AddBorders(0,98,0,112)
#
I removed a lot of lines that are commented out from the regular Gnot output to save space. I also added the .addaudio() part, but read the CCE FAQ in this forum if you want to know why that is.
Lining up the macroblocks is easy, all you have to do is make sure one of the values in the last line (addborders) is divisible by 16. Gnot divides the black space equally so before I edited this script the last line was:
AddBorders(0,105,0,105)
The values are (Left, Top, Right, Bottom) so by making it (0,98,0,112) the bottom is now aligned with a macroblock boundry. If I wanted to mess with the AR I could use (0,96,0,112) and both would be aligned but the AR would be off by ~1%.
This does cause the picture to be slightly off the horizontal center line sometimes, but I don't find it distracting.
If you want to know the entire process I use you can read my post in this thread:
http://forum.doom9.org/showthread.php?s=&threadid=31028
I've actually changed things a little since then, but for the most part it's the same process. It's a lot more work than DVD2SVCD but I like the results.
Swan
11th June 2003, 14:16
Thanks for putting me on the right track!
I like to know how to do something manually, before using a tool like DVD2SVCD. It looks great and all, but I always wanna know *why* I do a thing before I do it and if the whole thing is automated...
It's pretty clear you feel the same way.
I've read the other thread and it's also packed with good info.
I am familiar with GordianKnot. I'll let the resizing and letterboxing sink in (I have many letterboxed DVDs) and start to encode and see where it all takes me.:)
You don't use the SVCD preset in CCE, do you?
It looks to me as if selecting that prevents multiple-passes.
And I want at least 2 passes. :-)
And, don't I need to mux the audio and video with BBMpeg because CCE uses the wrong pack size (2,048, which is for DVD, but not SVCD)?
Will muxing in TMPGEnc work? I seem to recall that I did that once (muxed a CCE encoded SVCD video file with an mp2 audio file in TMPGEnc) and that the result was that audio went out of sync when I FF:ed or RW:ed the SVCD. Muxing with BBmpeg as an SVCD (and setting force mux rate to 0) solved that one.
When you don't use Force Film in DVd2avi, do you use the IVTC "Telecide()" function of decomb in Avisynth?
And then add pulldown flags with pulldown.exe or dopulldown, etc?
wmansir
11th June 2003, 15:34
Originally posted by Swan
You don't use the SVCD preset in CCE, do you?
It looks to me as if selecting that prevents multiple-passes.
And I want at least 2 passes. :-)
I don't use the SVCD preset, usually I just use multi-pass.
And, don't I need to mux the audio and video with BBMpeg because CCE uses the wrong pack size (2,048, which is for DVD, but not SVCD)?
Will muxing in TMPGEnc work? I seem to recall that I did that once (muxed a CCE encoded SVCD video file with an mp2 audio file in TMPGEnc) and that the result was that audio went out of sync when I FF:ed or RW:ed the SVCD. Muxing with BBmpeg as an SVCD (and setting force mux rate to 0) solved that one.
I've never encountered that problem (re:losing sync) when muxing with TMPEGenc. In fact I have switched to using TMPGenc to mux all the time because it results in a smaller file, which allows me to bump up the bitrate a bit.
I've never used CCE to encode the audio along with the video because it used to be buggy and BeSweet (or before that Azid+TooLame) was generally regarded to have higher quality.
When you don't use Force Film in DVd2avi, do you use the IVTC "Telecide()" function of decomb in Avisynth?
And then add pulldown flags with pulldown.exe or dopulldown, etc? I almost always use Decomb (in fact I removed it from that script above to simplify the example) except on the rare DVD that is 100% film. But weather you use FF or Decomb you will need to use pulldown. the only case where you don't need pulldown (with NTSC)is for interlaced material (encoded @29.97fps) or if you use CCE pulldown detection on hybrid material because it adds the pulldown flags where they are needed.
Swan
12th June 2003, 00:50
wmansir, thanks.
Is there an AC3 to Wav, using Beesweet, conversion guide on Doom9?
I can't find anything. Downloaded the latest Besweet gui and azidts too.
I understand that I need to turn on:
Azid = use AC3 decoder
SSRC = Downconvert Sample Rate
Output = wave stereo
and there is a checkbox (DVD2avi) which reads the delay in the Ac3 file's name (as DVD2Avi named it). Neat!
Should I check "Boost (Compress Dynamic Range)"?
My guess is no, but I would like to hear it from you.;)
About the aspect ratio and macroblock optimizations: it's best to use FitCD or Fit2Disk (http://shh.dvdboard.de/public_html/) for optimal resizing. It gets even easier when you use my AutoFitCD plugin for DVD2SVCD (see sig), and be it only to get the AVISynth script and then use it in your manual procedure.
wmansir
12th June 2003, 10:16
@Swan
I don't think there is a guide, but it's very simple. I think you have everything down. I think Boost is better used on non-ac3 sources, since if you want to change the dynamic range for ac3 you have some control on the azid section (light, normal, heavy). If you need more control than that, or your source isn't ac3, Boost should do the job, but I have never used it.
@RB
When I last used FitCD it was missing alot of the ease of use functions that make Gnot great, like the interactive preview pane for croping and support for basic filters for Avisynth creation like Decomb IVTC, SimpleResize, VobSub, ect. However, based on your recommendation I'll give it another look.
Swan
16th June 2003, 14:33
wmansir, I ran into some surprising problems with the DVD backup (field order change in the middle of a scene), so today was the first day I got around to working on the audio.:)
I now noticed that I need to set up Acid correctly too (in Beesweet).
What switches do you normally use in the Acid 1 configuration?
How does this look:
-s surround -c normal -L -3db --maximize ?
I notice that DVD2SVCD sets it up like this:
-s surround -c normal -g max ) -L -3db
In Beesweet I used this:
( -d -66 ) -ssrc( --rate 44.1 )
(the ac3 has a delay of -66 ms and I want to downsample from 48.000 Hz to 44.100 Hz.
/Swan
wmansir
16th June 2003, 16:18
Those look fine, that's what I normally use.
(--Maximize) in Azid is the same as (-g max) in besweet, so your settings and DVD2SVCD's are actually the same thing.
For some reason the Besweet preset DSPguru_MP2_for_SVCD uses Light compression in Azid, but I usually use Normal.
EDIT: Oh, I forget that you can actually use (-s surround2), which will use Dolby Pro Logic II encoding. It's backwards compatible with DPL I, and will give better sound if you have a DPL II decoder, so there is no reason not to use it.
Swan
16th June 2003, 19:24
Oh, I forget that you can actually use (-s surround2), which will use Dolby Pro Logic II encoding. It's backwards compatible with DPL I, and will give better sound if you have a DPL II decoder, so there is no reason not to use it.
I bet this is a dumb question, but does this matter? I am making an SVCD with Mpeg Layer 2 stereo audio. Can an Mpeg Layer II file be surround encoded? Man, have I got a lot to learn. :D
I usually hang out in the capturing forum, and encode stuff I've captured from DVB is no problem for me.
But I have made very few DVD backups, I must admit.
With your help, I have now got a method.
Rip the DVD.
Create a DVD2Avi project.
Convert the AC3 to wav with Azid and downsampling from 48 kHz to 44.1 kHz with SSRC, letting Besweet remove the delay.
Writing an Avisynth script, which loads the wav and the D2v project
and includes resizing, and trimming the video in 2 parts, suitable for CD 1 and CD 2.
Encode this using CCE 4-pass VBR
Extract audio from the avs using VirtualDub and encode audio to Mp2 (224 kbps) with TooLame
Mux with BBMpeg's SVCD preset
I am interested to learn how you add 2 seconds of blank video at the end. That's an ingenious solution.
One of my DVD players also cuts off 2 seconds before the video ends and when encoding my own stuff, I've solved it by appending a 2 minute black video.
Now all I need is a good bitrate calc. Tested BitRateCalc (freeware from http://www.tomzavodny.cz/index_en.php?) it suggested a bitrate of 2101 kbps for the video which was too high, obviously, since my file became 40 Mb oversized when muxed. Strangely enough, TMPGEnc, when using the wizard gave me the same bitrate suggestion (approx), which was 2100 average and 2520 max, audio at 224 kbps.
The video on CD 1 is around 47 minutes long, 84467 frames.
I plan to keep the max at 2450 kbps for the video and 224 kbps for the audio, then I know all of my players can handle it (the Samsung I have is very picky with bitrates).
Have you got any suggestions on a suitable bitrate calculator?
Originally posted by Swan
Have you got any suggestions on a suitable bitrate calculator?
FitCD (http://shh.dvdboard.de/)
wmansir
16th June 2003, 21:01
1. If you use a high enough bitrate you can capture the DPL (I and II) effect. If you do a search for "surround2 SVCD" there is thread where people discuss it and report it actually sounds pretty good. Just be sure to use STEREO and not Joint Stereo, which can ruin the DPL encoding.
2. Once you decide to encode your video AFTER cutting it up with AviSynth you can do a whole bunch of cool things to make your SVCDs better. Not only can you add a few seconds of blank video, but you can fade in and out (video and audio) which really gives it a professional feel.
Here's a sample from my latest encode:
#
LoadPlugin("C:\easyenc\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("C:\easyenc\GORDIA~1\decomb.dll")
LoadPlugin("C:\easyenc\GORDIA~1\SimpleResize.dll")
#
# SOURCE
#mpeg2source("F:\christ\christ.d2v").addaudio()
Audiodub(mpeg2source("F:\christ\christ.d2v"),wavsource("e:\christ\whole.wav"))
#
Telecide().Decimate(5)
#
crop(2,6,716,464)
#
SimpleResize(480,350)
#
AddBorders(0,64,0,66)
#
#0,77423).fadeout(30)
#
#77424,155915).fadein(36).fadeout(24)
#
#155916,0).fadein(36)
#
Temp=Trim(0,77423).fadeout(30)
Temp+Temp.blackness(150)
Those last two lines trim the video, fadeout the last 30 frames, then appends 150 blank frames to the end.
The script for CD2 is almost the same, except the last the last two lines are:
Temp=Trim(77424,155915).fadein(36).fadeout(24)
Temp.blackness(47)+Temp+Temp.blackness(150)
This: Trims, Fadein beginning, fadeout end, appends 48 frames to beginning, appends 150 frames to end. There's no real need to add a few seconds to the beginning, I just think it looks better combined with the fadein. (I know it says 47, but the fadein function adds 1 blank frame to the beginning of the video so the total is 48)
A couple of things to note about the amount of blank frames to add. It seems the amount of video cut off isn't based on TIME but on BITS, so if you have a low bitrate section (like blank video) at the end more than 2 seconds will be cut off, that's why I add 150 frames. At least that's the way it works on my DVD player.
3. I use DVDRhelp.com's java based calculator:
http://www.dvdrhelp.com/calc.htm
You can download it onto your harddrive and then bookmark it locally(or if you trust your internet connection, and DVDRhelp.com's server, you can just book mark the page). I'm actually using an older version that's a bit simpler. After you fill out all your settings go into advanced mode, if your muxing with BBmpeg you can set "other ISO files" to 3, if your using TMPGenc you can set it to -6.
This calc is pretty reliable since you can use the ISO files setting to fine tune for extra MB you might add (subtitles, Menus, ect).
I checked out the program you linked at it seemed pretty good, I don't know why your video would be so oversized. (my calc gave a bitrate of 2085 compared to it's 2101, but that difference should not cause a 40MB increase, maybe 10 max.)
4. Just a couple of quick notes on your method.
First, if you look at my sample script above you will see two lines in the SOURCE section (one is commented out). The first is just the video, the second (AudioDub(..)) is with the audio too. I only use the audiodub line when extracting the audio because it slows down encoding since it has to read the audio track. By uncommenting the first line and commenting out the second you can remove the audio track, which CCE doesn't touch anyway.
Second, I would recommend you use BeSweet even if your just encoding a .wav to .mp2. Then newest version of BeSweet uses the TooLame DLL, so you get the same quality, but BeSweet is more stable. Several times I've had TooLame freeze in the middle of an encode. Perhaps it was just my system though.
Swan
16th June 2003, 21:40
Fit CD gives me an even higher bitrate suggestion than the bitrate calc I used, which suggested 2101 :)
Average: 2107
Min: 1149
Max: 2521
I don't want more than 2450 as max, because of my Samsung player.
Will using a lower max bitrate affect the final file size?
Or just the quality, as it's a bit lower than the normal (approx 2520)?
I'll be using VCDEasy to set chapters, and create the .bin and .cue file. Which software in the drop-down box for authoring is best suited for VCDeasy? The one I select there affects the amount of blocks on the final image.
don't know why your video would be so oversized. (my calc gave a bitrate of 2085 compared to it's 2101, but that difference should not cause a 40MB increase, maybe 10 max.)
Odd! This is what I set it to:
47 minutes, SVCD/XVCD, CD-Size Multidisc 80 min 79.57 1 CD, audio bitrate 224 kbps, no 2nd audio.
This gives the suggestion to use 2101 kbps for the video. I am using the latest version of the calc.
I encoded the audio with 224 kbps using Beesweet (TooLame) and the final size of the Mp2 was 75.2 MB.
VCDHelp's calc gives me the suggestion of 2082 kbps. I just finished an encode with average bitrate of 2076 kbps on the video and that muxed with audio became 790 MB. So 2082 sounds like a good value to try.
Not only can you add a few seconds of blank video, but you can fade in and out (video and audio) which really gives it a professional feel.
That's what I normally do with my avi-captures. ;)
I then also have to add one frame's worth of audio delay, as the blank frame the Fade function inserts at the start of the video makes the audio play one frame too early.
I guess you add a delay too, when you insert several blank frames at the start of your encodings?
The Samsung does not cut off anything, but the other one I have (an highly capable Asian player by the name of Euroline) does. :)
In this video I'm working on now, I also added a special function courtesy of Bach to fix the field order change in the middle of the video (it went from top field order to bottom field order, then back to top field order). Avisynth is very powerful.:)
Second, I would recommend you use BeSweet even if your just encoding a .wav to .mp2. Then newest version of BeSweet uses the TooLame DLL
Thank you so much for all the tips. Yes, I used Beesweet's gui to encode with TooLame. Sorry for being unclear about that.
wmansir
16th June 2003, 22:13
VCDeasy is (among other things) a front end for VCDimager, so you can select that.
When I said "my Calc gave 2085" I was refering to the DVDRhelp.com calc, with ISO files set to 3 (instead of the default 5, which is why it doesn't match your 2082). When I pluged 47min into the BitRateCalc I got 2101 just like you.
Fadein doesn't cause sync problems here because it's working on the audio too. If we were to process the audio seperately (or extract it from a .avs file before adding the fadein) it would cause desync.
Swan
16th June 2003, 23:31
wmasnir, now I'll try your tips and will educate myself some more.
Thank you for your patience and for being so helpful.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.