Adding Compressed Music After Black Clip

This forum is for questions and discussion of all the aspects of handling your footage. If you have questions about capturing/ripping footage, AviSynth, or compression/encoding/converting, look here.

Adding Compressed Music After Black Clip

Postby Kero777 » Thu Aug 09, 2007 9:57 pm

My music starts very suddenly in my video and I realized that I should put in two seconds of black before it begins. I know how to do that, but if I export my music separately from Vegas to re-compress it back to an MP3 to put into my video, how would I set up my Avisynth script so that VirtualDubMod knows that the music now shouldn't start until two seconds in? Is it even possible? :? Thanks for reading!
Thanks to: Qyot27, Jaddziadax, BasharOfTheAges, Scintilla, Post-It, Anubisx00, Kariudo and everyone else for helping this Newby out! :P

"Hard work is worthless for those that don't believe in themselves." -Naruto Uzumaki
User avatar
Kero777
 
Joined: 06 May 2007

Postby Scintilla » Thu Aug 09, 2007 10:17 pm

1) If you're muxing in already-encoded MP3 audio with VirtualDubMod, your AVISynth script should have no effect on the audio.

2) Here's one thing you can try:
When you're muxing the MP3 in with VirtualDubMod, go to the Streams list, right-click on the MP3 stream, and select "Interleaving...". Then, under "Audio skew correction", input the desired value for "Delay audio track by" (in milliseconds).

I've never tried this before myself, and I have no idea if it actually works, so what I personally would recommend to do is add the two seconds of silence to your audio file first, BEFORE you compress it to MP3 and mux it (any audio editing program can do this).
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Postby Qyot27 » Fri Aug 10, 2007 12:50 am

Scintilla wrote:1) If you're muxing in already-encoded MP3 audio with VirtualDubMod, your AVISynth script should have no effect on the audio.

2) Here's one thing you can try:
When you're muxing the MP3 in with VirtualDubMod, go to the Streams list, right-click on the MP3 stream, and select "Interleaving...". Then, under "Audio skew correction", input the desired value for "Delay audio track by" (in milliseconds).

I've never tried this before myself, and I have no idea if it actually works, so what I personally would recommend to do is add the two seconds of silence to your audio file first, BEFORE you compress it to MP3 and mux it (any audio editing program can do this).

A third option would be to create a 2-second long silent MP3, then append the two together. MKVMerge will allow you to do this, then it's just a matter of extracting the audio stream back out with MKVExtract. The results may vary, though, and a click may end up being heard where the two come together. It is worth a shot, though.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby GloryQuestor » Fri Aug 10, 2007 6:35 am

Yet another option is that you can export your audio in the editor to WAV format, which will preserve the position of your music in relation to the video and also preserve the frame rate of the exported video.

Then, in VirtualDubMod, add it to the stream list, right-click on it and select Full Processing Mode. Then right-click on it again and select "Compression..." and choose Lame MP3. Then select your quality and bps, and your ready to go. :)
( :| Serious Business Studios :| )
Website Administrator, AnimeMusicVideos.Org
Pittsburgh Japanese Culture Society Events - AMV Department Head
Anime Weekend Atlanta - Video Art Track Department Supervisor
Another Anime Convention - Fan-Works Theater Staff
ImageImage
User avatar
GloryQuestor
Moderation Hero
 
Joined: 13 Apr 2004
Status: Study, Study, Study, Edit, Study, Study...

Postby Kero777 » Fri Aug 10, 2007 11:45 am

Thanks for all of the replies! There are many ways to do this, it seems. I chose Glory Questor's way, but I ran into a huge problem: The audio doesn't play in Winamp Or Windows Media Player. It does play in Windows Media Player CLASSIC and in VLC player though. Is there a reason for this? *Scratches head*

If there is a script I can use to add in audio with Avisynth, then I might be able to do it. Does anyone know how? I know I will get that yucky clicking noise otherwise. :( I'm going to be playing around with this for a bit. Any more replies will help me out a lot. Thanks.
Thanks to: Qyot27, Jaddziadax, BasharOfTheAges, Scintilla, Post-It, Anubisx00, Kariudo and everyone else for helping this Newby out! :P

"Hard work is worthless for those that don't believe in themselves." -Naruto Uzumaki
User avatar
Kero777
 
Joined: 06 May 2007

Postby Qyot27 » Fri Aug 10, 2007 8:14 pm

Kero777 wrote:Thanks for all of the replies! There are many ways to do this, it seems. I chose Glory Questor's way, but I ran into a huge problem: The audio doesn't play in Winamp Or Windows Media Player. It does play in Windows Media Player CLASSIC and in VLC player though. Is there a reason for this? *Scratches head*

If there is a script I can use to add in audio with Avisynth, then I might be able to do it. Does anyone know how? I know I will get that yucky clicking noise otherwise. :( I'm going to be playing around with this for a bit. Any more replies will help me out a lot. Thanks.

What bitrate did you choose? WMP tends to have problems with MP3s sometimes if the bitrate is at or over 224kbps. It might also be because you're encoding it through VDub and it isn't getting muxed in correctly. I always encode the audio stream in a standalone program like dBPowerAMP Music Converter*, oggdropXPd, or iTunes and then mux it in after the video is done encoding in XviD, H.264, or whatever (note: I'm not referring to doing H.264 in VDub - that's a no-no - but just muxing audio and video together after encoding the final).

*Newer versions have crippled MP3 encoding support unless you purchase a license. I never upgraded. You can find other apps to do it that use LAME, though.

AviSynth can't mux compressed audio AFAIK, but it can join two pieces together with the corresponding video files. For example:
Code: Select all
video = BlankClip(60).BilinearResize(848,480)
audio = WAVSource("mute.wav")#.SSRC(48000,fast=false)
AudioDub(video,audio).AssumeFPS(29.97,sync_audio=true).SSRC(48000,fast=false)

This assumes several things (if the real attributes differ change accordingly):
A) the framerate of the main video is at 29.97
B) the target audio sample rate is 48kHz
C) the target video resolution is something other than 640x480 (which is BlankClip's default)
D) any resizing mode will do, since it's just a black screen. I chose Bilinear because it'll be the fastest without going down to a PointResize or something - not that I think that would affect anything either, but I'm just being cautious.
E) the script may throw an error saying the audio can't be resampled. The commented-out additional resampling on the audio line is to correct that if it happens. On a rare occasion you may have to raise that one's new sample rate to something non-standard like 50000 or something.
F) you need to create a silent, stereo file beforehand because apparently, BlankClip only generates mono audio, and there isn't a cut-and-dried solution like a DuplicateChannels plugin to convert from mono to stereo by just copying over the same signal into both left and right channels.

In the main video's script, you can use this to add in the audio:
Code: Select all
video = AVISource("whatever.avi")
audio = WAVSource("whatever.wav")
AudioDub(video,audio)

Trim() in general and framerate adjustments that affect the audio stream (such as the sync_audio=true function of AssumeFPS) should be done on the last line, as I showed in the Blank Clip script. Due to the way this is set up, you'll need to use periods to separate the functions, again as I showed in the earlier script.

Finally, you can do the join operation:
Code: Select all
Import("blankclip.avs") ++ Import("mainvideo.avs")


As I'd mentioned in a previous thread, the ++ in a join operation keeps the audio synced properly. You can open the script in VDubMod, do a Save WAV..., convert it, etc. The reason for doing all those manipulations is because like in VDub, joining two audio streams when attached to video requires everything about the two clips' attributes to be identical. You might also need to add ConvertToYV12() to the BlankClip script as well, but I'm not sure about that.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby Qyot27 » Fri Aug 10, 2007 8:19 pm

Qyot27 wrote:E) the script may throw an error saying the audio can't be resampled. The commented-out additional resampling on the audio line is to correct that if it happens. On a rare occasion you may have to raise that one's new sample rate to something non-standard like 50000 or something.

Gah, I forgot to say that if that indeed happens, you'll need to delete the pound sign, since that keeps the additional resample operation from working.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby Kero777 » Sat Aug 11, 2007 3:29 pm

Qyot27 wrote:
Qyot27 wrote:E) the script may throw an error saying the audio can't be resampled. The commented-out additional resampling on the audio line is to correct that if it happens. On a rare occasion you may have to raise that one's new sample rate to something non-standard like 50000 or something.

Gah, I forgot to say that if that indeed happens, you'll need to delete the pound sign, since that keeps the additional resample operation from working.


Wow, thanks Qyot27! I'm going to have to try that. I really appreciate all that information you gave me. :D
Thanks to: Qyot27, Jaddziadax, BasharOfTheAges, Scintilla, Post-It, Anubisx00, Kariudo and everyone else for helping this Newby out! :P

"Hard work is worthless for those that don't believe in themselves." -Naruto Uzumaki
User avatar
Kero777
 
Joined: 06 May 2007


Return to Footage Help

Who is online

Users browsing this forum: No registered users and 0 guests