Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th August 2011, 06:31   #1  |  Link
ben13
Registered User
 
ben13's Avatar
 
Join Date: Sep 2010
Location: IN
Posts: 37
A/V out of sync in VFR encode!!

I was trying to encode a .ts recorded for my own veiwing purpose, I'm tring to make it vfr!
The video seems to be alrite, but the audio has some major delays...
kinda like 10s-15s!
Avs i used:
Quote:
DGDecode_mpeg2source("test.d2v")
assumeTFF()

#PASS 1
#-------------------------------------------
tfm(d2v="test.d2v", output="matches.txt")
tdecimate(mode=4, output="metrics.txt")

#PASS 2
#-------------------------------------------
tfm(d2v="test.d2v", input="matches.txt")
tdecimate(mode=5, hybrid=2, vfrDec=1, input="metrics.txt", tfmIn="matches.txt", mkvOut="mkv-timecodesfile.txt")

#TRIM
#------------------------------------------------------
trim(2487,6611)++trim(8639,26687)++trim(32933,48150)


#resize & denoising
#-------------------
Spline64Resize(1280,720)

#Filtering
------------------------
Filters...

Encoded vfr Video Media info:

Quote:
Encoded file media info
Codec ID/Info : Advanced Video Coding
Duration : 23mn 6s
Bit rate mode : Variable
Bit rate : 1 900 Kbps
Maximum bit rate : 50.0 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 26.969 fps
Minimum frame rate : 17.982 fps
Maximum frame rate : 29.970 fps

Now the problem is...

Quote:
#PASS 2
#-------------------------------------------
tfm(d2v="test.d2v", input="matches.txt")
tdecimate(mode=5, hybrid=2, vfrDec=1, input="metrics.txt", tfmIn="matches.txt", mkvOut="mkv-timecodesfile.txt")

#TRIM
#------------------------------------------------------
trim(2487,6611)++trim(8639,26687)++trim(32933,48150) <----- trimmed by avisynth assuming framerate at 26.96fps

But audio is still at 29.97 fps..

I tried making the audio at 26.96 using behappy n then tried trimming/cutting it, but no use.

Audio Clt file info

Quote:
<?xml version="1.0"?>
<Cuts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Framerate>26.969681769860408</Framerate>
<Style>NO_TRANSITION</Style>
<AllCuts>
<CutSection>
<startFrame>2487</startFrame>
<endFrame>6611</endFrame>
</CutSection>
<CutSection>
<startFrame>8639</startFrame>
<endFrame>26687</endFrame>
</CutSection>
<CutSection>
<startFrame>32933</startFrame>
<endFrame>48150</endFrame>
</CutSection>
</AllCuts>
</Cuts>

So someone can assist me on this?
Thanks you very much!

Last edited by ben13; 5th August 2011 at 19:45.
ben13 is offline   Reply With Quote
Old 5th August 2011, 09:13   #2  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,769
A/V synch for VFR encodes are rather the exception than the rule, irrespective of the codec. All legal sources are CFR, why encode in VFR?
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 5th August 2011, 12:12   #3  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by Ghitulescu View Post
A/V synch for VFR encodes are rather the exception than the rule, irrespective of the codec.
What? If you're doing it right it'll always be in sync. In fact if you have the correct workflow it's HARD to get it to go out of sync.

Quote:
Originally Posted by Ghitulescu View Post
All legal sources are CFR, why encode in VFR?
I take it you've never heard of hybrid content. Or the WMV format. Or...


@ben13: I suggest you cut the audio before encoding the video (or doing anything at all to it, really). Remember that the audio does not have a framerate and that you're not changing the length of the video.

Last edited by TheFluff; 5th August 2011 at 12:23.
TheFluff is offline   Reply With Quote
Old 5th August 2011, 16:22   #4  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Trim before TDecimate, otherwise the generated timecodes won't match the final video stream, and all will go out of sync.

You have also a typo:
Code:
trim(2487,6611)
...
<startFrame>2287</startFrame>
<endFrame>6611</endFrame>
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding

Last edited by cretindesalpes; 5th August 2011 at 16:25.
cretindesalpes is offline   Reply With Quote
Old 5th August 2011, 19:45   #5  |  Link
ben13
Registered User
 
ben13's Avatar
 
Join Date: Sep 2010
Location: IN
Posts: 37
Quote:
Originally Posted by TheFluff View Post
@ben13: I suggest you cut the audio before encoding the video (or doing anything at all to it, really).
Emmm..? Please elaborate!

Quote:
Originally Posted by TheFluff View Post
audio does not have a framerate
Sometimes, I see options like speedup- 23.97 t0 25fps or vice versa in audio encoders... what are they???

Last edited by ben13; 5th August 2011 at 19:58.
ben13 is offline   Reply With Quote
Old 5th August 2011, 20:06   #6  |  Link
ben13
Registered User
 
ben13's Avatar
 
Join Date: Sep 2010
Location: IN
Posts: 37
Quote:
Originally Posted by cretindesalpes View Post
You have also a typo:
Code:
trim(2487,6611)
...
<startFrame>2287</startFrame>
<endFrame>6611</endFrame>
Sorry about that typo!
It was when I was experimenting on it, original one was 2487(correct one, but no use)

Quote:
Originally Posted by cretindesalpes View Post
Trim before TDecimate, otherwise the generated timecodes won't match the final video stream, and all will go out of sync.
You mean this ?

Quote:

#TRIM
#------------------------------------------------------
trim(2487,6611)++trim(8639,26687)++trim(32933,48150)

#PASS 2
#-------------------------------------------
tfm(d2v="test.d2v", input="matches.txt")
tdecimate(mode=5, hybrid=2, vfrDec=1, input="metrics.txt", tfmIn="matches.txt", mkvOut="mkv-timecodesfile.txt")
TFM dies an error saying
"test.d2v frame count does match the filter frame count"
ben13 is offline   Reply With Quote
Old 6th August 2011, 03:26   #7  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by ben13 View Post
Sometimes, I see options like speedup- 23.97 t0 25fps or vice versa in audio encoders... what are they???
That's for film -> PAL speedup (or the reverse); a very different thing.

When doing VFR encodes you should under no circumstances change the length or the playback speed of the audio (just like you wouldn't do it when doing a normal CFR encode). If the audio requires cutting (such as in your case when you're working on a TS with what I assume to be commercial breaks) you should do the audio cutting first, before doing any video manipulation of any kind.

If you prefer cutting the audio in Avisynth, you should put your trim() statements first, right after the source filter. If you absolutely need to use the d2v parameter to TFM, you can cut right after that filter (but before decimation), but if your source is a broadcast TS the d2v parameter is most likely not going to be useful at all, so you can just remove it (broadcasters rarely if ever use soft telecining).

Last edited by TheFluff; 6th August 2011 at 03:29.
TheFluff is offline   Reply With Quote
Old 8th August 2011, 18:54   #8  |  Link
ben13
Registered User
 
ben13's Avatar
 
Join Date: Sep 2010
Location: IN
Posts: 37
Quote:
DGDecode_mpeg2source("test.d2v")
assumeTFF()

#TRIM
#------------------------------------------------------
trim(2487,6611)++trim(8639,26687)++trim(32933,48150)


#PASS 1
#-------------------------------------------
tfm(mode=1, output="matches.txt")
tdecimate(mode=4, output="metrics.txt")

#PASS 2
#-------------------------------------------
tfm(mode=1, input="matches.txt")
tdecimate(mode=5, hybrid=2, vfrDec=1, input="metrics.txt", tfmIn="matches.txt", mkvOut="mkv-timecodesfile.txt")

#resize & denoising
#-------------------
Spline64Resize(1280,720)

#Filtering
------------------------
Filters...
This new code does the job!

Thank you everyone!
ben13 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.