or Connect
AVS › AVS Forum › Gaming & Content Streaming › Networking, Media Servers & Content Streaming › Converting Video Files - Keeping Audio In Sync?
New Posts  All Forums:Forum Nav:

Converting Video Files - Keeping Audio In Sync?

post #1 of 13
Thread Starter 
If I am converting a video file (using any number of suites, currently VirtualDub), what's the best way to keep the audio in sync with the video?
post #2 of 13
Quote:
Originally Posted by IBNobody View Post

If I am converting a video file (using any number of suites, currently VirtualDub), what's the best way to keep the audio in sync with the video?

You need to be WAY more specific. There are so many combinations of source media, codecs, filters, muxers, container formats, etc that it's pretty much impossible to offer a solution that's guaranteed to fix your problem, or even be suitable to the particular conversion you're performing.

Describe the specific problem you're having - tell us everything - and maybe someone can provide a useful response.
post #3 of 13
Thread Starter 
I can elaborate more, but to put it simply, I just don't have the magic touch it takes to get things into sync.

Here's a good example. I have an XviD AVI file that is encoded in AC3. It won't play on my media player. I know that the problem is the audio because I can strip it out and get the video to play. So... I know I need to change the audio.

I've tried Xilisoft Video Converter and, VirtualDub to try and convert the audio to Lame MP3. I've tried some of the PS3/PSP Video 9 suites to convert to MP4. Every time I do anything, I always end up with out of sync audio. Surely there has to be an easy way to fix this, right?
post #4 of 13
The tools you're using are overkill for what you need to do. All you need to do is re-encode the audio and remux with the existing video. I'd use ffmpeg:

ffmpeg -i input_file -vcodec copy -acodec libmp3lame -ab 192k -ac 2 -f avi output_file

I have experienced VirtualDub throwing off audio sync on one particular type of file (Dish Network H.264 fed in through an AviSynth script, using DirectShowSource() and CoreCodec). Feeding that same AviSynth script into ffmpeg maintained audio sync. Go figure.
post #5 of 13
Thread Starter 
Quote:
Originally Posted by jhue View Post

The tools you're using are overkill for what you need to do. All you need to do is re-encode the audio and remux with the existing video. I'd use ffmpeg:

ffmpeg -i input_file -vcodec copy -acodec libmp3lame -ab 192k -ac 2 -f avi output_file

I have experienced VirtualDub throwing off audio sync on one particular type of file (Dish Network H.264 fed in through an AviSynth script, using DirectShowSource() and CoreCodec). Feeding that same AviSynth script into ffmpeg maintained audio sync. Go figure.

Tried that... The video will no longer load up in WM11.

EDIT: Nevermind. My codecs are scrambled. I will reattempt the conversion and report back.
post #6 of 13
Thread Starter 
Ok... Using a build of FFMPEG still results in sync issues, just like everything else I try.

Here is the MediaInfo of the original file.

Code:
General #0
Format                       : AVI
Format/Info                  : Audio Video Interleave
Format/Family                : RIFF
File size                    : 701 MiB
PlayTime                     : 1h 6mn
Bit rate                     : 1473 Kbps
StreamSize/String            : 4.47 MiB
Writing application          : VirtualDubMod 1.5.10.2 (build 2540/release)
Writing library              : VirtualDubMod build 2540/release

Video #0
Codec                        : XviD
Codec/Family                 : MPEG-4V
Codec/Info                   : XviD project
Codec profile                : Streaming Video Profile/Level 1
Codec settings, Packet bitst : No
Codec settings, BVOP         : Yes
Codec settings, QPel         : No
Codec settings, GMC          : 0
Codec settings, Matrix       : Default
PlayTime                     : 1h 6mn
Bit rate                     : 1016 Kbps
Width                        : 592 pixels
Height                       : 320 pixels
Display Aspect ratio         : 1.850
Frame rate                   : 23.976 fps
Resolution                   : 8 bits
Chroma                       : 4:2:0
Interlacement                : Progressive
Bits/(Pixel*Frame)           : 0.224
StreamSize/String            : 483 MiB
Writing library              : XviD 1.1.2
Writing library/Date         : UTC 2006-11-01

Audio #0
Codec                        : AC3
PlayTime                     : 1h 6mn
Bit rate mode                : CBR
Bit rate                     : 448 Kbps
Channel(s)                   : 6 channels
Channel positions            : Front: L C R, Rear: L R, LFE
Sampling rate                : 48.0 KHz
Video0 delay                 : 499ms
StreamSize/String            : 213 MiB
Here is the MediaInfo for the transcoded file with sync issues:

Code:
General #0
Format                       : AVI
Format/Info                  : Audio Video Interleave
Format/Family                : RIFF
File size                    : 581 MiB
PlayTime                     : 1h 6mn
Bit rate                     : 1221 Kbps
StreamSize/String            : 6.05 MiB
Writing application          : Lavf52.13.0

Video #0
Codec                        : XviD
Codec/Family                 : MPEG-4V
Codec/Info                   : XviD project
Codec profile                : Streaming Video Profile/Level 1
Codec settings, Packet bitst : No
Codec settings, BVOP         : Yes
Codec settings, QPel         : No
Codec settings, GMC          : 0
Codec settings, Matrix       : Default
PlayTime                     : 1h 6mn
Bit rate                     : 1016 Kbps
Width                        : 592 pixels
Height                       : 320 pixels
Display Aspect ratio         : 1.850
Frame rate                   : 23.976 fps
Resolution                   : 8 bits
Chroma                       : 4:2:0
Interlacement                : Progressive
Bits/(Pixel*Frame)           : 0.224
StreamSize/String            : 483 MiB
Writing library              : XviD 1.1.2
Writing library/Date         : UTC 2006-11-01

Audio #0
Codec                        : MPEG-1 Audio layer 3
Codec profile                : Joint stereo
PlayTime                     : 1h 6mn
Bit rate mode                : CBR
Bit rate                     : 192 Kbps
Channel(s)                   : 2 channels
Sampling rate                : 48.0 KHz
Resolution                   : 16 bits
StreamSize/String            : 91.3 MiB
Writing library              : LAME3.98 (beta)
post #7 of 13
Thread Starter 
Still no response? Surely, I'm not the only one who has resyncing issues.
post #8 of 13
Looks like your original file has an audio delay set into it:

Video0 delay : 499ms


and your new one doesnt. If your audio is ~1/2 second ahead of the video, and that difference is consistent through the duration, then thats probably your issue.

I dont know how to add in a delay, but its probably easy.
post #9 of 13
If ffpmeg isn't working, maybe try an mencoder based solution. Format Factory is a GUI front end for a well configured mencoder system. However, don't use the newest version (1.65) as it has issues, use 1.55. Just be sure to set the fps to match, and choose a custom configuration in order to set custom resolutions/bitrates.
post #10 of 13
Thread Starter 
Quote:
Originally Posted by capitolm94 View Post

Looks like your original file has an audio delay set into it:

Video0 delay : 499ms


and your new one doesnt. If your audio is ~1/2 second ahead of the video, and that difference is consistent through the duration, then thats probably your issue.

I dont know how to add in a delay, but its probably easy.

That was it... You get the cookie.

But what disturbs me is that this is not always apparent...

Code:
General
Format                           : AVI
Format/Info                      : Audio Video Interleave
File size                        : 579 MiB
Duration                         : 1h 6mn
Overall bit rate                 : 1 217 Kbps
Writing application              : VirtualDubMod 1.5.10.2 (build 2540/release)
Writing library                  : VirtualDub build 30080/release

Video
Format                           : MPEG-4 Visual
Format profile                   : Streaming Video@L1
Format settings, BVOP            : Yes
Format settings, QPel            : No
Format settings, GMC             : No warppoints
Format settings, Matrix          : Default
Codec ID                         : XVID
Codec ID/Hint                    : XviD
Duration                         : 1h 6mn
Bit rate                         : 1 016 Kbps
Width                            : 592 pixels
Height                           : 320 pixels
Display aspect ratio             : 1.850
Frame rate                       : 23.976 fps
Resolution                       : 24 bits
Colorimetry                      : 4:2:0
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.224
Stream size                      : 483 MiB (83%)
Writing library                  : XviD 1.1.2 (UTC 2006-11-01)

Audio
Format                           : MPEG Audio
Format version                   : Version 1
Format profile                   : Layer 3
Codec ID                         : 55
Codec ID/Hint                    : MP3
Duration                         : 1h 6mn
Bit rate mode                    : Constant
Bit rate                         : 192 Kbps
Channel(s)                       : 2 channels
Sampling rate                    : 48.0 KHz
Resolution                       : 16 bits
Stream size                      : 91.3 MiB (16%)
Alignment                        : Split accross interleaves
Interleave, duration             : 42 ms (1.00 video frame)
Interleave, preload duration     : 500 ms
Writing library                  : LAME3.98.2
How did I know that I put a 499ms offset in there? It's not always apparent.

Is there a tool that can tell me how much I need to tweak my audio?
post #11 of 13
If you just need a constant delay, as opposed to sync that varies or grows throughout the file, just use the -itsoffset options (will need -map too).
post #12 of 13
Thread Starter 
Quote:
Originally Posted by jhue View Post

If you just need a constant delay, as opposed to sync that varies or grows throughout the file, just use the -itsoffset options (will need -map too).

I just stuck the value into VD offset field...

But in cases where I have a straight-up offset and Mediainfo does not list a delay, is there a tool that will tell me automatically what the delay is?
post #13 of 13
It probably has something to do with this:

Alignment : Split accross interleaves
Interleave, duration : 42 ms (1.00 video frame)
Interleave, preload duration : 500 ms


but I cant decipher that. Perhaps someone else has more info on that?
New Posts  All Forums:Forum Nav:
  Return Home
AVS › AVS Forum › Gaming & Content Streaming › Networking, Media Servers & Content Streaming › Converting Video Files - Keeping Audio In Sync?