Log in

View Full Version : how to restore 24p from progressive 25p with duplicated frames?


yantei
6th February 2010, 12:00
Hi guys,

I'm looking for a suitable restoration function for my material:

progressive 23.976 fps material converted to progressive 25 fps PAL without any blends - 3 duplicate frames every second and one missing frame (?) between them

the pattern is something like this (duplicated frames):

1 3 5
26 28 30
51 53 55
76 78 80
99 101 103
124 126 128
149 151 153
172 174 176
197 199 201
222 224 226
247 249 251
270 272 274

...and so on...

the best would be to remove all duplicates and artificially generate this one missing frame every second - am I thinking right? is that possible? what would you suggest to try?

17-sec DV-encoded sample here:
http://www.mediafire.com/?2dk0mm0jngv

thanks in advance for any suggestions

jmartinr
6th February 2010, 14:05
Aren't that 2 missing frames/second?

yantei
6th February 2010, 14:14
yeah, you're right of course

but is it possible to reconstruct them somehow?
I just would like to do something with this material in order to watch it - in this form which I've got it is really painful, I don't think I can focus on action...

Emulgator
6th February 2010, 15:17
If you can find a pattern: SelectEvery, SelectRangeEvery.
If there is no deterministic pattern because footage may have been cut after pattern had been applied.
then manually Deleteframe(,,,,,,)through the whole clip.
In your clip I see an offset 23 if a previous pattern of only 2 repeats were made,
otherwise offset 25 if 3 previous repeats were made, but the 25er not always repeating 3 times before a 23er is coming...
Audio, missing, I can not say, this is up to you.

0 Start

10,12,
+23
33,35,37
+25
58,60,62
+23
81,83,85
+25
106,108,110
+25
131,133,135
+25
156,158
+23
179,181,183

?
+25?
204,206,208?
+25?
229,231,233?
+23?

252,254,256
+25
277,279,281

?
+25?
302,304,306?
+25?
?


327,329
+23
350,352,354
+25
375,377,379

?

428 End

yantei
6th February 2010, 16:52
Thanks for help, Emulgator
It is not a good idea for writing down all duplicates - clip has got circa 112500 frames...
I don't think the clip has been cut after this awful conversion
You've missed one duplicate (325)
I've checked further frames and noticed few 21-frame offsets :(


0 Start

10,12,
+23
33,35,37
+25
58,60,62
+23
81,83,85
+25
106,108,110
+25
131,133,135
+25
156,158
+23
179,181,183

?
+25?
204,206,208?
+25?
229,231,233?
+23?

252,254,256
+25
277,279,281

?
+25?
302,304,306?
+25?
?


325,327,329
+23
350,352,354
+25
375,377,379

?

448,450,452
+25
473,475,477
+23
496,498,500
+25
521,523,525
+25
546,548,550
+25
571,573
+23
594,596,598
+25
619,621,623
+25
644,646,648
+23
667,669,671
+25
692,694,696
+25
717,719,721
+23
740,742,744
+25
765,767,769
+25
790,792,794
+25
815,817,819
+23
838,840,842
+25
863,865,867
+25
888,890,892
+23
911,913,915
+25
936,938,940
+25
961,963,965
+25
986,988
+23
1009,1011,1013
+25
1034,1036,1038
+25
1059,1061,1063
+23
1082,1084,1086
+25
1107,1109,1011
+25
1132,1134,1136
+25
1157,1159
+23
1180,1182,1184
+25
1205,1207,1209
+25
1230,1232,1234
+23
1253,1255,1257
+25
1278,1280,1282
+25
1303,1305,1307
+23
1326,1328,1330
+25
1351,1353,1355
+25
1376,1378,1380
+25
1401,1403,1405
+23
1424,1426,1428
+25
1449,1451,1453
+25
1474,1476,1478
+23
1497,1499,1501
+25
1522,1524,1526
+25
1547,1549,1551
+25
1572,1574
+23
1595,1597,1599
+25
1620,1622,1624
+25
1645,1647,1649


do you need more?
Do you think it is still worth trying?

(sorry for mistakes I've made before an edit)

yantei
6th February 2010, 17:33
okay, I can see the pattern now, every 586 frames

but can You help me with dealing with it using avisynth functions?
and how to insert missing frames? the final material can be interlaced if it's the only reasonable solution

I just would like to make movements smooth back again...

yantei
7th February 2010, 17:09
i was wrong again
cycle has got 1001 frames and there is 121 duplicates in it (does it make sense?)

I can remove dups using MultiDecimate plugin, but how to insert missing frames in order to get rid of "jerkiness"?


1009,1011,1013
+25
1034,1036,1038
+25
1059,1061,1063
+23
1082,1084,1086
+25
1107,1109,1011
+25
1132,1134,1136
+25
1157,1159
+23
1180,1182,1184
+25
1205,1207,1209
+25
1230,1232,1234
+23
1253,1255,1257
+25
1278,1280,1282
+25
1303,1305,1307
+23
1326,1328,1330
+25
1351,1353,1355
+25
1376,1378,1380
+25
1401,1403,1405
+23
1424,1426,1428
+25
1449,1451,1453
+25
1474,1476,1478
+23
1497,1499,1501
+25
1522,1524,1526
+25
1547,1549,1551
+25
1572,1574
+23
1595,1597,1599
+25
1620,1622,1624
+25
1645,1647,1649
+23
1668,1670,1672
+25
1693,1695,1697
+25
1718,1720,1722
+23
1741,1743,1745
+25
1766,1768,1770
+25
1791,1793,1795
+25
1816,1818,1820
+23
1839,1841,1843
+25
1864,1866,1868
+25
1889,1891,1893
+23
1912,1914,1916
+25
1937,1939,1941
+25
1962,1964,1966
+25
1987,1989,1991
+23
2010,2012,2014
+25
2035,2037,2039
+25
2060,2062,2064
+23
2083,2085,2087
+25
2108,2110,2112
+25
2133,2135,2137
+25
2158,2160
+23
2181,2183,2185
+25
2206,2208,2210
+25
2231,2233,2235
+23
2254,2256,2258
+25
2279,2281,2283
+25
2304,2306,2308
+23
2327,2329,2331
+25
2352,2354,2356
+25
2377,2379,2381
+25
2402,2404,2406
+23
2425,2427,2429
+25
2450,2452,2454
+25
2475,2477,2479
+23
2498,2500,2502
+25
2523,2525,2527
+25
2548,2550,2552
+25
2573,2575
+23
2596,2598,2600
+25
2621,2623,2625
+25
2646,2648,2650
+23
2669,2671,2673
+25
2694,2696,2698
+25
2719,2721,2723
+23
2742,2744,2746
+25
2767,2769,2771
+25
2792,2794,2796
+25
2817,2819,2821
+23
2840,2842,2844
+25
2865,2867,2869
+25
2890,2892,2894
+23
2913,2915,2917
+25
2938,2940,2942
+25
2963,2965,2967
+25
2988,2990,2992
+23
3011,3013,3015
+25
3036,3038,3040
+25
3061,3063,3065
+23
3084,3086,3088
+25
3109,3111,3113
+25
3134,3136,3138
+25
3159,3161
+23
3182,3184,3186
+25
3207,3209,3211
+25
3232,3234,3236
+23
3255,3257,3259
+25
3280,3282,3284
+25
3305,3307,3309
+23
3328,3330,3332
+25
3353,3355,3357
+25
3378,3380,3382
+25
3403,3405,3407
+23
3426,3428,3430
+25
3451,3453,3455
+25
4376,3478,3480
+23
3499,3501,3503
+25
3524,3526,3528
+25
3549,3551,3553
+25
3574,3576
+23
3597,3599,3601
+25
3622,3624,3626
+25
3647,3649,3651
+23
3670,3672,3674
+25
3695,3697,3699
+25
3720,3722,3724
+23
3743,3745,3747
+25
3768,3770,3772
+25
3793,3795,3797
+25
3818,2820,3822
+23
3841,3843,3845
+25
3866,3868,3870
+25
3891,3893,3895
+23
3914,3916,3918
+25
3939,3941,3943
+25
3964,3966,3968
+25
3989,3991,3993
+23
4012,4014,4016
+25
4037,4039,4041
+25
3062,4064,4066
+23
4085,4087,4089
+25
4110,4112,4114
+25
4135,4137,4139
+25
4160,4162
+23
4183,4185,4187
+25
4208,4210,4212
+25
4233,4235,4237
+23
4256,4258,4260
+25
4281,4283,4285
+25
4306,4308,4310
+23
4329,4331,4333
+25
4354,4356,4358
+25
4379,4381,4383
+25
4404,4406,4408
+23
4427,4429,4431
+25
4452,4454,4456
+25
4477,4479,4481
+23
4500,4502,4504
+25
4525,4527,4529
+25
4550,4552,4554
+25
4575,4577
+23
4598,4600,4602
+25
4623,4625,4627
+25
4648,4650,4652
+23
4671,4673,4675
+25
4696,4698,4700
+25
4721,4723,4725
+23
4744,4746,4748
+25
4769,4771,4773
+25
4794,4796,4798
+25
4819,4821,4823
+23
4842,4844,4846
+25
4867,4869,4871
+25
4892,4894,4896
+23
4915,4917,4919
+25
4940,4942,4944
+25
4965,4967,4969
+25
4990,4994,4994
+23
5013,5015,5017
+25
5038,5040,5042
+25
5063,5065,5067
+23
5086,5088,5090
+25
5111,5113,5115
+25
5136,5138,5140
+25
5161,5163
+23
5184,5186,5188
+25
5209,5211,5213
+25
5234,5236,5238
+23
5257,5259,5261
+25
5282,5284,5286
+25
5307,5309,5311
+23
5330,5332,5334
+25
5355,5357,5359
+25
5380,5382,5384
+25
5405,5407,5409
+23
5428,5430,5432
+25
5453,5455,5457
+25
5478,5480,5482
+23
5501,5503,5505
+25
5526,5528,5530
+25
5551,5553,5555
+25
5576,5578
+23
5599,5601,5603
+25
5624,5626,5628
+25
5649,5651,5653
+23
5672,5674,5676
+25
5697,5699,5701
+25
5722,5724,5726
+23
5745,5747,5749
+25
5770,5772,5774
+25
5795,5797,5799
+25
5820,5822,5824

yantei
7th February 2010, 20:46
all right, I think I'll give it up, although the video is really worth trying :(

I've wasted whole day for this

Removing dups using MultiDecimate is probably bad idea - the most important part is to insert missing frames blended from the neighbours
I've got the pattern but It seems to be too difficult to decide how to treat duplicated frames while generating missing frames

I'm sorry if my thread is difficult to understand
I'll try to describe my problem again, summarizing the whole case:


My video is a progressive PAL material converted from progressive 23,976 fps in a strange way - every ~1 second there are 3 duplicated frames (no blends!)
within 1001-frame cycle I can see two parts divided by a 2-dups occurence
in the end of each 1001-frame cycle there is also a 2-dups occurence

jmartinr
8th February 2010, 00:18
I have no experience with this, but I think that as a first step you should try to dump ~1 frame/second, so you get 23,976 with ~2 dupes/second and work from there.

Didée
8th February 2010, 00:36
I have no experience with this, but I think that as a first step you should try to dump ~1 frame/second, so you get 23,976 with ~2 dupes/second and work from there.
No go. If you start with decimating one frame first, you don't know if it was a miss-dup or a dup-dup, so afterwards, you don't know nothing anymore. Hence you can't work from there.

A scriptable solution:

prepare interpol = input.MFlowFPS() with delta=2

make mask = input .is_a_dup

make mask = mask NAND mask(frame-4)

mt_merge input,interpol,mask

TDecimate now

return success

jmartinr
8th February 2010, 09:29
The idea was to know what you're removing (say only the last dup of a row of 3) so you know the pattern afterwards, and the timing of the frames is correct.

But I gladly yield to your suggestion, Didée. ;)

yantei
8th February 2010, 11:50
prepare interpol = input.MFlowFPS() with delta=2

make mask = input .is_a_dup

make mask = mask NAND mask(frame-4)

mt_merge input,interpol,mask

TDecimate now

return success

Wow,

Big thanks Didée

but now that's work for experienced avisynth programmer which I'm definitely not... could someone help me with this and try to write a working function based on Didée's idea? I can send the final, processed video (which is really good and rare) as a reward

Didée
8th February 2010, 13:12
Some code, quickly thrown together ... beware, it's pretty much "proof of concept", not quite "ready for production".
Whattheheck, it basically works.

o = AviSource("D:\sample.avi",pixel_type="YV12")

diff2prev = mt_makediff(o,o.selectevery(1,-1)).mt_lut("x 128 - abs 2 *")
metric1 = mt_lutf(diff2prev,diff2prev,"average","x").mt_lut("x 2 - 255 *").invert()
metric2 = mt_logic( mt_logic(metric1,metric1.selectevery(1,-2),"min"), mt_logic(metric1,metric1.selectevery(1,2),"min"), "max")
metric3 = mt_logic( metric2, metric2.invert().selectevery(1,-4),"min")

osup = o.MSuper(sharp=2)
bv = osup.MAnalyse(isb=true, delta=2,blksize=16,overlap=8)
fv = osup.MAnalyse(isb=false,delta=2,blksize=16,overlap=8)
interpol = o.MFlowInter(osup,bv,fv,time=50).selectevery(1,-1)

rep = o.mt_merge(interpol,metric3,luma=true,U=3,V=3)

rep.tdecimate(mode=7,rate=23.976)

A pity that TDecimate doesn't have a mode that merely outputs a "marked-for-decimation" mask ...

yantei
9th February 2010, 12:01
yep, it works - pretty nicely, I'm processing the material right now
huge thanks for spending your time for it, Didée

however, I could still find some duplicates, even two next to each other... maybe because the sample I provided is not the beggining of my whole video, it starts at 847th frame
and regenerated, masked frames are of course easily recognisable but - I believe - won't be irritating during the playback