Jump to content
NEW ANNOUNCEMENT - Check Featured Topic! ×
Baal

How to: Synchronize two audio tracks for muxing with audacity

Recommended Posts

The purpose of this tutorial is to answer the question "how do I find the delay?" when you want to mux english audio to a subtitled release, but don't know where to begin.
 
What you need:
 - Audacity (http://audacity.sourceforge.net) with FFmpeg import/export library installed.
 - MKVToolNix (Link)
 - Headphones or speakers.
 
To begin you need to open Audacity and load japanese audio first and then english audio.
 
Image 01:
p6Dx2fY.jpg
 
In this tutorial I'm syncing audio for the first episode of "A Certain Magical Index". With green color I marked japanese audio track (2 channel AAC file). English audio is marked with yellow, its 6 channel audio but I closed other 5 channels because it looks cleaner and I don't need them. Red rectangle on the bottom is where you write/read selection length.
 
To find the delay we need to look for any sounds that are not speech, because japanese and english speech won't overlap and it will look differently in the waveform display*. If you are not sure about your selected sound then just listen to it by selecting a portion of audio and hit spacebar.
 
Image 02:
LrUncEU.jpg
 
When you have found your background sound make a selection between its beginning on japanese and english track. Don't worry about precision.
In this case its 1035 ms. So I must delete 1035 ms from the beginning of the english track. There are multiple ways to do it, but I select the english audio, hit "Home" to go to 00:00:00, type 1035 ms as the length of the selection and delete it with "Del".
 
Image 03:
7rOtU3b.jpg
 
In this image you can see that I found different sound (it can be the same), zoomed in more and selected the difference one more time. It shows us that I deleted 8 ms too much, so I press CTRL+Z to undo the deletion and remove only 1027ms.
 
Image 04:
eyYHd2n.jpg
 
And this is the result, difference between two sounds less than 1ms.
The delay for this english audio track is "-1027ms". FIN.
 
Things that can go wrong:
There is a chance that the audio won't sync if you only delete a portion at the beginning. It might require syncing in a few places like: after the OP, before/after the commercials break, before the ED. In such case there is no other choice than syncing it in audacity (or other app) and exporting.
To make sure that your audio is synced you should simply check the ending in audacity.
 
*The most common visual representation of audio is its waveform display, which is a graph of amplitude (loudness) over time.

Edited by Baal
  • Like 5

Share this post


Link to post
Share on other sites

I'd probably prefix this with [Tutorial]. Basically you add it as a tag, then click the box that says something like 'use first tag as prefix'.

Makes it easily stand out.

*UPDATE*: I did it for you. As you can see:
23ad5ffa0b.png

  • Like 2

Share this post


Link to post
Share on other sites

I'd probably prefix this with [Tutorial]. Basically you add it as a tag, then click the box that says something like 'use first tag as prefix'.

Makes it easily stand out.

*UPDATE*: I did it for you. As you can see:

23ad5ffa0b.png

 

Thanks, didn't think of that.

Share this post


Link to post
Share on other sites

Doing things visually can lead to errors though. No amount of practice can compensate for one entire sense. It's always better to listen to both tracks playing together, removing/adding silence until you can tell no difference between which is playing.

You might want to include how to add the delay to mkvmerge, too. No doubt people will want their hands held for that part too.

Share this post


Link to post
Share on other sites

Doing things visually can lead to errors though. No amount of practice can compensate for one entire sense. It's always better to listen to both tracks playing together, removing/adding silence until you can tell no difference between which is playing.

You might want to include how to add the delay to mkvmerge, too. No doubt people will want their hands held for that part too.

Yea that's how I was doing it when I did my own blue exorcist movie mux. But great tutorial nonetheless. Does anyone know the exact time frame of viz and funi logo opening?

Share this post


Link to post
Share on other sites

Doing things visually can lead to errors though. No amount of practice can compensate for one entire sense. It's always better to listen to both tracks playing together, removing/adding silence until you can tell no difference between which is playing.

 

Since I don't want to argue about it I just removed that suggestion from the tutorial.

 

You might want to include how to add the delay to mkvmerge, too. No doubt people will want their hands held for that part too.

 

I think I will just create tutorial about remuxing single audio releases with english audio. It will include creating signs/songs tracks in Aegisub and chapters.

Share this post


Link to post
Share on other sites

Thanks for the tutorial Baal.


 


As a suggestion, the only extra thing I would add is how to save/export the new audio file with the adjusted delay. Might be obvious to most, but it would be good to have it to avoid changing the quality of the track or other issues.


  • Like 1

Share this post


Link to post
Share on other sites

Alright, so Im trying to sync these 2 tracks - 

 

The original difference between them is 1059ms. Im tying up the OP as it has a definitive start/end point as well as then only having to have one timed subtitle track (kara) as you should. 

f75e8a5710.png


 

Set the difference in mkvmerge (Nouages), applying it to the English track...

d2458b4d39.png


 

 

And here is where it gets funny, open the new "timed" file, and the English track now overshoots the Japanese by 29ms? Why? Does mkvmerge and Audacity interpret times differently? 

d0f1ca80c7.png


 

 


Things I have tried:


• The closest I got was then subtracting the last difference (29ms) from the original difference (1059), giving me a new time of 1030. Which when checked in Audacity gave me an out of sync time of 3ms this time around. Closer at least.


 


• Using the Time Shift Tool to drag the english track and manually time it with the Jap. Both are in perfect sync when played back. Delete the Japanese track, export the Eng (sticking with options that match that tracks properties), open the file, import the new "timed" English track and its out of sync by 25ms -_-


Share this post


Link to post
Share on other sites

Are the sample rates the same for both tracks?

Edit: nvm.

 

Ok.

 

To still answer your question, yes they are. 

 


The other thing I forgot to mention is that I used the same method above to do the first episode, and it synced fine. 

Share this post


Link to post
Share on other sites

Believe it or not, audio files also have frames. It's length depends on number of samples and sampling frequency... bla bla (technical stuff), anyway at 48kHz 1 frame it is 32ms and you can cut your audio files every 32ms. Now, in mkvmerge negative delays dosn't exist, yep. In order to apply negative delay mmg does this:


 


1059/32 = 33,09375


34*32 = 1088


1088-1059 = 29


 


1. Remove from the begginning 1088ms (34 "frames")


2. Delay that audio by 29ms to get desired 1059ms


 


Now, my question is for what reason are you demuxing it after sync'ing?


Share this post


Link to post
Share on other sites

Believe it or not, audio files also have frames. It's length depends on number of samples and sampling frequency... bla bla (technical stuff), anyway at 48kHz 1 frame it is 32ms and you can cut your audio files every 32ms.

That is interesting. Would You mind providing source of this information.

I am asking, because in software I use, 1 frame is ~13.3 ms or 1/75 s. Some sources suggest 1 frame is 1 sample from each channel, so it is getting confusing.

Share this post


Link to post
Share on other sites

 

Believe it or not, audio files also have frames. It's length depends on number of samples and sampling frequency... bla bla (technical stuff), anyway at 48kHz 1 frame it is 32ms and you can cut your audio files every 32ms.

That is interesting. Would You mind providing source of this information.

I am asking, because in software I use, 1 frame is ~13.3 ms or 1/75 s. Some sources suggest 1 frame is 1 sample from each channel, so it is getting confusing.

 

I don't remember where I read about it long ago but here:

http://www.labdv.com/learning/dv_basics/cd_audio_dd_explained-en.html?full-window

You can read that:

 

 

Dolby Laboratories' AC-3 format is the standard generally used on DVD's and can contain up to 6 discrete channels of sound. This format uses audio compression (like MP3) to reduce the data stream size. An AC-3 data stream is composed of a series of fixed-size, independent frames, each representing 1536 PCM samples (each decoded frame produces 1536 samples of uncompressed PCM audio). Therefore, depending on the sampling rate of the encoded audio stream, each frame represents a different running length. A 48kHz AC-3 frame, for example, contains 1536/48000=0.032 seconds of sound.

 

Because I noticed that MK has problem with Index II audio that he got from DVD I knew it was AC3, so I'm sorry for my generalization in previous post.

 

For those that are interested and because AAC is also common in releases 1 frame in most AAC files @48kHz is 1024/48000=0,021333 - ( 21,3 [ms] )

http://wiki.multimedia.cx/?title=Understanding_AAC

https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html

 

EDIT: 'Fixed' equation.

Edited by Baal
  • Like 2

Share this post


Link to post
Share on other sites

Believe it or not, audio files also have frames. It's length depends on number of samples and sampling frequency... bla bla (technical stuff), Now, in mkvmerge negative delays dosn't exist, yep. In order to apply negative delay mmg does this:

 

Ah I see, that would explain why it always "snaps" to the same place when you delay the audio. You also said that negative delays dont exist, but then gave the procedure that mkvmerge uses when you input a negative value, so surely it would work by putting the negative value in from the beginning? (I may have misinterpreted your words thought)

 

I gave your instructions a go, but the English audio had shot forward by that 29ms again... even after delaying it in mmg. 

 

 

For those that are interested and because AAC is also common in releases 1 frame in most AAC files @48kHz is 1024/48000=0,021333 - ( 21,3 [ms] )

http://wiki.multimedia.cx/?title=Understanding_AAC

https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html

 

EDIT: 'Fixed' equation.

 

 

Alright clarification required please: are AC-3 and AAC files the same? Am I to use the 23,3ms instead of 32ms for the calculations? Or was this second equation just for clarification purposes

Share this post


Link to post
Share on other sites

But... The picture clearly shows all tracks as being PCM. Is that what Audacity displays all foreign tracks as?

 

Probably, AC3 and AAC shows as PCM, FLAC shows as 'float'.

 

You also said that negative delays dont exist, but then gave the procedure that mkvmerge uses when you input a negative value, so surely it would work by putting the negative value in from the beginning? (I may have misinterpreted your words thought)

 

What I meant is that whether you input positive or negative delay mkvmerge will always use positive delay in the resulting *.mkv

When you remux with positive value and then demux you get your original file, but if you use negative value then your file is forever lost because mkvmerge subtracted the full number of frames that your codec supports and delayed the difference to fullfill your request. So you always get positive delay in the end and its impossible to reconstruct the original file in the demuxing process.

 

 

are AC-3 and AAC files the same?

 

No.

 

Am I to use the 23,3ms instead of 32ms for the calculations?

 

No, you don't need any calculations except finding the delay in Audacity.

 

Or was this second equation just for clarification purposes

 

Yes.

 

MK, I still don't understand why are you demuxing the resulting audio after delaying it in mkvmerge??? Were you expecting to get the same file that you put there? Or can you hear that its out of sync by 29ms?

Edited by Baal

Share this post


Link to post
Share on other sites

 

What I meant is that whether you input positive or negative delay mkvmerge will always use positive delay in the resulting *.mkv

When you remux with positive value and then demux you get your original file, but if you use negative value then your file is forever lost because mkvmerge subtracted the full number of frames that your codec supports and delayed the difference to fullfill your request. So you always get positive delay in the end and its impossible to reconstruct the original file in the demuxing process.

 

 

Ah ok I see now, yeah that makes sense. Thanks.

 

 

 

No, you don't need any calculations except finding the delay in Audacity.

 

Ok, so the delay was 1059ms originally, I now also understand what you meant by your first calculations. So then Im still not to sure why if mkvmerge gives me my desired 1059ms delay, how come its still out of sync when I recheck it in audacity. As I now understood from what you said, it should be as easy as finding the delay in audacity, inputting it into mmg and re-muxing?

 

 

 

MK, I still don't understand why are you demuxing the resulting audio after delaying it in mkvmerge??? Were you expecting to get the same file that you put there? Or can you here that its out of sync by 29ms?

 

I am not demuxing anything? Just delaying the audio as per this screenshot: http://puu.sh/cWINs/d2458b4d39.png. So the Eng track is muxed into the Jap BD (no timing done - just as it came from the DVD), then I open this new Dual Audio version in Audacity, make a note of the time difference (1059ms), open the Dual Audio version in mkvmerge and "delay" the Eng track by this 1509ms and remux to a new file. Open this V2 in Audacity to check the timing and the Eng track ends up being 29ms too early. 

 

Unfortunately you can hear the delay (sounds like you are listening to it in a big cave when you feed the Eng audio to the right channel and Jap to the left.)

Share this post


Link to post
Share on other sites

Open this V2 in Audacity to check the timing and the Eng track ends up being 29ms too early.

 

 

You need to understand that audacity is audio editing application and it opens audio files as they are stored inside mkv file.

When any other video playback application opens that mkv it means it supports this format and it will correctly read 29ms delay.

 

In your mkv V2 after delaying eng track it is stored as ac3 file with 1088ms cut from the beginning, but also that mkv container stores information for all players that this track needs to start playing after 29ms. It means you get your 1059 delay but only in playback. Opening english dub track in audio editing app will show its missing 1088ms.

Share this post


Link to post
Share on other sites

Oh I see now. So if I wanted to have Audacity read the 2 tracks being "in sync", or the OP's starting at the same time, I would have to add 29ms of silence to the beginning of the Eng track, remux and make sure there is no delay set in mmg? 


 


What was putting me off was the first episode that I did, after syncing the tracks using the same method I mentioned, the 2 tied up perfectly in Audacity ~ timing must have been just right. 


 


Ok, so end result is do everything that I have been doing, but dont worry about the tracks not lining up in Audacity? 


 


Edit: what happens with something like Aegisub then? Does it read the audio track like a video player would? I.e. with the 29ms delay?


Edited by Moodkiller

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.


  • Similar Content

    • By poetictragedy
      Tutorial: Loki Signature


      This thread will outline the method I used to create the Loki signature I'm currently sporting. I'm using Photoshop CS5 on Windows 7. There are probably differences between versions of Photoshop and/or between operating systems. I just don't know what those might be.

      General Setup: The process behind this signature was a little different that what I normally do. Usually, I find a render and make/find an appropriate background. When working with renders of real, live people, it's hard to make or find a background that matches well enough. For this signature, I took a screencap from an Avengers trailer and used that as my base. Here's the image, if anyone would like to follow along.

      Step 1: Open your image. Crop the image to an appropriate signature size; my standard is 500px x 150px. Note: I always name my layers so I know what I'm working on. I strongly recommend this; it makes it easier to keep track of everything.





      Step 2: Add a new Group . I make one group at the top of the layer stack, and put all of my Adjustment layers in it. This way I can easily turn it off and see what the original image looked like, and whether my adjustments made an improvement, or made it worse.

      Step 3: Add Adjustment layers , starting with a Gradient Map. This gives the image the overall color scheme. The one I chose can be found by clicking the gradient drop down box, and there's a little arrow to the right of the drop down menu (marked in red). From the next menu, choose Metals.





      I want a greenish signature because I know the character wears a green costume. Double-click on the gradient drop down box and a new window, called Gradient Editor, should pop up. To change the color of the signature, I'm going to change the dark blue (marked in red, below) to dark green, and the light blue (marked in yellow, below) to light green. Double-click the boxes and a color picker will open. For the dark green I used #0d4e0b, and for the light green I used #e9f5e9.





      I set the Blend mode to Hue, and the Opacity to 70%. The image will now have a green gradient to it. Note: Blend mode and Opacity are things that can be experimented with. I usually cycle through all the options before choosing the one I like the most.





      Step 4: Add a Brightness/Contrast Adjustment layer. The image is very dark, so I set the brightness to 90. I also wanted to give the image a little more contrast, so I set the contrast to 20.





      Step 5: Add a Color Balance Adjustment layer. I don't really have a method for using this; I just slide the bars left and right, and see what looks best. In this case, I used Cyan/Red +4, Magenta/Green -18, and Yellow/Blue -21.





      Step 6: Add a Vibrance Adjustment layer. Once again, there's no real method to this. I slide the bar up or down and see what works. In this case, I used Vibrance +50.





      Step 7: Add a texture above the background layer. I used this texture. Again, I cycled through the blending options, and chose Color Dodge, Opacity 40%. Note: The texture lightened up the image quite a bit. Some of the adjustment layers may need to be readjusted to counteract this.

      I don't know why I didn't screencap this step, whoops. But you can see the effect of the texture in the step 8 picture.

      Step 8: Add a Gradient Fill layer, but DON'T put it in the Group; put it right above the background layer. A menu will pop up; the settings I used were the transparent to black Gradient, Style: Reflected, Angle: 0, Scale: 105%, and Reverse is checked. This serves to black out the sides of the signature a little, bringing the focus to the character.





      Step 9: Add text. The text I used was “You were made to be ruled,” a line spoken one of the movie trailers. I made two text layers, one plain (“You were made to be”), and one a little fancier (“ruled”). For the plain text, I used Times New Roman 15pt, and for the fancy text, I used The King & Queen Font 23pt; the color of both was white. The blending settings for the both text layers used the Outer Glow effect. Right-click on the layer, and select Blending Options. Click Outer Glow to bring up the menu.

      These are the settings I used for the plain text layer:
      Blend Mode: Screen
      Opacity: 45%
      Noise: 0%
      Color: #b95bfb
      Technique: Softer
      Spread: 13%
      Size: 4px
      Range: 70%
      Jitter: 0%

      And this is how the fancy text layer differs:
      Opacity: 100%
      Size: 13%
      Range: 50%

      For the plain text layer, change the opacity to 60%, and the fill to 0%. For the fancy text layer, the opacity is 50%, and the fill is 0%.





      Step 10: Add a border. Create a new layer above the text layers. Press Ctrl+A to select the whole image. Select Edit, then Stroke from the top menu. In the new window, select the width and color. I chose 1px and black. Click OK.





      And voila! This was a more complicated signature, and it was even difficult for me to recreate it. I'm not sure if this is the exact order I did things, but I think it's close. If there's something that doesn't make sense, let me know, and I'll edit this post.
    • By poetictragedy
      TUTORIAL: BACKGROUNDS

      This thread will feature a few tutorials that outline different methods I use to create backgrounds. I'm using Photoshop CS5 on Windows 7. There are probably differences between versions of Photoshop and/or between operating systems. I just don't know what those might be.

      General Setup: These steps can be applied to every signature.
      Step 1: Open a new document. I'm going to use a signature as an example, but it can be any size. The size I'm using is 500px x 150px. I always start with this size, then crop the signature as I see fit. Note: You may have to change the Background Contents to Transparent.





      Step 2: Open your render. This is the render I'm using, but you can use whatever render you want. Copy and paste it into your new document. Resize and place the render where you think it will look best. I usually choose one side or the other, kind of using the “rule of thirds.” Imagine the canvas is divided into thirds, and put the render in the middle of the left or right thirds. Basically, just don't put it right up against the edge of the canvas; give the render a little room to breathe.

      Step 3: Create a new layer by clicking the New Layer icon in the Layers window, or by hitting Ctrl+Shift+N. Drag this layer to the bottom of the stack, so it is under the layer with your render. Note: I try to give the layers relevant names (“background,” “render”), so I can keep track of all the things I'm working on. You can change the name by double clicking on the layer name.





      Background #1: Gradient + Scanlines


      Step 1: Using the eyedropper tool , choose a light and dark color from the render for the background and foreground colors. I chose the dark pink from the robot (whose name escapes me), and the light pink from Lacus's hair. Then use the gradient tool (click and hold the paint bucket icon to find it) to create a gradient on the background layer. Try to follow the lighting/shadowing on the render. In this case, I went from the top left corner to the bottom right corner.





      STOP! If you've never used scanline patterns before, follow this tutorial to make a scanline pattern. However, to get the exact effect in my example, use a 5px x 5px canvas instead of the 3px x 3px suggested.

      Step 2: Create a new layer to be used for the scanline pattern. Use the paint bucket tool, selecting Pattern from the drop-down box near the top of the screen. Select the scanline pattern. Then click on the canvas to apply the pattern. Choose a blending option from the drop down menu in the Layer window and change the opacity to your liking. In this case, I used Soft Light at 20%.





      That's about it for the actual background. The rest was done with brushing, text, and adjustment layers, which will be covered in future tutorials.



      [
      NEXT TUTORIAL]
    • By poetictragedy
      Tutorial: Text



      as requested by ba11ard




      This thread will show the different styles of text I use, and explain why I use them. I guess this could be considered more of an analysis than an actual tutorial.





      Style #1: "Label"



      A lot of times, the text I use is simply my username; this helps users quickly identify that this signature is mine, and prevents others from stealing. This is helpful in competitions, such as the SOTW contests.

      In the above case, the font is small, but still easily readable. Default fonts work well for this purpose; most fancy fonts get more difficult to decipher as they get smaller.

      Also, the opacity is turned down and blending options (such as multiply/screen/overlay) are used, to blend it into the background more. The text should be readable, but not over-powering, as to take away from the focus of the render.

      I FORGOT TO MENTION. The text should be near the render, but not on top of it (in most cases; sometimes it's unavoidable). This gives the signature a focal point. If the text was on one side and the render on another, the eye wouldn't know where to focus.

      Here are more examples of this type of text:


      For this one, I put the text layer underneath the bokeh texture to blend it.






      I don't normally set text on an angle like this (personal preference), but I thought it fit the signature, because there are so many definite lines of motion.




      More text styles coming soon!

×
×
  • Create New...