X264 video encode: audio going out of sync

The place for all kinds of software for all kinds of operating systems.

Moderator: Dposcorp

X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 2:07 pm

i'm at my wit's end here. long story short: i record gameplay with DXTORY, audio stays in sync throughout. as soon as i do any form of encoding on it, the audio track plays slower than the video. they'll be in sync at the beginning of the video, and gradually go out of sync. by the end of a 1 hour video, audio's delayed by over a second.

i don't know if this is the right place to ask, but hopefully someone will have experience with it here. here are the mediainfo exports:

original:
Code: Select all
General
Complete name                            : D:\record\bf3 2012-07-17 12-44-02-468.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format profile                           : OpenDML
File size                                : 33.9 GiB
Duration                                 : 14mn 32s
Overall bit rate                         : 334 Mbps
Original source form/Distributed by      : Video:YUV420 Audio0:Speakers (ASUS Xonar Essence STX Audio Device) Audio1:Microphone (Display Audio)
Writing application                      : DxtoryCore ver2.0.0.117

Video
ID                                       : 0
Format                                   : xtor
Codec ID                                 : xtor
Duration                                 : 14mn 32s
Bit rate                                 : 331 Mbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 29.970 fps
Bits/(Pixel*Frame)                       : 11.999
Stream size                              : 33.7 GiB (99%)

Audio #1
ID                                       : 1
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 1
Duration                                 : 14mn 32s
Bit rate mode                            : Constant
Bit rate                                 : 1 411.2 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Bit depth                                : 16 bits
Stream size                              : 147 MiB (0%)
Interleave, duration                     : 999 ms (29.95 video frames)

Audio #2
ID                                       : 2
Format                                   : PCM
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : 1
Duration                                 : 14mn 32s
Bit rate mode                            : Constant
Bit rate                                 : 705.6 Kbps
Channel(s)                               : 1 channel
Sampling rate                            : 44.1 KHz
Bit depth                                : 16 bits
Stream size                              : 73.4 MiB (0%)
Interleave, duration                     : 999 ms (29.95 video frames)


encoded:
Code: Select all
General
Complete name                            : C:\Video Output\test.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 224 MiB
Duration                                 : 14mn 32s
Overall bit rate                         : 2 150 Kbps
Movie name                               : test.mp4
Writing application                      : Lavf53.24.0

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 5 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 14mn 32s
Bit rate                                 : 2 048 Kbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.074
Stream size                              : 209 MiB (94%)
Writing library                          : x264 core 120 r2120 0c7dab9
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=9 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=4 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=30 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=2048 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Matrix coefficients                      : SMPTE 240M

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 14mn 32s
Bit rate mode                            : Constant
Bit rate                                 : 128 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Compression mode                         : Lossy
Delay relative to video                  : -2s 2ms
Stream size                              : 13.3 MiB (6%)


relevant computer specs:
i7 2600K at 4.5 GHz
16 GB DDR3-1600 RAM
asus xonar essence STX sound card
GTX 680

thanks in advance.
moriz
Gerbil XP
 
Posts: 446
Joined: Tue Aug 19, 2008 7:35 am

Re: X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 2:12 pm

what are you using the encode it?
if you say sync is fine after capture but fails after encoding, then problem is encoding software?
furesh2o
Gerbil In Training
 
Posts: 4
Joined: Fri Jul 20, 2012 12:21 am

Re: X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 2:31 pm

I'm going to guess that the issue is framerate. Input framerate is probably not a steady 24, 30 or 60 fps. You may have to decimate frames to get it to a steady value. Alternatively, the input file may be at a different framerate than what you are encoding to - this is a surefire way to get audio out of sync.

EDIT: x264 supports variable framerate encoding and playback. Option 2 is to make sure it is enabled and reading the framerate correctly.
Wind, Sand and Stars.
Voldenuit
Minister of Gerbil Affairs
 
Posts: 2454
Joined: Sat Sep 03, 2005 11:10 pm

Re: X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 2:49 pm

furesh2o wrote:what are you using the encode it?
if you say sync is fine after capture but fails after encoding, then problem is encoding software?


encoding is done with avidemux 2.5.6, using MPEG-4 AVC encoder. i usually do edits using Sony Vegas Pro, then frameserve it to avidemux for the final encode. i've also tried using handbrake, MeGUI, and many encoders within Sony Vegas. all of them have the same issue. whatever it is, it isn't JUST the coding software.

Voldenuit wrote:I'm going to guess that the issue is framerate. Input framerate is probably not a steady 24, 30 or 60 fps. You may have to decimate frames to get it to a steady value. Alternatively, the input file may be at a different framerate than what you are encoding to - this is a surefire way to get audio out of sync.

EDIT: x264 supports variable framerate encoding and playback. Option 2 is to make sure it is enabled and reading the framerate correctly.


input framerate is currently set to 29.970 fps. i've tried 30 and 60 fps, all with the same result. the recording media is a 3x RAID0 1TB HDD array. combined with how beefy the rest of my system is, i really doubt recording framerate is an issue. after all, the game itself runs well above 70 FPS all the time. the output framerate is 29.970 as well, as shown in the mediainfo output.

oh yeah, one funny thing: if i use the mkv container with vorbis audio encoder, the sync issue disappears, or nearly disappears. however, youtube doesn't like mkv much.
moriz
Gerbil XP
 
Posts: 446
Joined: Tue Aug 19, 2008 7:35 am

Re: X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 5:04 pm

I use avidemux extensively and i've experienced audio sync issue with it when converting between mp4 and mkv.
I stopped using .mp4 because aac encoder in avidemux introduces brief shrieking noise at the start.
I've been using x264/mp3 in mkv instead to encode videos and i had no problem so far uploading to youtube.
furesh2o
Gerbil In Training
 
Posts: 4
Joined: Fri Jul 20, 2012 12:21 am

Re: X264 video encode: audio going out of sync

Postposted on Sat Jul 21, 2012 5:12 pm

i've tried using the lame (mp3) encoder, and the same desync issue occurs. oh well, maybe i should just use mkv and vorbis from now on. youtube does seem to accept that combination.
moriz
Gerbil XP
 
Posts: 446
Joined: Tue Aug 19, 2008 7:35 am


Return to General Software

Who is online

Users browsing this forum: No registered users and 3 guests

cron