Log in

View Full Version : [SOLVED]VFR_WMV into x264, video sync delay?


NiGHTsC
30th April 2009, 05:31
http://www.vimeo.com/4215168
You can download the original video using the free member download feature on the bottom right of the page

Below is the Mediainfo
Video
Format : VC-1
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Duration : 2mn 5s
Bit rate mode : Variable
Bit rate : 7 124 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16/9
Frame rate : 29.970 fps
Resolution : 24 bits
Bits/(Pixel*Frame) : 0.258
Language : en-us


As you can see in the stream video (not the download one), the video is few secs delayed cause of the VFR_WMV, audio and subtitle went fine as usual though.

I've tried to add convertfps=true in both MeGUI and Ripbot264, as well as to downgrade FPS to 23.976 (fps=23.976), but still not fixing this sync problem.

Is there anything else I could add in AVS to fix this video sync?


Thank you in advance.

Selur
30th April 2009, 07:37
Could you upload it (the source) somewhere else?, since probably not all people want to create a vimeo account. (even if it's free)
Personally I would like to try to convert it with sx264, which is not using avisynth but mencoder/ffmpeg for decoding and filtering. (always on the hunt for testclips ;))

Cu Selur

roozhou
30th April 2009, 07:37
No you can't if you are using avisynth script since avisynth does NOT support variable-framerate.

Please give dshow x264 a try(no GUI available now, you need to use cmdline)
http://forum.doom9.org/showthread.php?t=141441

nm
30th April 2009, 10:27
I've tried to add convertfps=true in both MeGUI and Ripbot264, as well as to downgrade FPS to 23.976 (fps=23.976), but still not fixing this sync problem.
You could also try preserving the original, variable framerates. Use WMVTIMES.exe (http://forum.doom9.org/showthread.php?p=827302#post827302) to create a timecode file from the source and use it when muxing the re-encoded video and audio to Matroska. Don't use convertfps when you try this.

JEEB
30th April 2009, 11:24
Agreed with the earlier poster:

FFMS2's ffvideosource() + wmvtimes.exe -> ??? -> profit

roozhou
30th April 2009, 13:26
You could also try preserving the original, variable framerates. Use WMVTIMES.exe (http://forum.doom9.org/showthread.php?p=827302#post827302) to create a timecode file from the source and use it when muxing the re-encoded video and audio to Matroska. Don't use convertfps when you try this.

If you do not use "convertfps", the video will repeat(or truncate) to fit the original length because avisynth needs a total frame number before playback and this number CANNOT be changed.

JEEB
30th April 2009, 15:13
If you do not use "convertfps", the video will repeat(or truncate) to fit the original length because avisynth needs a total frame number before playback and this number CANNOT be changed.

I did end up lol'ing, didn't I. First of all, as far as I can see he wants to re-encode the WMV, not play it back. And even if Avisynth doesn't as-is support VFR - it can still get all the frames out and with WMVTIMES you will have the timecodes. After he re-encodes the frames he can re-mux with DTSrepair or something to add timecodes information to the end result file if he needs MP4. For MKV it's even easier with mkvmergegui.

If he has subtitles these can be easily converted to be usable with the CFR'd stream. The only thing that's not-so-easy with my solution is that ffvideousource can give out a weird fps, but that can be fixed with an assumefps() that is close enough to the original. Kthx.

No repeat, no weirdness, no need for directshow hacking.

roozhou
30th April 2009, 15:36
@JEEB
I am not talking about ffms2 (yes it works). He mentioned convertfps so I assumed he was using DirectShowSource. The latest vsfilter supports external timecodes in TextSub, and he can use ffdshow as video decoder and subtitle renderer while not caring CFR or VFR.

Why do you think directshow is "hacking"? DirectShow is a more up-to-date technology compared to VFW which avisynth is based on, isn't it?

Dark Shikari
30th April 2009, 15:55
VFW which avisynth is based on:rolleyes:

roozhou
30th April 2009, 17:29
:rolleyes:

Actually avisynth frameserves like a vfw decoder, right?

b66pak
30th April 2009, 18:08
@NiGHTsC can you use mediafire or megaupload for the sample?
_

juGGaKNot
30th April 2009, 18:23
Vimeo : user login juggaknot4cs@yahoo.com pass pglforum.

Old email, i made it for people that want to download my vimeo videos.

b66pak
30th April 2009, 18:46
"The email address and password you entered do not match."
_

NiGHTsC
30th April 2009, 20:09
Sorry, my mistake for not upload it with main topic.

File uploaded to drop.io
http://drop.io/pbg3etx/asset/ffxiii-demo-cutscene-720p-part2-40s-wmv
just click Download and you are good to go

Thanx again!


I just try to get the timecode with WMVTIMES.exe
re-encoded WMV, video to 264, audio to AAC, merge with MKVMerge GUI v2.4.2, FPS set to 29.970 and timecode loaded in GUI
and it gives me this error message.
Warning: 'J:\video.264' track 0: The number of external timecodes 879 is smaller than the number of frames in this track. The remaining frames of this track might not be timestamped the way you intended them to be. mkvmerge might even crash.


by the way, I just re-encode WMV to x264 once again without adding convertfps=true ACCIDENTALLY
and the x264 version played great, no lag no delay!
but...it replay the last few frames at the end of the video...
guess the x264 video finish to play the frames too early so it has to replay them to fit the original length of video.

Here is the no lag no delay, but frame replay video.
http://drop.io/kgctezg/asset/ffxiii-demo-cutscene-720p-part2-40s-non-convertfps-mkv


Thank you once more!

roozhou
30th April 2009, 20:45
by the way, I just re-encode WMV to x264 once again without adding convertfps=true ACCIDENTALLY
and the x264 version played great, no lag no delay!
but...it replay the last few frames at the end of the video...
guess the x264 video finish to play the frames too early so it has to replay them to fit the original length of video.


That's right. I mentioned in previous post, this is the limitation of avisynth's framework! You can also try mencoder based GUI (sx264, mediacoder) or avidemux which does not suffer from such limitation.

nm
30th April 2009, 22:01
by the way, I just re-encode WMV to x264 once again without adding convertfps=true ACCIDENTALLY
and the x264 version played great, no lag no delay!
but...it replay the last few frames at the end of the video...
guess the x264 video finish to play the frames too early so it has to replay them to fit the original length of video.
Read JEEB's posts about ffvideosource.

b66pak
1st May 2009, 17:37
@NiGHTsC your wmv is NOT vfr...is pure 29.97fps

here are the timecodes:

# timecode format v2
0
33
67
100
133
167
200
233
267
300
334
367
400
434
467
500
534
567
601
634
667
701
734
767
801
834
867
901
934
968
1001
1034
1068
1101
1134
1168
1201
1234
1268
1301
1335
1368
1401
1435
1468
1501
1535
1568
1602
1635
1668
1702
1735
1768
1802
1835
1868
1902
1935
1969
2002
2035
2069
2102
2135
2169
2202
2235
2269
2302
2336
2369
2402
2436
2469
2502
2536
2569
2603
2636
2669
2703
2736
2769
2803
2836
2869
2903
2936
2970
3003
3036
3070
3103
3136
3170
3203
3236
3270
3303
3337
3370
3403
3437
3470
3503
3537
3570
3604
3637
3670
3704
3737
3770
3804
3837
3870
3904
3937
3971
4004
4037
4071
4104
4137
4171
4204
4237
4271
4304
4338
4371
4404
4438
4471
4504
4538
4571
4605
4638
4671
4705
4738
4771
4805
4838
4871
4905
4938
4972
5005
5038
5072
5105
5138
5172
5205
5238
5272
5305
5339
5372
5405
5439
5472
5505
5539
5572
5606
5639
5672
5706
5739
5772
5806
5839
5872
5906
5939
5973
6006
6039
6073
6106
6139
6173
6206
6239
6273
6306
6340
6373
6406
6440
6473
6506
6540
6573
6607
6640
6673
6707
6740
6773
6807
6840
6873
6907
6940
6974
7007
7040
7074
7107
7140
7174
7207
7240
7274
7307
7341
7374
7407
7441
7474
7507
7541
7574
7608
7641
7674
7708
7741
7774
7808
7841
7874
7908
7941
7975
8008
8041
8075
8108
8141
8175
8208
8241
8275
8308
8342
8375
8408
8442
8475
8508
8542
8575
8609
8642
8675
8709
8742
8775
8809
8842
8875
8909
8942
8976
9009
9042
9076
9109
9142
9176
9209
9242
9276
9309
9343
9376
9409
9443
9476
9509
9543
9576
9610
9643
9676
9710
9743
9776
9810
9843
9876
9910
9943
9977
10010
10043
10077
10110
10143
10177
10210
10243
10277
10310
10344
10377
10410
10444
10477
10527
10588
10645
10699
10764
10825
10881
10947
11008
11064
11130
11193
11252
11319
11383
11445
11512
11575
11704
11769
11834
11894
11957
12018
12074
12135
12193
12248
12311
12368
12421
12479
12534
12586
12648
12705
12759
12816
12870
12924
12982
13038
13093
13151
13206
13260
13314
13368
13421
13477
13531
13583
13639
13691
13744
13799
13852
13903
13956
14007
14056
14108
14158
14207
14257
14306
14355
14410
14563
14635
14711
14788
14860
14937
15010
15083
15157
15235
15307
15387
15461
15534
15609
15684
15755
15829
15897
15968
16036
16107
16207
16318
16394
16520
16598
16685
16779
16883
16976
17069
17150
17219
17279
17346
17404
17465
17532
17595
17649
17707
17760
17811
17867
17946
18054
18132
18199
18272
18360
18449
18557
18676
18768
18851
18935
19009
19079
19144
19210
19272
19329
19378
19427
19472
19516
19557
19594
19628
19661
19694
19728
19761
19794
19839
19883
19926
19969
20016
20066
20116
20169
20224
20278
20339
20405
20479
20564
20654
20744
20835
20924
21017
21115
21219
21319
21415
21506
21590
21666
21738
21808
21874
21941
22006
22072
22138
22205
22269
22334
22398
22461
22524
22589
22656
22723
22788
22851
22914
22977
23037
23097
23156
23213
23270
23322
23374
23424
23472
23519
23564
23609
23653
23697
23741
23784
23827
23870
23912
23954
23996
24039
24082
24126
24173
24221
24268
24310
24352
24395
24434
24472
24512
24553
24589
24626
24664
24702
24741
24779
24819
24859
24898
24931
24965
25062
25096
25129
25162
25196
25229
25262
25296
25329
25363
25396
25429
25463
25496
25529
25563
25596
25629
25663
25696
25730
25763
25796
25830
25863
25896
25930
25963
25996
26030
26063
26097
26130
26163
26197
26230
26263
26297
26330
26364
26397
26430
26464
26497
26530
26564
26597
26630
26664
26697
26731
26764
26797
26831
26864
26897
26931
26964
26997
27031
27064
27098
27131
27164
27198
27231
27264
27298
27331
27365
27398
27431
27465
27498
27531
27565
27598
27631
27665
27698
27732
27765
27798
27832
27865
27898
27932
27965
27998
28032
28065
28099
28132
28165
28199
28232
28265
28299
28332
28366
28399
28432
28478
28542
28605
28668
28723
28776
28828
28879
28929
28978
29028
29077
29125
29174
29223
29271
29319
29368
29417
29469
29521
29571
29620
29666
29710
29752
29791
29829
29863
29896
29930
29965
30004
30043
30084
30125
30170
30217
30267
30316
30368
30424
30480
30533
30580
30627
30688
30755
30826
30899
30968
31030
31104
31190
31275
31361
31434
31494
31552
31617
31682
31744
31804
31861
31918
31971
32024
32076
32124
32176
32225
32272
32320
32369
32413
32457
32503
32545
32588
32632
32679
32726
32775
32826
32874
32920
32970
33017
33065
33110
33154
33196
33229
33263
33313
33346
33380
33413
33447
33480
33513
33547
33580
33613
33647
33680
33713
33747
33780
33814
33847
33880
33914
33947
33980
34014
34047
34081
34114
34147
34181
34214
34247
34281
34314
34347
34381
34414
34448
34481
34514
34548
34581
34614
34648
34681
34714
34748
34781
34815
34848
34881
34915
34948
34981
35015
35048
35082
35115
35148
35182
35215
35248
35282
35315
35348
35382
35415
35449
35482
35515
35549
35582
35615
35649
35682
35715
35749
35782
35816
35849
35882
35916
35949
35982
36016
36049
36083
36116
36149
36183
36216
36249
36283
36316
36349
36383
36416
36450
36483
36516
36550
36583
36616
36650
36683
36716
36750
36783
36817
36850
36883
36917
36950
36983
37017
37050
37084
37117
37150
37184
37217
37250
37284
37317
37350
37384
37417
37451
37484
37517
37551
37584
37617
37651
37684
37717
37751

if you try to convert it to 23.976fps you will destroy it because every frame is UNIQUE end you must decimate...
_

NiGHTsC
1st May 2009, 21:48
That's right. I mentioned in previous post, this is the limitation of avisynth's framework! You can also try mencoder based GUI (sx264, mediacoder) or avidemux which does not suffer from such limitation.I see...><
Yah, I'm just trying to keep my programs

Read JEEB's posts about ffvideosource.wow, cool! it's fixed now...!!
the 40secs video finally played well...XD


but...
Is it possible that even with FFVideoSource, it still can't fix the sync problem?
or maybe I just got wrong setting in somewhere?

I try to encore other same-codecs&FPS-WMV and the problem is back, the video is 2-4secs delayed= =

This is how my AVS looks like with FFMS2LoadPlugin("I:\RipBot264v1.13.3\Tools\FFMS2\FFMS2.dll")
video=FFVideoSource("I:\FFXIII_Demo_Cutscene_720p_part4.wmv").ConvertToYV12()

then I re-encoe with DirectShowSource+non-convertfps=true and still 1-2secs delayed

at last, DirectShowSource+convertfps=true and same as FFMS2, 2-4secs delayed.

@NiGHTsC your wmv is NOT vfr...is pure 29.97fps

if you try to convert it to 23.976fps you will destroy it because every frame is UNIQUE end you must decimate...
_lol..my bad, another mistake...
convertfps=true isn't fixing it so I thought it must be a VFR
in fact, I just have no clue how to determine whether it is a VFR_WMV or not...


Thank you and Thank you :D

roozhou
2nd May 2009, 04:10
I guess the video contains a "still" frame which is one black frame lasting 1~2 seconds.

NiGHTsC
2nd May 2009, 06:54
hm..depends on the setting, it could last longer, from 1~4secs...

I may upload another one if necessary, cause this one is much bigger, 177MB...><!!

roozhou
2nd May 2009, 07:59
hm..depends on the setting, it could last longer, from 1~4secs...

I may upload another one if necessary, cause this one is much bigger, 177MB...><!!

I highly suggest you try my x264 build here. It can easily solve such problem. I tested your sample and it worked great.
http://forum.doom9.org/showthread.php?t=141441

b66pak
3rd May 2009, 19:18
after reading this:

http://forum.doom9.org/showthread.php?p=1274083#post1274083

i thing your sync problems are result of audio part of the movie (VSR .wma)
_

NiGHTsC
3rd May 2009, 23:00
I highly suggest you try my x264 build here. It can easily solve such problem. I tested your sample and it worked great.
http://forum.doom9.org/showthread.php?t=141441with FFMS2, the sample I uploaded could be done without any problem.

But it's just not working with another video...

maybe it's the audio sync now...

omg...MS just can't stop making things more complicated...:mad::mad:


Thank you.

after reading this:

http://forum.doom9.org/showthread.php?p=1274083#post1274083

i thing your sync problems are result of audio part of the movie (VSR .wma)
_do you have any other WMV demux? cause this WMVMuxer cannot demux the audio.

You could try with the 40s.wmv I uploaded.


Thank you.


Edit: Alright, I just upload the 177MB video.
http://www.sendspace.com/file/zuyb18

roozhou
4th May 2009, 09:03
with FFMS2, the sample I uploaded could be done without any problem.

But it's just not working with another video...

maybe it's the audio sync now...

omg...MS just can't stop making things more complicated...:mad::mad:


This is not MS's fault. If you can play these videos without problem but the encodes give you A/V desync, this is the encoder's fault.

JEEB
4th May 2009, 17:39
I'd say its MS's fault for not opening stuff and making it harder for people to use open source alternatives, but I think as long as official tools work with this I guess it's alright (although it all still makes up unneeded steps).

Basically my workflow with this given video was:

1) Re-encode video with ffvideosource, get timecodes from wmvtimes
2) Extract that wma track with WME's tools
3) Re-encode audio with WME to the so-called lossless (VBR 100) WMA (here the file seems to become "sane" WMA).
4) Re-encode to AAC/whatever sane format needed with whatever you usually use for WMA sources.
5) Mux it all together.

Not really pretty, eh? But works. I wonder if ffmpeg or something can work with these files correctly so that *nix lusers or people who wish for automatization won't have any extra problems >_>

Also, this is the first time I'm actually getting "Variable Sample Rate"'d WMA thrown at me, so I guess this thread taught something to me as well.

NiGHTsC
4th May 2009, 21:10
This is not MS's fault. If you can play these videos without problem but the encodes give you A/V desync, this is the encoder's fault.It's just the "Variable XXXX" stuffs are driving me crazy...= =

I'd say its MS's fault for not opening stuff and making it harder for people to use open source alternatives, but I think as long as official tools work with this I guess it's alright (although it all still makes up unneeded steps).

Basically my workflow with this given video was:

1) Re-encode video with ffvideosource, get timecodes from wmvtimes
2) Extract that wma track with WME's tools
3) Re-encode audio with WME to the so-called lossless (VBR 100) WMA (here the file seems to become "sane" WMA).
4) Re-encode to AAC/whatever sane format needed with whatever you usually use for WMA sources.
5) Mux it all together.

Not really pretty, eh? But works. I wonder if ffmpeg or something can work with these files correctly so that *nix lusers or people who wish for automatization won't have any extra problems >_>

Also, this is the first time I'm actually getting "Variable Sample Rate"'d WMA thrown at me, so I guess this thread taught something to me as well.Alright, I just demux my 177MB's Video/Audio with Windows Stream Editor.
Encode the Audio with Windows Media Encoder - File archive, save it into Loseless(VBR 100)
get timecode with WMVTimes, encode Video into 264 using FFVideoSource in Ripbot
Encode Audio into MP4_AAC with MeGUI and with Nero AAC_dp_ NDAAC-HE-32Kbps preset
Mux 264/MP4_AAC/Timecode into MKV with MKVMerge GUI v2.4.2

boom...still out of sync...= =

I play the MKV with wma and it plays well, so something was wrong during the audio encoding process
it seems the loseless VBR 100 is still "insane"

JEEB, which Audio encoder did you use?

Thank You.

JEEB
4th May 2009, 22:24
It's just the "Variable XXXX" stuffs are driving me crazy...= =

Variable framerate and all would be much easier to deal with should the tools work as they should. I at least told to the developer of ffmpegsource about this kind of audio, and about the fact that ffms2 gives out a wee bit wrong timecodes for wmv, but I have no idea if he'll be able to do something before he gets less busy.

Also, after checking several places in my encoded video the output seems to be in synch :3 Link (http://jeeb.fiveforty.jp/x264/test2.mkv) to a small encode I made of it.

I used foobar2000 for the audio encoding with 2pass AAC @ 64kbps via neroaacenc. Also, when I was trying to re-encode the audio to VBR100, I actually re-encoded the video with WME, too - although I have no idea if that has anything to do with it :).

Also, update your meGUI's stuff (mkvmerge etc.) if you're using it - since that's one of the good things it does (until a version that gets in breaks ^^; ).

NiGHTsC
4th May 2009, 23:44
You sure the audio is in sync?
cause at 0:44, the aircraft's gun sound is 1~2secs earlier.

Yes, they are all up to date, at least when I open MeGUI, no "There's update, please download it" message.

Since I've tried to play my MKV with WMAs(demux-ed one and loseless one) and no sync problems
so all I need is an audio encoder that can encode these VSRs into constant ones.


Thank you.


PS. I love JP ISPs :D

b66pak
5th May 2009, 19:21
ok...i found this: "Windows Media Audio 9 Lossless to PCM Converter" here:

http://www.microsoft.com/windows/windowsmedia/forpros/encoder/utilities.aspx

install it and go to that location (:c:\Program Files\Windows Media Components\Tools\WMAL2PCM\")...read LossLessReadme.txt for instructions...

for your sample "FFXIII_Demo_Cutscene_720p_part4.wmv" i extracted the audio and convert to lossless and then i do this:


cmd/k wmal2pcm.exe FFXIII_Demo_Cutscene_720p_part4_lossless.wma FFXIII_Demo_Cutscene_720p_part4.wav

and i get:

c:\Program Files\Windows Media Components\Tools\WMAL2PCM>cmd/k wmal2pcm.exe FFXI
II_Demo_Cutscene_720p_part4_lossless.wma FFXIII_Demo_Cutscene_720p_part4.wav

Converting FFXIII_Demo_Cutscene_720p_part4_lossless.wma to FFXIII_Demo_Cutscene_720p_part4.wav
++ Song title:
++ Author:
++ Copyright:
++ Description:
++ Rating:
++ WMA bitstream version: 3
++ sampling rate: ++ # of channels: 2
++ bit-rate: 1152000 bps
++ duration: 282773 ms
++ DRM content: No
Presentation time is off by: 1000.250127 ms
Presentation time expected: 30092.742188 ms
Presentation time received: 31092.992315 ms
Full Read and Decode took 7 s.
Play Time would be 281 s.

pay attention to the red line!

i get a .wav witch should be delayed with "1000.250127 ms" to be in sync with the video!

i use BeHappy with this .avs:

########################################
#Created by BeHappy v0.2.3.38221
#Creation timestamp: 5/5/2009 9:17:30 PM
########################################
#Source FileName:E:\FFXIII_Demo_Cutscene_720p_part4.wav
#Target FileName:E:\\FFXIII_Demo_Cutscene_720p_part4_delayed.wav
########################################

########################################
# [Source: RaWav IgnoreLength always]
########################################
RaWavSource("E:\FFXIII_Demo_Cutscene_720p_part4.wav", 1)

########################################
# [BeHappy: Delay Audio by 1000 ms ]
DelayAudio( 1000.0/1000.0)

########################################
# [Encoder: Wav Writer]
########################################

the final .wav is in sync now...
_

L.E. try this with any other .wmv and report back please...

NiGHTsC
5th May 2009, 20:39
@b66pak
Where you found this 38221 version?
the newest one is 38071

cause I got only # [Source: WavSource] while you have # [Source: RaWav IgnoreLength always]


Edit1 : anyway, it seems the version doesn't matter after all, it's the 1000ms.
so once you have it delayed, everything goes perfectly, at least for the part4 one.


WME Stream Editor -> WME -> WMA to PCM -> BeHappy -> any Audio encoder
wow...crazy WMV...


Thanx alot b66pak and Thanx to everyone who tried to help me.
100x Thank you

:D

b66pak
6th May 2009, 19:05
you can also try this:

1 WMEncoder Stream Editor to extract the audio.
2 WMEncoder To convert .wma to .wma lossless.
3 LoRd_MuldeR's LameXP v3.08 (2009-03-05) - http://forum.doom9.org/showthread.php?t=119749 - to convert .wma lossless to whatevar you want (i only tested with the uncompressed wave PCM)
_

NiGHTsC
6th May 2009, 21:56
It's alright ;)
wmaltopcm is a good tool to find out the sync ms.
glad I have only few WMVs, rofl

Thanx again XD