Doom10 Forum: Digital Video Discussion
September 09, 2010, 12:36:45 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Of course it's better, it's one more. Read the rules!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: dealing with VFR and audio sync  (Read 759 times)
mastrboy
Member

Offline Offline

Posts: 8


View Profile
« on: March 11, 2010, 03:55:27 PM »

I have a anime which I'm cutting and re-encoding for a personal project and having some trouble getting the audio to be 100% in sync...

It's an mkv/avc source so i loaded it up in DGAVCIndex and saved a dga file, which reports FPS 20000000 / 659998 (30,30312213067312)  Cry

The avisynth script is as following:
v = AVCSource(file.dga)
a = DirectShowSource(sound.ac3,video=false)
AudioDub(v,a)
Trim(32478,40605)

Audio stuff or where i lack a lot of knowledge, so if anyone could point be in the right direction for keeping the audio in sync i would be really grateful  Wink

Logged
RiCON
Member

Offline Offline

Posts: 66



View Profile
« Reply #1 on: March 11, 2010, 04:32:15 PM »

Try using FFMS2 instead.
Logged
mastrboy
Member

Offline Offline

Posts: 8


View Profile
« Reply #2 on: March 11, 2010, 04:54:29 PM »

that might work, i choose not to use DirectShowSource as it did not have frame-accurate serving, but reading about FFMS2 it seems to provide frame accurate serving "It gives you an easy, convenient way to say "open and decompress this media file for me, I don't care how you do it" and get frame- and sample-accurate access (usually), without having to bother with the sometimes less than straightforward and less than perfectly documented FFmpeg API."

Thanks.. i'll report back about results so it might help others looking for the same Smiley
Logged
mastrboy
Member

Offline Offline

Posts: 8


View Profile
« Reply #3 on: March 11, 2010, 05:45:44 PM »

It seems to have worked with the following avisynth script

a = FFAudioSource("video.mkv")
v = FFVideoSource("video.mkv",fpsnum=30000, fpsden=1001)
AudioDub(v,a)
Trim(32478,40605)

But the manual for FFMS2 is surely lacking, figuring out what fpsnum and fpsden actually does i had to google around as the manual entry was too complex:
"fpsnum & fpsden:  For VFR -> CFR conversion. Setting fpsnum <= 0 means a 1:1 relation with the encoded frames."

Though I'm not sure how much i like one of the known problems listed on FFMS2:
- There will appear decoding artifacts on h264 in transport streams.

But I'm pleased not having to demux the video and audio from the mkv file anymore Cheesy
Logged
RiCON
Member

Offline Offline

Posts: 66



View Profile
« Reply #4 on: March 12, 2010, 01:19:21 AM »

Transport Streams as in MPEG-TS, like used in Blu-rays. In that case, I generally remux the m2ts to mkv using gdsmux or use DSS2 on the m2ts itself.
Logged
qyot27
Isn't it sad?
Member

Offline Offline

Posts: 50



View Profile
« Reply #5 on: March 12, 2010, 05:19:29 PM »

For DirectShowSource, the proper method is to do
DirectShowSource("video.mkv",fps=[fps],convertfps=true)

Where [fps] is the desired framerate.  Usually 23.976 or 29.97.  If 23.976, any higher-fps sections will have frames dropped to maintain 23.976fps, whereas if you use 29.97, the lower-fps parts will have frames duplicated to bring them up to 29.97fps.

This is essentially the same thing you're doing in FFmpegSource2 with the fpsnum and fpsden parameters.  Traditionally, standard framerates are expressed as numerator/denominator, such as 30000/1001 (29.97) or 24000/1001 (23.976) - hence fpsnum (fps numerator) and fpsden (fps denominator).  I've noticed, though, that the latest builds of FFMS2 have been cutting my audio short by anywhere from 1-2 seconds up to 5-6 seconds.  DirectShowSource doesn't do that.  So you could grab the audio from DSS but use FFMS2 to work with the video, making sure the fpsnum and fpsden, fps and convertfps parameters are used with their respective functions.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!