Jump to content

Show Intro Skip Option (Plugin)


Liquidfire88

Recommended Posts

4 hours ago, chef said:

@dotcom what happens with the finger print data?

It is a rather large string of encoded data.

What is it exactly? 

yeah, here's the fingerprint of the office intro:

DURATION=30
FINGERPRINT=3336578991,3340773295,3307284135,3307361987,3290453955,3311461363,3319833587,3319968083,3319959874,1172477186,1155695874,1415615778,1415623715,1948296227,1965073459,656583683,639809537,639797249,774015057,774031585,706771043,710961251,719337767,719403293,711146781,711137037,711264029,720184877,715859501,715851327,715665999,733487757,681058957,949498516,412684948,412619396,144201412,1217980997,1216932357,1216981511,1285204483,3432701443,3437151747,3430827715,3446622099,3479523219,1315257779,1256274339,1256398259,1248009619,1247875507,1243640243,1244717474,1244701090,1511039458,1511039458,978564435,1783863123,1809036593,1800650033,1762901265,1762900241,1796454673,3943930149,3927088421,3927104805,3927137583,3947956015,1769015083,1760763690,1760763690,1752239930,1760567066,1758539034,1754344926,1754742175,1770337677,1770267021,2038702468,1485070724,1480881028,1212511124,1279750996,1288075060,1283878693,1150442277,1150437653,3300052229,3321023749,3311914309,3479555525,1315786647,1315397559,1323712439,1323450295,1315115430,1314927014,1310749110,1311830438,1242603938,1511039458,2064687586,2030085490,1744942962,1746059027,1829945091,1865595651,1848883473,1848752417,1779538211,1779670311,1779686438,1779631143,1802633263,1769082927,1752372527,1752237375,1760763165,1756774173,681451069,681381597,681064077,696787853,965222797,466149773,424398988,424276412,1212806636,1213167404,1288601148,1284931100,1284922884,3432400389,3432203781,3436397327,3480700879,3480620494,3462859222,1256675766,1256679846,1273048502,1264592342,1264603606,1244709334,1244762610,1242801122,1511236067,1510056435,2046931443,2046857697,1778430433,1778495969,1778628565,1778499029,1778498037,3942889967,3942898159,3943914991,3914534251,3916629371,1777538330,1777538362,1777538330,1760638234,1761027355,1774138683,1773999483,1773696457,2073585033,2072568205,2076766605,1531506845,1494184157,1544433757,1548628285,1557542717,1284906541,3297906237,3300068877,3300204301,3438563151,3445968335,3479522703,1332039575,1315135414,1315125174,1323443126,1315136438,1316090806,1311814562,1309712802,1578148322,1511039474,2068881907,2068887011,1796257123,1863431459,1863499059,4010974487,3994270997,3996368181,3929210149,3929169197,3945989421,3950052653,3924887337,1777406779,1777546011,1777546011,1775318299,1754608923,1754545434,1755065802,2022452619,2022450575,1489777037,416027021,147788189,147723164,147723228

Edited by dotcom
  • Like 1
Link to comment
Share on other sites

I must be missing a flag in the command line. My fingerprint data is a bit different

{"duration": 300.00, "fingerprint": "AQADtNGcJErEDGGqo8_CoT_6D_nxXGDyotKhHzoflH_gV4SoEV5P9BM-5PrB5Bl6PEd-_BYOxdGLJiL6RKnx2Mae48Pv4CiaDl_BPsR5_EbzFf0J_SEQZpWKPsfxF88R8g181ITO449A3yPKwzr040KpI__w40eviWhe_EX54ceP50dKHiWLI0etMMvh44eV4wsP_sb5QP_wDM9yYttxC8-D74Gb6EeyIxZb4Vl2TCeJ5jmetjjx42AQ5th_5HvxYP-C40MPSgcaWimOI0yrQTvCwjkmTIcZDSccHZ1pxIZ2pD9emMcZ-NPQ4ygP_0LYHV2T7Wh-_EfDFSWjC9_xWcPBvsiXHSVpCc1d_MJzPOGDZvQRWvmQ_EVN5TgPlhEmZse_4anRlINqCVOOZ0fJKCmausTT4ziYH_4QaTuua5h-XNKF_vjB8EN--Hhx_PCRzWB23CvO40fRXEPOCCV5NP_QD36PsqBvlB0fGL2uIf8I6SgZfbi748qhD-mDrsJ5hBcSvij6enB7VMc-9LAW0UJIiYXiI3wq-Ct-4zbyaIe2hkc-gtHhdThxHTmPSzoc99A-F89RUCeFFyW46jgqvUiPouJx5PCkHboMl0dOw-PRMhMuTTcepsONHj4YU5TwJcsRL_og6kTe4rjCo-pxMfjh8UHo83jC4BEc_XhS3McbPKmDkl-I5yQ2RuiPL8QvtL1EeOpROXLQo0kqZcV_5OHRP_Cl40JI-dCqGWnnBS2pCSeOXYmOPksqJJdYItqOShmD9caPX3C1-HgTPYjVQx_hMfhM7Plx5dBvHBEza8TWXMIZE58Pc8GJnIOmbC_CpLqC8_hx5sOLv6gON2EyEWky0YdIHuGXFuew-_gymbiOZnvRH6eiIJ-kTEaF5scn48pSBe3aBN4RHv_wHI32iEF-CY3STMdOiLKES8QZGs1ohMKHMNcwXUHRRD5OLYa0ZTgPPUL1YUqyHz_y8OgRHrduaC96jUJsDc-JL8OPfqEwpdbxK7gLduHxHKYUJfgQ8bC0zFC_o_2C1MePfQxuoT6e44efZTO-oMm4BuEeDeeFX9C-455QNx1xhNr0wRU5nPCZC_2JfkLT9zheNDnyXipO_hD36OhL5Dn2o0-A80NKXUHyZbCnr6iHKwzh4AlzYk7EcEFzJPty5Mf0o4mP5xI-iWjGj3iNhA_S2ui1HM_YoXrgViGuHCWS60gnfCa-BWHuY_rx44eipwgThwgtjUKjpYQK_9gl42GiDVJF5DamPDnKH1-UwxlirTmhijnePEQpP0ifInx6KEd-8Beu5MXFNMdzHVs8PGyO80rwJIJ3JG-D_HgQJ-KNJuWJ8thtfMrBPOkR5j_-4OCDpleCPlm64SZR6cohJ-2C88eX4Xly9AujCD8e4Vki_MX9UODVwXF2PBFLYz9mY8pJlMcTXLmKq0VzhNSh50d042Dl484TdEyR30h2HbXD4AuHppKMfDl09Xgk5mj-oTI58Dn05Phc_EJ_Ycq145OPy8RG4nmOHz0lNJM4hcV34oxC_GDEQyuP_cgfnMaF1vDRR7mEX8h9nDG-PWge6JKO9EZ_Bddj9MSUikEPJsfZENOeI80fBcm6VEZ_NN2Nq0EtHs2047Rm5LAbI98jYj765ejxsOCVI8wkGgwjLXB1_LKQKwyYH02P58WPxDviXvBp4-GP-cf1wN1y5EYSPuKMrkuOJr9wNFeOdtdwW4dm5UOz6MbJ5PiIyjkaMWVyXA-B71mQI9kPPzjcJmiOZ_iR6-BjiLmx4s7RXEP_44d_4jyRK09g_rgy4c5xHfmTQKxTIRYzHdcsHdcOPzuurEJ-Q3F-5OxwKjsaLWFoMHKihcEfFc2jY0-QzE4Y5DEePyipowmT_Hj0BAnzdcj34kuZoDaaaJaOJ9qOC78l-NiPXMoj_HAy4k6Ck8YVmIf64wl9ZOhZ4VExPaISHI-S4eERHlo-Ik-CldGFq8LBcGgiSZtxHVevCH8C17iSLMezCwn_acizo8yNZhdxZ0cVE1tz1FuO73jwZMfWn_gyxFH4BAnzSsKXSbi2HFyYKxGq52j-Ck8S5YhEm0jIo-WFEnYv9Fo2NHmEbspY4z4u4YwWPJOLPJqDZOkrHDezD32O75rxpcenWMIloT3uECf14R2ShlSRT0fZxWi6HO2Eycl0HJYffGsFqifK6cGFnziDugaTaE-QLMwqDuHyROhT-DnW493xxF1g5cSbX4i-Q88y5Bf4FOY-IeQGXPIDLdKLHj--Hc15aG-AXvkRRk9-cCoao5eO_jiiH1p2LhFiJSuF6kNz7uiR9tDSHDljXC565ZhSaVMS1PkCJtGP1Ua6Q88RU1-MH6fQLxzh5UdJ4ezReDq8C_XRH9u74x9-JFNeIdQlNM9yvNEufPAo5fiDONOFJOQuXMcZ7LjxeXCi7Bn4HLmoKELy4qhHTHGOi2YQR0t2QueCSId945fxDw3HbMB5IdWhssFzaD_O45uC1FN64Zs-_MOpI8-aQpV8PPqR7kY_4loS4hl2hFmH9kGcXETlHM0vYVeSE8zl4seuE1UiFU3-IVkXVkE-PLmOZ1SKXgl8o9_xEH-CyeGN5smRB1N-QVO042ksRJZo4UdumA5YSsF_XNnRbGEqYXrSD98JeRTuSNiJR62Exj1K_DiZVIKkKsPd4jF846PwptAWKVORPisAAxBBhhllHEZMCCCUgFwoIUQkVAjClFCMIGDAJcY4oggRjhhTiHFEKEAAgEYRCRgxjnAEgbQGSuEEACAEBIABThGEjDHMCMoUMsBIQpRSCHHAkAAGGSGURUwIhiB2wAFGHFEEKCKQQAAYRaBwlBBAAAGEAAEMEQwRZxAlCAmKhRFAISEAI8AIaAB2xDhBASNUACKMsAAAAogyQgAiFAeACQWEgQQqIQlCAhDoGBBIAQIEJIwYowDzUAiBgADIWOIMYWYAioxEQiAHlACAImMMAYQ4IAURQhBhgJGQcEEAEQZKwYQARBAFBDJMAMKcgIIAZIhgwjEggSDUCYOYMAIAZQhSJggplBMIQEIAMYIZKw1hSjEQiRBECEAcIcw4pggDwCFHgSCMGsYAIQQpRBBxwgAiBAHCMQMEIAIAhhQRgCgEAAIAEuQUAkgYQCAFDlDFBHEWCaKIgwYJqJACAgiEiAQKIIGMcwAYggQghAkkiESeMEMcQU4BIoABnBmAkACAEKMAAcYIIBEAQAglnBgOKKYIAFAAJIRgjCEhBAKGKaCIMwABgwgQAjDDHGECagiBUsgjAgAFSAOFiBKCSKAsAAQIIBAxghBphCDASAQQEwZAxBRAgghCiCIKAQkAMEQJQogCRDgCADJMCCUoIcQZxgyQihiBlALEGAKQMpAYJ4wgQCGClEFIAGgAkAISYogQChFjBHAaCUicIMwAwhUSABAlkAGACi8AHBAQJwghBgglhACOKcNEAwIQgQwhAAoAlMIEAQgkJMQAC4QgQhAjMACAEEMEAgQYgShgCjBAAENEAQMQQIIRAIhADCEADCBACAAEYIohIIAQSiMFiQBCYUSAMoAAAgAQTBEgECCSKACIkIIIIZhQEAEhkEDOAAEMcIQIIIByCgImABBIAgQQA8QohBBwQAgDDLKEAGEMIcwYAxxCABiJhEEACGYEAgAABJAByBBDEVAI"}

 

I'm thinking i need to set '-raw' to true? maybe...

EDIT: Yes now I'm getting an integer array.

Command line is:

            var fpcalc = "fpcalc.exe";
            var procStartInfo = new ProcessStartInfo(fpcalc,"output.wav -raw  -json")
            ...
            
{"duration": 300.00, "fingerprint": [640612389,644803604,654275588,671085588,905933828,897537029,876563461,892816445,1027034477,1060593007,1062698861,1054342781,798359133,798341887,766876639,754817999,745380815,1814929102,1815084790,2083520230,2100248294,2133671655,2121023079,2121018983,1860969825,1860973585,2125415425,1068194817,1034607621,1034614789,1030486085,1026291781,1026291797,1026284645,1060756581,1065344365,1073741677,801103725,766369629,703463245,946732367,946732367,942627966,959396974,992951406,997014894,980237166,984562303,984554079,984571471,1001225805,1000931149,434765125,426376277,426507509,422305015,422141175,422271463,460028390,468417510,1005288166,1069153014,1034549958,904526470,300546966,283769238,275347862,807999894,809057207,809183911,813378215,821766822,278732470,278666902,278675158,278413174,9992502,1100544318,1201192254,1186510140,1186501436,3468403516,3468337688,3489374744,3388707352,3363550744,1213983288,1212934699,1225390954,1258866794,1511639166,438290510,507429966,507412558,372146254,372150350,372150358,372215911,506303587,1059970146,1059970530,963500518,963631590,963640806,963509750,963476830,963476830,971767662,971767790,971763694,972647391,972680141,972679644,970582460,970582440,962193852,962166684,962289564,962322172,970587756,970583597,970845759,1004404254,1004396318,996007230,996011070,957344798,957336590,957336654,958385502,945786238,954179439,684584959,676130767,944631695,944766399,1028607151,1062014127,906767535,906833071,911158695,919478182,865013430,832523910,832425670,832359942,838633734,905484342,896052263,930653220,897310772,1031467060,1031422268,1029329448,433746472,429620776,429472280,429419098,433613422,425228654,421251198,456838222,440123470,440057934,440320078,444518486,444592246,444462307,1065213155,1064160503,896391607,897448359,897579943,838859455,838729406,821952158,821681822,821682078,813292958,813301182,813297143,830074223,828996911,862481711,845770031,845770047,845888783,845831950,862670366,938200622,900451902,883547678,883556110,887684358,1425660950,1425660982,1572467750,2147083303,2147085357,2071551293,1533758845,1529564157,1500204031,1500216286,1500195662,1508585230,1508605727,1504280380,1504280364,1541961532,1533604636,1533670220,1534849864,1534841688,1509556216,1507388137,1498999791,1478224894,1480248286,423250910,427511774,460920799,444278605,444216652,442119444,442176564,442053684,444163124,452556085,469490997,536464725,501843271,493454535,493454551,472761599,472896767,472897007,477101479,477101991,485228279,485097174,485097158,485227158,485223062,481028759,1554743223,1554609589,1558786453,1559044244,1550660020,1550275492,2095576804,2096492068,2096425508,2096409140,2088020500,2099637772,4247181068,4284924237,4286038511,4294173166,4260618734,4258506606,3990073150,3989879614,4023433534,3998263326,2920590351,2920787983,2920730639,2786480495,2786464495,2786984623,2793341615,2818383535,3787263935,4037872063,4037877659,4038934411,4038862475,4059834251,3546047899,1398595771,1396461803,1396457723,1362038795,1345196299,1349399050,1353589274,1420784186,1420685882,3568105259,3569139001,3564411160,3577658120,3577653768,3576605192,3610238476,3597420060,3739750943,3739816762,3739877482,3731357934,2657632494,2654486638,3732526158,3757614286,3753411983,3753482125,3753485997,3751522221,2681958313,2673564585,2400918443,2400918507,2369658670,2356024074,2230125322,3299615498,3299610922,3299365162,3299393579,3437815033,3426274440,3443034248,3443100040,3745159560,3745429896,3728124296,3732318680,3604067832,4136673561,4138763067,4277379882,4267877162,3190006574,2938540334,2904982830,2888731678,2892942350,2892986446,3158060239,3158060191,3023973551,3023439279,3077910959,3065455551,3064406687,4138148494,4138033870,4154778318,2506417790,2418321023,3492726735,3492734411,3492562281,3496543593,3505075305,3505333593,3505333512,3505335304,3505224761,3505183789,3505183805,3521944909,3513759181,3513750407,3580789639,3577119621,3614868437,4150691617,4133918497,3060049696,3194267440,3194791713,4285392417,4285527603,4264252963,4264101474,4265084898,4265091490,4269285538,4275765426,4141745286,4120777862,4103484550,3566677390,3568776590,3568328622,3568357294,3568365547,3572620619,2498821385,2506161945,2539714360,2548168504,2548552508,2548470332,2540082732,2674234924,2640676396,3187062284,3187060492,3180825980,3185348077,3210517741,3189544173,3055400191,3055023615,2805363183,2805354991,2775974846,2783385502,2783393182,2984519102,2968794542,2968589758,4038267278,4038275470,4038140302,4038074878,3521130879,1365275967,1399190557,1462236173,1445456908,1445979144,1445977112,1445977112,1596968216,1550829369,1550802490,3639481882,3639489034,3634890250,3634890346,3652728746,3667599534,3666550942,3397910669,3465035916,3469263000,3460878568,3457995112,3458136872,3745442328,3711347224,3723930171,3719802394,1572111882,1576846026,1551680154,1547323066,1413099194,1413099434,1412048297,1412046984,1349189768,1375273096,297271481,330834093,335028653,318267821,316268987,316395978,309954011,308840811,308840745,40413449,57534733,19293453,19275783,2240518,6438962,14860578,283223330,283223874,1424141827,1961008961,1474463489,1449361937,1444971056,1982116385,1982112295,1713693222,1714349614,1852759086,4004366382,3869821166,3869792394,1718249610,1630153866,1630143370,1613365930,1625821865,3769111208,3769115304,2712168297,2963861273,2968055305,2959795725,4033561101,2968273429,2427191844,2427387940,2428436516,2428239916,2439775260,2200910860,2185115660,3260430684,3265166046,3332144798,3332171678,1197269406,1279246734,1279181262,1279186894,1279159886,1149136398,369060366,367885830,359419494,1417463270,1413267938,1413251302,1411293394,1415487938,1474208194,3537807170,3537536514,3537405490,3529016099,2463687457,2463654180,2463637796,2480481324,2497254508,2497383676,2493124093,2627362286,2633587198,2624113150,2619973070,2351611343,2368452557,2636685901,2674438781,2683937325,3220873765,3216680231,3220745255,3178794023,3157820471,3023754243,4095373315,4095619395,4095611751,4112323303,4116513511,4160684791,1939216327,1368864711,1351362503,1355556679,281813791,13369613,30277897,47059208,48125192,41833736,41867032,41932600,394049320,368883560,352098281,1433704425,1450476969,1450673561,1182192027,1182724538,1205789098,3302777258,3301794234,3301864846,3297670558,3297666470,3298812390,3315392882,3338445075,3270021888,3261629200,3525879584,3526077728,3542792496,3546979328,4093545728,4093611265,4085024033,3793527072,3793592356,3810426932,3810443300,3775873060,3758882860,3763148061,3763224069,3771607589,2963159589,2962755108,3029861948,3031958028,4139266572,4139397708,4139661007,4142808718,3597409966,1445739950,1983659178,1966871722,1950298250,1954427019,1424969932,1441579100,1466753068,1466753324,1198973212,1138160396,3280384524,3515254302,3498216750,3565526062,3566517294,3570699390,2486605006,2502858126,2502858126,4079912846,4079912591,4063139484,4063164092,4063229628,4062999196,4062982828,4062978476,4067172524,4033623213,4042208421,4037948615,4037948483,3501065219,3504604211,1348740131,1344544803,1093017603,1164325123,1151730946,1286014754,1286434594,3433884962,3434932258,3481053219,3460279297,3728383296,1584304064,1592690304,2130544288,2120004256,1847370401,3993805223,3994988710,1847559398,1715247190,1696983054,1680796174,3828243006,3828237882,3840492073,3836265000,3886563624,3869773880,2800233544,2804427208,3040487851,3178904490,3166570922,3166637498,2627011786,3700695306,3703316746,3384288522,3383239978,3416796462,3379042351,3374843951,3374861519,3374890127,3379146127,3384389007,3382292399,3415977965,3382689325,3382689316,3369967156,3369453108,3359471136,3359470112,3359573024,3359313120,3357215985,3356110019,3419024578,3398071366,3398096134,2324354310,2324356126,2392361326,2409139182,2228791982,2218298030,2218364558,2151330702,2172297358,2481631405,2464907436,2456388540,2452390540,3526210252,3526332956,3543113272,4079794728,4046235688,4037847080,4054767656,3551190028,3551151372,3530163149,3341288366,3342676398,3275625646,3252030566,2176191542,2227051526,3300451334,3316163859,3584599856,3572008224,3572007984,4243164176,4235895808,4246381680,2131464416,1863024800,1863237792,1862431136,1829905056,1842548385,1821444754,1821575826,4236253906,4240452290,3696504386,3562420034,3573416898,3584689090,3584754130,3584635282,3349706194,3349763282,3354123281,3337320464,3328727296,3324525872,3324538656,3593138996,3593139060,3605713876,3618161044,3602433468,3604540588,3604543660,3730438316,3730499756,3732565180,3724174788,3572384759,3571827302,3563307638,3559125590,3559109330,1412539090,1460708818,1442882674,4131437618,4139883575,4141001781,4134710580,4134968636,4148072220,4148086285,4148086285,4047487821,4051550719,4051517935,4059910639,4051465711,4118635999,4118703565,4118703565,1979698653,4110175596,4110183460,4110181396,4101846020,3565106196,3565102100,3564045329,3757966627,3736740450,3736797746,3467190786,3467125266,2393384499,2397579777,2389391872,2250930688,2267798032,2230947364,2224914996,2493285196,2492769224,2626986729,2631176939,3155986090,3158085290,3158088426,2904537850,2938026458,2938038474,2942200970,2950636730,2950309274,2941919626,2908430746,3175690686,3176871358,3160093886,3170514029,3165533244,3182232588,2510578956,2510349580,2544088108,2543891756,2549129709,2538636714,2534462890,2534497706,2534628782,2534562222,2534857710,2507603214,2515985670,2511183879,2511319044,2511310852,2511189012,2515381280,2502540640,3073101729,3073007267,3072990902,3056473750,4151195286,4150736790,4159972774,4159972774,4158661094,4158677319,4158776581,4091673861,1944124695,1935735127,1935760855,3542226422,3512879030,4116857782,4125251574,4120993399,4255144757,2111892277,2095376916,2087578116,2083159556,2083140100,2083131904,2083205937,2083008801,1835544800,1836581040,1876435072,2128343172,1989849244,1721414812,1658494104,1658358088,1677240632,1622842155,1622851370,3773477162,4030431530,4030513466,4028383514,4045275402,4045037834,4059718922,3787122974,3770325294,3770259759,3854080283,3858271177,3883632585,3862598348,3862606476,3862623117,3862655405,3862438053,2792894629,2801337509,2746883477,2982028673,2964203457,2964284227,2964181763,2964321031,3052266759,3043814711,3043814439,3044861991,3220961575,3220884749,3186249485,3177795341,3173535533,3173576045,3177964909,3186544895,3221082334]}

 

Thinking a head for a moment: is it safe to hold this array in a memory stream (in RAM) during a scheduled task? along with  audio streams?

Is it too much data to hold at one time? Perhaps it's better to be stateless, and write and remove files?

Edited by chef
Link to comment
Share on other sites

Have to figure out how to compare many elements in one array, with all the elements in another array... 

XOR conditions?

 

 

 

Edited by chef
Link to comment
Share on other sites

I've been able to create the binary base 2 versions of the fingerprint integers, like what is mentioned in  @TeamB's linked article.

 

IntroTestingFingerPrint.png.f8851047327bcfd6dc1983b3e0a97d45.png

 

Apparently, it is the binary data we need to compare for bit differences (e.g. by counting set bits in the result of xor).

Link to comment
Share on other sites

Yes that is correct, you need to compare the bit stream. But you will also need to take into account varied starting points for the beginning of the theme music, you will probably need to compare the reference bit stream and the episode bit stream using a sliding comparison algorithm like the guy does in his article from above.

@dotcom did your script take into account different starting positions?

I am not sure if you would need to compare each bit offset in your search or if you could just use the 32 bit blocks. One is going to be a lot more expensive than the other.

Link to comment
Share on other sites

 I was trying to get a finger print of audio from two different sources, and attempting to find the intro in them, by looking for similarities in the print.

But, I am having no luck, even when both audio streams are converted to the same wav file type.

when I create the print in raw format (even though both files have the intro music in them) there is no comparison.

...yeah ... I'm lost. Darn! 

 

 

Link to comment
Share on other sites

24 minutes ago, chef said:

 I was trying to get a finger print of audio from two different sources, and attempting to find the intro in them, by looking for similarities in the print.

But, I am having no luck, even when both audio streams are converted to the same wav file type.

when I create the print in raw format (even though both files have the intro music in them) there is no comparison.

...yeah ... I'm lost. Darn! 

 

 

The above article seems to mention that fingerprints are generated based on a mono version of whatever audio track you want to use. Perhaps, mono vs multi-channel could have an effect on the fingerprint itself, if you’re not already trying that.

Though, there’s a number of other things that could cause differences in the generated fingerprint.

  • Like 1
Link to comment
Share on other sites

I have only have a very quick play with this and want to do some more work on it when I get time, not sure when that will be though.

What I did was extract the audio of a theme song using the following, this extracts a 20 second clip from an offset of 30 into the episode, this would become the theme music for a series and would need to be set by a user on one particular episode, they would g=need to set the start and end time for the theme music,  to allow extracting the theme music of the series.

It extracts as a mono 16kHz PCM wav

ffmpeg.exe -i "episode_01.mkv" -ss 00:00:30 -t 00:00:30 -ac 1 -acodec pcm_s16le -ar 16000 -c:v nul theme_music.wav

then feed it to fpcalc.exe to get the theme int array.

fpcalc.exe theme_music.wav -raw

@dotcom pips the data from ffmpeg to fpcalc but I dont know how cross platform that is, if will work on all systems so I just extract the wav and feed it into fpcalc.

You get this:

DURATION=30
FINGERPRINT=518203313,513880977,518009811,249570275,266348387,232793954,216033058,216266002,217288962,217157906,485527858,485537586,418430770,418626322,502438163,525580595,508689779,1578300881,1578258881,1578259393,1582449637,1523646437,2056322020,2073098596,2043713797,2102565127,3692230919,3694327558,3698520614,3696480806,3713126950,3711988278,3720356382,3716166446,3700453422,3700653165,3700578536,3705030872,3447146696,3476474252,3476483468,3476485581,3480732127,3447046526,3430281582,3425788262,3425854454,3425853762,3427938626,3436380610,3297788387,3297792481,3297829344,3302094816,3306391536,3325202368,3325210560,3593645892,3593702725,3597961591,3596921319,3596938734,3597590014,3614332319,3581280671,3581346751,3589608431,3589616613,3588563829,3588564309,3580110101,3580114213,1567890727,1567956277,1576222533,1576153031,1576152775,1299390403,1292911971,1276138851,1276142626,1544614962,475067410,475247890,1574151442,2110957330,2144515603,2126939651,2126939973,2059830725,2051321317,2047126767,2047143150,2047114478,2064020842,2035184942,2023642415,2023638877,2023706444,2027708108,1495035612,1511845564,1511978908,1511977357,2053030365,2060829053,2077549933,2035606845,2018960669,4233544991,3696674111,3713390390,4250269542,4282775014,4282701286,4291098094,4291098030,4186437118,4253446623,4258165197,4259254748,4233892220,2082280828,2082414056,2082413032,1549605353,3697031641,3705416137,3721145609,3486332169,3487437577,2392806205,2260521773,2258428205,2258411837,2258477359,2257424815,2257354927,2261549230,2187100350,2182841534,2535103679,2503654815,2503916495,3040783949,3040783881,3040847368,2771165961,3844973321,3849253689,3849769769,3828761129,3828680248,3845471768,3879025464,3875289384,3802925160,3802926249,1655443594,1911304330,1881936014,808321178,808321454,808336302,820910766,833563270,850144902,313320079,313304015,1387041567,1919713583,1936504107,1634577195,3782126382,3773737518,3765348894,3845039630,2771288590,2804908558,2804196143,2804196141,2938429741,2921714988,2922760236,2922760556,2943703421,2952224125,2952156511,2952164303,2918671311,2910151167,2910066159,2889620719,2893876718,2919108094,4021968862,4005195470,4005261007,4009308111,4000853453,4000871676,4000847100,4000911612,1868181708,1868177484,2138977356,2147355692,2126449965,2126466863,2126347806,4273794654,4286377567,4248566351,4248488525,3699035717,3716140549,3724408341,4294764069,3204212261,3203753509,3203683621

Once you have the Chromaprint data for the theme music you can store this and use it to do all the episode processing.

Then you would need to process each episode, say the first 3 to 5 min to get the int arrays. Then do the search for the above theme Chromaprint in the data using a sliding search algorithm. You would probably need to use a similarity threshold as there will be slight differences in each episode due to encoding (even though Chromaprint is designed to handel this there will still be differences).

In my head that is how I would do it but as I said I have not really started yet, just some thoughts until I get time to have a play.

  • Like 1
Link to comment
Share on other sites

here is a very good example of an offset comparison between two chromaprints

https://acoustid.org/fingerprint/26931382/compare/13214169

as you move (delay) the second chromaprint you see it eventually lines up and gives you a mostly black third bar, this is the difference and if it was perfect then would be ALL black with no differences but as you can see when when it mostly lines up at about -5 offset there are still differences in the two but that offset is the most likely start offset for the second audio stream.

What you would need to do is create an algorithum to "align" the themem chromaprint with the one extracted from the episode.

This has already been done 🙂 mostly, the example form the original skip blog post has a solutioin, I dont know how well it works but here it is in GO

https://github.com/VictorBitca/matcher/blob/02383434a966fff7cd26656f0939b995da1f8d00/match.go#L127

  • Like 1
Link to comment
Share on other sites

Edit: I posted this before reading your previous post and link... 

To test it out, I hard coded two mono wav finger prints from two episodes (each five minutes long)

The first episode had the intro right at the beginning of the show.

The second had a quick two and a half minute episode recap, followed by the intro.

public static uint[] ThemeSongAtBeginningOfStream =
        {
            640612389, 644803604, 654275588, 671085588, 905933828, 897537029, 876563461, 892816445, 1027034477,
            1060593007, 1062698861, 1054342781, 798359133, 798341887, 766876639, 754817999, 745380815, 1814929102,
            1815084790, 2083520230, 2100248294, 2133671655, 2121023079, 2121018983, 1860969825, 1860973585, 2125415425,
            1068194817, 1034607621, 1034614789, 1030486085, 1026291781, 1026291797, 1026284645, 1060756581, 1065344365,
            1073741677, 801103725, 766369629, 703463245, 946732367, 946732367, 942627966, 959396974, 992951406,
            997014894, 980237166, 984562303, 984554079, 984571471, 1001225805, 1000931149, 434765125, 426376277,
            426507509, 422305015, 422141175, 422271463, 460028390, 468417510, 1005288166, 1069153014, 1034549958,
            904526470, 300546966, 283769238, 275347862, 807999894, 809057207, 809183911, 813378215, 821766822,
            278732470, 278666902, 278675158, 278413174, 9992502, 1100544318, 1201192254, 1186510140, 1186501436,
            3468403516, 3468337688, 3489374744, 3388707352, 3363550744, 1213983288, 1212934699, 1225390954, 1258866794,
            1511639166, 438290510, 507429966, 507412558, 372146254, 372150350, 372150358, 372215911, 506303587,
            1059970146, 1059970530, 963500518, 963631590, 963640806, 963509750, 963476830, 963476830, 971767662,
            971767790, 971763694, 972647391, 972680141, 972679644, 970582460, 970582440, 962193852, 962166684,
            962289564, 962322172, 970587756, 970583597, 970845759, 1004404254, 1004396318, 996007230, 996011070,
            957344798, 957336590, 957336654, 958385502, 945786238, 954179439, 684584959, 676130767, 944631695,
            944766399, 1028607151, 1062014127, 906767535, 906833071, 911158695, 919478182, 865013430, 832523910,
            832425670, 832359942, 838633734, 905484342, 896052263, 930653220, 897310772, 1031467060, 1031422268,
            1029329448, 433746472, 429620776, 429472280, 429419098, 433613422, 425228654, 421251198, 456838222,
            440123470, 440057934, 440320078, 444518486, 444592246, 444462307, 1065213155, 1064160503, 896391607,
            897448359, 897579943, 838859455, 838729406, 821952158, 821681822, 821682078, 813292958, 813301182,
            813297143, 830074223, 828996911, 862481711, 845770031, 845770047, 845888783, 845831950, 862670366,
            938200622, 900451902, 883547678, 883556110, 887684358, 1425660950, 1425660982, 1572467750, 2147083303,
            2147085357, 2071551293, 1533758845, 1529564157, 1500204031, 1500216286, 1500195662, 1508585230, 1508605727,
            1504280380, 1504280364, 1541961532, 1533604636, 1533670220, 1534849864, 1534841688, 1509556216, 1507388137,
            1498999791, 1478224894, 1480248286, 423250910, 427511774, 460920799, 444278605, 444216652, 442119444,
            442176564, 442053684, 444163124, 452556085, 469490997, 536464725, 501843271, 493454535, 493454551,
            472761599, 472896767, 472897007, 477101479, 477101991, 485228279, 485097174, 485097158, 485227158,
            485223062, 481028759, 1554743223, 1554609589, 1558786453, 1559044244, 1550660020, 1550275492, 2095576804,
            2096492068, 2096425508, 2096409140, 2088020500, 2099637772, 4247181068, 4284924237, 4286038511, 4294173166,
            4260618734, 4258506606, 3990073150, 3989879614, 4023433534, 3998263326, 2920590351, 2920787983, 2920730639,
            2786480495, 2786464495, 2786984623, 2793341615, 2818383535, 3787263935, 4037872063, 4037877659, 4038934411,
            4038862475, 4059834251, 3546047899, 1398595771, 1396461803, 1396457723, 1362038795, 1345196299, 1349399050,
            1353589274, 1420784186, 1420685882, 3568105259, 3569139001, 3564411160, 3577658120, 3577653768, 3576605192,
            3610238476, 3597420060, 3739750943, 3739816762, 3739877482, 3731357934, 2657632494, 2654486638, 3732526158,
            3757614286, 3753411983, 3753482125, 3753485997, 3751522221, 2681958313, 2673564585, 2400918443, 2400918507,
            2369658670, 2356024074, 2230125322, 3299615498, 3299610922, 3299365162, 3299393579, 3437815033, 3426274440,
            3443034248, 3443100040, 3745159560, 3745429896, 3728124296, 3732318680, 3604067832, 4136673561, 4138763067,
            4277379882, 4267877162, 3190006574, 2938540334, 2904982830, 2888731678, 2892942350, 2892986446, 3158060239,
            3158060191, 3023973551, 3023439279, 3077910959, 3065455551, 3064406687, 4138148494, 4138033870, 4154778318,
            2506417790, 3492062847, 3492726607, 3492734411, 3492562281, 3496543593, 3505075305, 3505333625, 3505333512,
            3505335304, 3505224761, 3505183789, 3505183805, 3521944909, 3513759181, 3513750407, 3580789639, 3577119621,
            3614868437, 4150691617, 4133918497, 3060049696, 3194267440, 3194791713, 4285392417, 4285527603, 4264252963,
            4264101474, 4265084898, 4265091490, 4269285538, 4275765426, 4141745286, 4120777862, 4103484550, 3566677390,
            3568776590, 3568328622, 3568357294, 3568365547, 3572620619, 2498821385, 2507210521, 2539714360, 2548168504,
            2548552508, 2548470332, 2540082732, 2674234924, 2640676396, 3187062284, 3187060492, 3180825980, 3185348077,
            3210517741, 3189544173, 3055400191, 3055023615, 2805363183, 2805354991, 2775974846, 2783385502, 2783393182,
            2984519102, 2968794542, 2968589758, 4038267278, 4038275470, 4038140302, 4038074878, 3521130879, 1365275967,
            1399190557, 1462236173, 1445456908, 1445979144, 1445977112, 1445977112, 1596968216, 1550829369, 1550802490,
            3639481882, 3639489034, 3634890250, 3634890346, 3652728746, 3667599534, 3666550942, 3397910669, 3465035916,
            3469263000, 3460878568, 3457995112, 3458136872, 3745442328, 3711347224, 3723930171, 3719802394, 1572111882,
            1576846026, 1551680154, 1547323066, 1413099194, 1413099434, 1412048297, 1412046984, 1349189768, 1375273096,
            297271481, 330834093, 335028653, 318267821, 316268987, 316395978, 309954011, 308840811, 308840745, 40413449,
            57534733, 19293453, 19275783, 2240518, 6438962, 14860578, 283223330, 283223874, 1424141827, 1961008961,
            1474463489, 1449361937, 1444971056, 1982116385, 1982112295, 1713693222, 1714349614, 1852759086, 4004366382,
            3869821166, 3869792394, 1718249610, 1630153866, 1630143370, 1613365930, 1625821865, 3769111208, 3769115304,
            2712168297, 2963861273, 2968055305, 2959795725, 4033561101, 2968273429, 2427191844, 2427387940, 2428436516,
            2428239916, 2439775260, 2200910860, 2185115660, 3260430684, 3265166046, 3332144798, 3332171678, 1197269406,
            1279246734, 1279181262, 1279186894, 1279159886, 1149136398, 369060366, 367885830, 359419494, 1417463270,
            1413267938, 1413251302, 1411293394, 1415487938, 1474208194, 3537807170, 3537536514, 3537405490, 3529016099,
            2463687457, 2463654180, 2463637796, 2480481324, 2497254508, 2497383676, 2493124093, 2627362286, 2633587198,
            2624113150, 2619973070, 2351611343, 2368452557, 2636685901, 2674438781, 2683937325, 3220873765, 3216680231,
            3220745255, 3178794023, 3157820471, 3023754243, 4095373315, 4095619395, 4095611751, 4112323303, 4116513511,
            4160684791, 1939216327, 1368864711, 1351362503, 1355556679, 281813791, 13369613, 30277897, 47059208,
            48125192, 41833736, 41867032, 41932600, 394049320, 368883560, 352098281, 1433704425, 1450476969, 1450673561,
            1182192027, 1182724538, 1205789098, 3302777258, 3301794234, 3301864846, 3297670558, 3297666470, 3298812390,
            3315392882, 3338445075, 3270021888, 3261629200, 3525879584, 3526077728, 3542792496, 3546979328, 4093545728,
            4093611265, 4085024033, 3793527072, 3793592356, 3810426932, 3810443300, 3775873060, 3758882860, 3763148061,
            3763224069, 3771607589, 2963159589, 2962755108, 3029861948, 3031958028, 4139266572, 4139397708, 4139661007,
            4142808718, 3597409966, 1445739950, 1983659178, 1966871722, 1950298250, 1954427019, 1424969932, 1441579100,
            1466753068, 1466753324, 1198973212, 1138160396, 3280384524, 3515254302, 3498216750, 3565526062, 3566517294,
            3570699390, 2486605006, 2502858126, 2502858126, 4079912846, 4079912591, 4063139484, 4063164092, 4063229628,
            4062999196, 4062982828, 4062978476, 4067172524, 4033623213, 4042208421, 4037948615, 4037948483, 3501065219,
            3504604211, 1348740131, 1344544803, 1093017603, 1164325123, 1151730946, 1286014754, 1286434594, 3433884962,
            3434932258, 3481053219, 3460279297, 3728383296, 1584304064, 1592690304, 2130544288, 2120004256, 1847370401,
            3993805223, 3994988710, 1847559398, 1715247190, 1696983054, 1680796174, 3828243006, 3828237882, 3840492073,
            3836265000, 3886563624, 3869773880, 2800233544, 2804427208, 3040487851, 3178904490, 3166570922, 3166637498,
            2627011786, 3700695306, 3703316746, 3384288522, 3383239978, 3416796462, 3379042351, 3374843951, 3374861519,
            3374890127, 3379146127, 3384389007, 3382292399, 3415977965, 3382689325, 3382689316, 3369967156, 3369453108,
            3359471136, 3359470112, 3359573024, 3359313120, 3357215985, 3356110019, 3419024578, 3398071366, 3398096134,
            2324354310, 2324356126, 2392361326, 2409139182, 2228791982, 2218298030, 2218364558, 2151330702, 2172297358,
            2481631405, 2464907436, 2456388540, 2452390540, 3526210252, 3526332956, 3543113272, 4079794728, 4046235688,
            4037847080, 4054767656, 3551190028, 3551151372, 3530163149, 3341288366, 3342676398, 3275625646, 3252030566,
            2176191542, 2227051526, 3300451334, 3316163859, 3584599856, 3572008224, 3572007984, 4243164176, 4235895808,
            4246381680, 2131464416, 1863024800, 1863237792, 1862431136, 1829905056, 1842548385, 1821444754, 1821575826,
            4236253906, 4240452290, 3696504386, 3562420034, 3573416898, 3584689090, 3584754130, 3584635282, 3349706194,
            3349763282, 3354123281, 3337320464, 3328727296, 3324525872, 3324538656, 3593138996, 3593139060, 3605713876,
            3618161044, 3602433468, 3604540588, 3604543660, 3730438316, 3730499756, 3732565180, 3724174788, 3572384759,
            3571827302, 3563307638, 3559125590, 3559109330, 1412539090, 1443931602, 1442882674, 4131437618, 4139883575,
            4141001781, 4134710580, 4134968636, 4148072220, 4148086285, 4148086285, 4047487821, 4051550719, 4051517935,
            4059910639, 4051465711, 4118635999, 4118703565, 4118703565, 1979698653, 4110175596, 4110183460, 4110181396,
            4101846020, 3565106196, 3565102100, 3564045329, 3757966627, 3736740450, 3736797746, 3467190786, 3467125266,
            2393384499, 2397579777, 2389391872, 2250930688, 2267798032, 2230947364, 2224914996, 2493285196, 2492769224,
            2626986729, 2631176939, 3155986090, 3158085290, 3158088426, 2904537850, 2938026458, 2938038474, 2942200970,
            2950636730, 2950309274, 2941919626, 2908430746, 3175690686, 3176871358, 3160093886, 3170514029, 3165533244,
            3182232588, 2510578956, 2510349580, 2544088364, 2543891756, 2549129709, 2538636714, 2534462890, 2534497706,
            2534628782, 2534562222, 2534857710, 2507603214, 2515985670, 2511183879, 2511319044, 2511310852, 2511189012,
            2515381280, 2502540640, 3073101729, 3073007267, 3072990902, 3056473750, 4151195286, 4150736790, 4159972774,
            4159972774, 4158661094, 4158677319, 4158776581, 4091673861, 1944124695, 1935735127, 1935760855, 3542226422,
            3512879030, 4116857782, 4125251574, 4120993399, 4255144757, 2111892277, 2095376916, 2087578116, 2083159556,
            2083140100, 2083131904, 2083205937, 2083008801, 1835544800, 1836581040, 1876435072, 2128343172, 1989849244,
            1721414812, 1658494104, 1658358088, 1677240632, 1622842155, 1622851370, 3773477162, 4030431530, 4030513466,
            4028383514, 4045275402, 4045037834, 4059718922, 3787122974, 3770325294, 3770259759, 3854080283, 3858271177,
            3883632585, 3862598348, 3862606476, 3862623117, 3862655405, 3862438053, 2792894629, 2801337509, 2746883477,
            2982028673, 2964203457, 2964284227, 2964181763, 2964321031, 3052266759, 3043814711, 3043814439, 3044861991,
            3220961575, 3220884749, 3186249485, 3177795341, 3173535533, 3173576045, 3177964909, 3186544895, 3221082334
        };

        public static uint[] ThemeSongAfterRecap =
        {
            3563781110, 3572136566, 2499423862, 2511879734, 2543335159, 2543335167, 2663920639, 3754693631, 3721134525,
            3704554684, 3705551036, 3696699580, 1544824988, 1561602204, 1594961036, 1326592397, 1293030086, 1280459330,
            1280373298, 1290855202, 1290839330, 1286847794, 1286846738, 1285994755, 3467025667, 3471742275, 3463087043,
            3463025395, 3731469025, 3598231140, 3598233124, 4133005852, 4067998236, 4067989820, 1916451060, 1916468372,
            1916421253, 1916420231, 1663697046, 556417190, 544129510, 548323622, 548257814, 564944903, 858006533,
            925117445, 925187109, 891685413, 1022237221, 482216535, 415108806, 414914242, 213464642, 212365826,
            1287172371, 1287172400, 1285074208, 1339599136, 3466246400, 3734669888, 3602812608, 3602744048, 3604775651,
            3067917286, 3050090726, 3033313510, 3024938214, 3020810418, 3155060866, 3155061635, 3171839617, 3204863616,
            3192324736, 3200516752, 3200525200, 2663653616, 2664703013, 2666937381, 2665883703, 2662217782, 2393839670,
            2393576758, 2326266134, 2343043854, 2348307230, 2314982170, 2296050459, 2287543609, 2283285800, 2283280744,
            2285459928, 2373639048, 2678766216, 2527628937, 2527628971, 2523694762, 2519499450, 2537394826, 2501882506,
            2485117626, 2487181998, 2486116974, 2423062822, 3500737574, 4037618726, 3517655094, 3551148055, 1407858693,
            1391074308, 1382754052, 309932636, 305738076, 306123228, 306119853, 303307945, 860891307, 868223419,
            868338073, 868337033, 834912584, 826536200, 288465192, 270639400, 337748264, 274960696, 6393112, 14781208,
            82152220, 94735133, 111642910, 115785030, 107388998, 102932558, 104050942, 121016718, 91664782, 351714694,
            347507077, 351641013, 343194797, 890545325, 1964286127, 1964421370, 1964392667, 1949708779, 1950163433,
            3699189608, 3703449128, 3703440940, 3703375388, 3703322380, 3702268172, 3433308175, 1290022942, 1282802990,
            1278627374, 1293307518, 1595334350, 1578548942, 1582601935, 2115278559, 2115285743, 1846850559, 1847439855,
            1846387949, 1847440620, 1864335468, 2099134540, 2099126348, 4229832812, 4229308516, 4241888748, 4237690605,
            4237756158, 4254406366, 3717478094, 3583268558, 3587491406, 3579287054, 3577064991, 3576999213, 3610295341,
            4147156029, 1999671310, 1999736846, 1999732814, 3878850798, 3878859951, 3845295295, 3844263309, 3844529805,
            3848566413, 1744069294, 1744052974, 1744114410, 1698436074, 1698181226, 1684546666, 1688943658, 1689140250,
            1689136202, 1958700111, 1975379789, 1976939215, 1473741519, 1465090558, 2000929002, 1996775658, 1996759275,
            1996825723, 927348025, 931534648, 897978168, 882712088, 886367752, 1951704840, 1949611272, 1681233224,
            662012888, 651461336, 575967961, 571773659, 638972587, 1712730794, 1729509290, 1729510890, 1742093547,
            1737954539, 1737831883, 2006721354, 2006737418, 2010960410, 1968755242, 1977148266, 1960371306, 1972954218,
            4254703851, 4288323721, 4274697352, 3591279768, 3591212520, 3591360232, 3595501272, 3594972760, 3603424792,
            3621250616, 4158120745, 4155887914, 4155818026, 4156342314, 4125983790, 3560817726, 3493612614, 1344027846,
            1344017602, 1344143490, 337510546, 886452659, 882254480, 898966148, 379414212, 381542084, 318623556,
            309890076, 309916716, 305718312, 322445352, 339222825, 343553595, 1425686058, 1421770346, 1419771498,
            1469368010, 1456785290, 370459018, 236377482, 236344730, 504768446, 437658542, 458630078, 156377982,
            139666234, 166797611, 183513384, 183788584, 183823400, 181708856, 1255447560, 1233564680, 1217306888,
            1218351368, 1218347848, 1285473147, 1284818794, 1279307562, 1275104810, 1560514138, 1560457034, 1560520522,
            1560389066, 486576586, 520192970, 486785786, 487015146, 486998750, 470160222, 471208318, 483795055,
            479601885, 479618253, 481746060, 498584964, 531991957, 519341237, 510980277, 376729765, 393486511,
            391328238, 124920686, 1173496366, 1156720183, 1156656645, 1156591108, 1151345932, 1152415004, 1169179676,
            1186382860, 1185334540, 1185330956, 1185331005, 1190507311, 3325342507, 3325330283, 1175753339, 1192735435,
            1142335179, 1146531531, 1151256266, 1151091434, 1167913450, 1406984426, 1377628394, 1428091038, 1411310734,
            1411312782, 1411303566, 1417119918, 1421191662, 3702829039, 3700729583, 3717526269, 3755786877, 3738980925,
            3755942461, 3751748141, 1574773551, 1557995822, 1549607982, 1547508782, 1547635770, 1546984522, 1282686154,
            1299504586, 1441891722, 1475577243, 1454478235, 1454486427, 1454412701, 1454477804, 3606294892, 3593708332,
            4264796972, 4281590300, 2100437516, 2100434748, 2113279276, 2108961839, 2140410926, 2127823934, 1584857162,
            1517682762, 1517695306, 450241098, 446523098, 446490362, 446490331, 446217945, 467437304, 425494456,
            1545580952, 1545511304, 1544991129, 1543943673, 1543878121, 1564780008, 1564865848, 1599521032, 1599488776,
            1442206232, 1442260732, 1442653885, 1436362430, 1469388206, 1406468526, 1381318830, 1381449918, 1127661710,
            1093071118, 1147660046, 1147465230, 1147956798, 1164715838, 1181553982, 1190002734, 1185546302, 1319764030,
            1320693790, 1308110942, 215549403, 207234777, 207234776, 207300312, 207107800, 209458936, 222038008,
            171390456, 171406840, 170947688, 168874024, 173068601, 181661978, 181637402, 198415130, 1222022922,
            1220975114, 1220975162, 1216654186, 1216653802, 3364659706, 3381506186, 3415965833, 3485040824, 3479732396,
            3475542188, 3442208940, 3425329644, 3426362876, 1211770200, 1295662920, 1295916888, 1300105945, 125246106,
            133971610, 261889690, 261883578, 249299897, 240915368, 236741048, 236773880, 1310040344, 1160224824,
            1143177256, 1424195880, 1420007196, 1420013085, 3567298110, 3568345646, 3696341550, 3692249646, 3742499390,
            1446380042, 1445869322, 1458518106, 1454123114, 3605866731, 3597023433, 3462744264, 3458499720, 3458498952,
            1315230712, 3468096488, 3468092264, 3468075883, 3468599658, 3451707754, 3429684714, 3425488366, 1279106526,
            1547632014, 1411313550, 1411313550, 873396109, 923719564, 907982220, 911647884, 911582397, 919901423,
            852788334, 1928627262, 1400280126, 1400283182, 1362485286, 1362382902, 1362497822, 1375605758, 1404982943,
            4089368220, 4089039492, 4088978076, 4092133052, 4083733164, 4050170536, 4029276728, 1881760296, 1881678377,
            1881940539, 1881941547, 1882011945, 1890453545, 1889929257, 1889945609, 1972866249, 1435870345, 1473556617,
            1448915131, 1448915115, 1985982634, 1985922026, 1988023914, 1971217963, 1962878491, 2088509705, 1551638536,
            1546919992, 1546989624, 1597379384, 1582707256, 1586635288, 1586508360, 1586501321, 1586513802, 1167279530,
            1154635178, 1146279866, 1414723226, 1410705098, 1410643658, 1410635594, 1966445898, 2000068699, 1987485789,
            1982312573, 1982169213, 1916059897, 1916031225, 1932924907, 1943420650, 2006334190, 4120723182, 3583780558,
            3617334218, 3739033930, 3739157258, 3738833434, 1593456187, 1589194281, 1589133097, 1610096425, 1551381817,
            1551462728, 1551552968, 1551548872, 1547216872, 1547216872, 1547215848, 1562096345, 1595572939, 1600094922,
            1465750266, 1476190954, 1476196330, 1605912554, 1604996458, 1571437945, 1575628040, 1551443208, 1551639576,
            473772088, 471793688, 471204104, 475398408, 215363865, 215033689, 214972251, 231736667, 223364443,
            257148251, 259233115, 535926139, 519157114, 1056028154, 1056030202, 779205882, 779336954, 775140602,
            1848873210, 1848873179, 1848815705, 3996299384, 4013336428, 3963022956, 3967217260, 2767670892, 2784838236,
            2809926220, 2805736140, 2809930735, 2818322670, 2813067502, 2779448558, 2762874106, 3837672666, 3841865930,
            4110232651, 4110183753, 4127127368, 4156483096, 4143965704, 4135384584, 4131182105, 2117981547, 2139047022,
            2105426046, 2105421918, 2088640718, 2084450782, 2086343678, 2102924271, 2110272493, 2089318361, 2089512393,
            2093640009, 1556801803, 1574694170, 1608250682, 1591316858, 3738747226, 3730358618, 3747205626, 3712738810,
            3695962090, 3637211115, 3637194751, 3637067134, 3638107454, 3378318654, 2405371198, 2321489182, 2329347342,
            2325156126, 2325553430, 2325553462, 2325557558, 2325492006, 2327335270, 2348336613, 2313733524, 2297156500,
            3362444220, 3362509244, 3358447028, 3358391700, 3358390676, 1212017044, 1210050964, 1208936852, 1208921476,
            1536075140, 445296772, 445288580, 180978132, 1243124516, 1245247020, 1228537388, 1278994972, 1547414028,
            1551473468, 1572375852, 2126023788, 4271473871, 4204429454, 4204433558, 4200181990, 4195909734, 4212899878,
            4162465798, 4162461958, 4162462983, 4166655781, 4170911332, 4170714852, 4187502532, 2072519620, 1535926732,
            1498312908, 1494090957, 1494093183, 1478302062, 1482500974, 1482501742, 1507597950, 1541162590, 1523368782,
            1523355918, 1523360014, 1255121159, 1255059463, 1246662679, 1229901847, 1209943110, 1208880342, 1212747190,
            1221148582, 3364368038, 3364384422, 3364411030, 3382228679, 3654853317, 2581111764, 2581312372, 2581247844,
            2581173796, 2572727844, 2602083876, 2585458228, 2587514423, 2587510334, 2608418158, 2650283110, 2629306598,
            2629520534, 2629522566, 2629361794, 2631426435, 3625525889, 3642438336, 3407491649, 3409587985, 1245325619,
            1248462898, 1256917010, 1257846786, 1257776130, 1255694338, 1255858243, 1255833793, 1255833728, 1239122320,
            1224445872, 1224321696, 1222228644, 1222171364, 1238952549, 1247308327, 1243377462, 1243562262, 3390984470,
            3390992438, 3394842678, 3410501910, 3368689926, 3364492098, 3364488023, 3364439013, 3365435364, 3365466092,
            2312677868, 2346228188, 2346359757, 3415911375, 3420106655, 3648554415, 2635628974, 2635694527, 3743068319,
            3742016909, 4245415325, 4245350309, 4249535140, 4257923748, 4259009204, 4292371196, 4286079869, 4285031789,
            4264062061, 4264095021, 4285201695, 4286242062, 4261072654, 4242130702, 4233643838, 4235809598, 4244206142,
            4244203374, 4256769519, 4256706045, 4254678204, 4191882428, 4183494044, 3648656844, 1484404044, 1484469084,
            1501114653, 1501376798, 1501393182, 1501164830, 1482224958, 1482222894, 1490611518, 1490582814, 1486584846,
            1502237709, 1535788156, 1535788284, 1539982556, 1514882492, 1510561724, 1578760108, 1578690237, 1578692287,
            1594421150, 1560870806, 1560854407, 1562033543, 3615407591, 3623781735, 3601302807, 3601200390, 3332765458,
            2263183922, 2280010290, 2279748130, 2279813926, 2258915622, 2260006189, 2528435501, 2532612364, 2541062412,
            2503444932, 2486603156, 2487138196, 3560880013, 3560735373, 3558638525, 3042874348, 3078021500, 3069633852,
            3069568300, 3203724588, 2683594536, 2675713592, 3715966584, 3716027993, 3716026330, 3758034426, 3757591658,
            3739767850, 3739808794, 3731465290, 3744113742, 3710559310, 3699024974, 3699090918, 3698975719, 3705656055,
            3707650677, 3699245621, 3565097765, 3564908836, 3564907820, 2491230508, 2499746108, 2497649468, 2514246200,
            2545741384, 3736920712, 3734536841, 3600319130, 2525529002, 2525791658, 2521611434, 2518006970, 2534846667,
            3073810633, 3061227720, 4143359164, 4071992493, 4069846190, 4065604782, 4061409454, 4063560110, 4063101870,
            4079907582, 1911481870, 1638902286, 1621928207, 1638705165, 1638447116, 1667799052, 1730842637, 1730842637,
            1730854967, 1866092583, 1832460582, 1815687974, 1819869734, 1827276399, 1688866511, 1957300941, 1974078090,
            1437145738, 1470905034, 1168911050, 1302600186, 1285830778, 1285831774, 1286893646, 1286922318, 1284813023,
            1321054700, 1320858532, 1316594596, 3458761648, 3458963344, 3594174384, 3594168756, 3558386084, 4095257524,
            4105935516, 4104846989, 3567940253, 3567997613, 4100735597, 3022840109, 3039593517, 3077539900, 2813310988,
            2796402701
        };

My expectation was that at some point in both prints, despite the 'recap' of the episode, we would see some similarities when the intro started.

I tested it as follows (not my favorite to foreach loop together like this... but it's quick and dirty just to see):

        public static void ListTest()
        {
            foreach (var item in ThemeSongAtBeginningOfStream)
            {                
                foreach (var compareItem in ThemeSongAfterRecap)
                {
		if(compareItem == item) {
                    	Console.WriteLine(item);
				}
                    Console.WriteLine(item ^ compareItem); //Try an XOR just to see if it is zero or true....
                }
            }
            Console.WriteLine("Complete...");
        }

 

The outcome skips directly to "Complete...".

I look forward to hearing about what you guys find. 

Edited by chef
Link to comment
Share on other sites

Are you expecting the int bits to xor exactly i.e. with no differences?
I dont think that is going to work, as I said there will still be differences but they will be smaller where the overlap is.
See the comparison tool I linked above, even when the two audio stream are at their best match there are still differences.

The code example I linked tries to give a best match score for each overlap and then picks the best one. You would need to do something like that.

Link to comment
Share on other sites

In my testing with a quick and dirty Python script I threw together and two episodes of Adventure Time (because the intro always starts at the beginning), I am able to compare two fingerprints and see some similarities in the beginning of the file. In fact, between two episodes of that show, I always see the similarities end at the same place.

However, I still need to see what kind of result I get if I compare episodes from two entirely different shows, and also two episodes from a show that doesn’t always start the intro in the same position.

Finally, as @TeamB states, it’s likely that the bits won’t always match entirely (even between episodes of the same show), so there will need to be compensation for that.

Edited by samuelqwe
Link to comment
Share on other sites

Also just a not on bit wise comparisons, you can not look at the INT and expect them to be similar i.e. close in magnitude.

I know you may already know this but will just say it anyway.

Example:

1 Bit difference, same order of DIFFERENCE but very big difference in INT magnitude

3563781110
11010100011010101111101111110110

3563781108
11010100011010101111101111110100

INT diff = 2

vs

3563781110
11010100011010101111101111110110

3295345654
11000100011010101111101111110110

INT diff = 268435456

You really need to look at the binary stream to compare

 

  • Like 1
Link to comment
Share on other sites

I had a little time today to play with this.

I extracted some wav files

extract to 10 seconds for theme and 2 min of the episode to compare

ffmpeg.exe -i "movie.mkv" -ss 00:00:10 -t 00:00:20 -ac 1 -acodec pcm_s16le -ar 16000 -c:v nul series_theme.wav
ffmpeg.exe -i "movie.mkv" -t 00:02:00 -ac 1 -acodec pcm_s16le -ar 16000 -c:v nul episode.wav

fpcalc.exe series_theme.wav -raw -json > series_theme.json
fpcalc.exe episode.wav -raw -json > episode.json

this gave me two json files to play with.

then used the following python to slide a comparison along the two dat asets to find the min diff point

import json

with open("series_theme.json") as f:
    theme_chromaprint = json.load(f)

with open("episode.json") as f:
    episode_chromaprint = json.load(f)

def count_bit_diff(left, right):
    count = 0
    for i in range(0, 32):
        if ((left >> i) & 1) != ((right >> i) & 1):
            count = count + 1
    return count

# find offset
theme_fingerprint = theme_chromaprint["fingerprint"]
episode_fingerprint = episode_chromaprint["fingerprint"]

episode_offset = 0
scores = []

for index_offset in range(0, len(episode_fingerprint) - len(theme_fingerprint) + 1):
    index_score = 0
    for index in range(0, len(theme_fingerprint)):

        epp_int = episode_fingerprint[index + index_offset]
        theme_int = theme_fingerprint[index]
        this_score = count_bit_diff(epp_int, theme_int)
        index_score += this_score

    scores.append(index_score)


print (scores)

min_score = -1
min_score_at = 0
for index in range(0, len(scores)):
    score = scores[index]
    if min_score == -1 or score < min_score:
        min_score = score
        min_score_at = index
print("Min Score : %s at %s" % (min_score, min_score_at))

ended up with

image.png.ae68479cf09ddad299b0d68cb6cf4ec1.png

With a very nice dip in differences at the point I expected 🙂

Here is the dip zoomed in

image.png.a8299f29fdf12dfdbaebd6c15621b2d0.png

so there are a number of data points around the min which shows there is a reasonable amount of tolerance to the chromaprint calculation per int

 

Edited by TeamB
  • Like 3
Link to comment
Share on other sites

The smaller the offset the closer the match. Got it!

I will try to write the same type of function in c#...  

Link to comment
Share on other sites

Okay, I think I have converted this properly into c#, and I get some results which seem to score around 19 (right around where the intro must be located in the stream).

Here is some code refactored to c#... 

        public static List<int> scores = new List<int>();
  
        public static int count_bit_diff(uint left, uint right) 
        {
            var count = 0;
            foreach (var i in Enumerable.Range(0, 32 - 0)) {
                if ((left >> i & 1) != (right >> i & 1)) {
                    count = count + 1;
                }
            }
            return count;
        }
          
        public static void CompareAudioFingerPrint()
        {
            for (var index_offset = 0; index_offset <= (episode_fingerprint.Count() - theme_fingerprint.Count() + 1); index_offset++)
            {
                var index_score = 0;
                for (var index = 0; index <= theme_fingerprint.Count(); index++)
                {
                    try //There is an index outside the bounds of the array error that happens.. I believe it is because some uints are not 32bit
                    {
                        var epp_int = episode_fingerprint[index + index_offset];
                        var theme_int = theme_fingerprint[index];
                        var this_score = count_bit_diff(epp_int, theme_int);
                        index_score += this_score;
                        scores.Add(index_score);
                    }
                    catch { }
                }
            }

            foreach (var score in scores)
            {
                Console.WriteLine(score);
            }

            Console.WriteLine("Complete...");
        }

 

This reads out all the differences in the scores list, and some do drop as low as 19, which I would consider to be around where the intro starts.

Forgive me for using your python codes exact name structure, I wanted to read it and try to make sense of it all, as I was doing my best to translate to c#.

 

Question: Am I waaaaaaay off here? 

Edited by chef
Link to comment
Share on other sites

I have done it!

After much fiddling with FPCALC and Python, I was able to get functional intro detection between two video files!

I tried the script with a few different shows, but in the example output below I've used two episodes from the show Danny Phantom, because I knew the intro started at different times in this show. You can see in the list of Hamming distances that there is a region of low single digits for a bit (that's where the intro is).

Starting process...

Getting audio tracks from both videos... 50% Done!

Converting audio to .wav format... 50% Done!

Converting audio to mono... 50% Done!

Trimming audio to 5 minutes... 50% Done!

Fingerprinting audio... 50% Done!

Analyzing fingerprints...
The calculated fingerprint offset is -206.0
Done!

Hamming distances:
[9, 14, 14, 12, 16, 21, 14, 17, 19, 15, 13, 14, 11, 13, 15, 16, 15, 15, 12, 16, 20, 16, 13, 15, 13, 12, 14, 16, 19, 20, 19, 23, 19, 16, 16, 15, 11, 13, 18, 20, 16, 12, 13, 14, 15, 16, 13, 16, 17, 15, 17, 16, 18, 19, 15, 18, 15, 19, 17, 13, 14, 14, 13, 17, 17, 17, 16, 17, 15, 16, 15, 12, 12, 13, 18, 14, 14, 12, 17, 19, 15, 16, 14, 15, 19, 19, 19, 18, 13, 15, 14, 17, 15, 15, 17, 16, 13, 14, 13, 18, 20, 19, 16, 15, 14, 13, 16, 15, 16, 15, 16, 17, 21, 14, 15, 13, 15, 12, 10, 11, 16, 16, 20, 14, 14, 18, 21, 19, 15, 11, 13, 17, 15, 18, 17, 12, 13, 15, 12, 12, 9, 14, 15, 16, 18, 17, 14, 14, 12, 14, 15, 14, 15, 12, 14, 16, 9, 13, 17, 13, 12, 11, 16, 12, 14, 19, 21, 17, 17, 17, 15, 15, 16, 15, 17, 16, 12, 13, 15, 17, 15, 14, 13, 15, 16, 14, 14, 16, 15, 13, 13, 16, 9, 12, 10, 14, 15, 9, 10, 13, 13, 14, 13, 10, 10, 12, 15, 13, 15, 17, 20, 22, 18, 15, 15, 15, 13, 10, 14, 13, 16, 15, 10, 7, 9, 9, 13, 15, 16, 13, 13, 13, 10, 13, 15, 14, 13, 13, 12, 19, 14, 16, 14, 13, 15, 14, 14, 17, 18, 13, 15, 18, 12, 10, 17, 16, 15, 22, 21, 19, 15, 13, 11, 14, 18, 17, 17, 16, 15, 13, 16, 15, 15, 18, 16, 17, 13, 13, 16, 19, 21, 19, 17, 17, 17, 21, 19, 17, 14, 17, 17, 16, 20, 15, 15, 16, 17, 18, 17, 17, 21, 19, 14, 16, 16, 16, 16, 18, 16, 17, 12, 10, 14, 14, 20, 13, 13, 17, 15, 13, 11, 12, 15, 17, 19, 16, 17, 15, 17, 18, 21, 21, 22, 19, 18, 17, 16, 15, 19, 19, 16, 20, 16, 14, 16, 15, 15, 20, 19, 18, 19, 18, 20, 18, 16, 16, 15, 14, 16, 18, 18, 18, 17, 15, 16, 16, 17, 15, 16, 22, 18, 17, 15, 15, 18, 21, 19, 20, 16, 15, 15, 13, 15, 13, 12, 11, 15, 12, 17, 13, 17, 16, 20, 15, 14, 16, 15, 15, 16, 15, 18, 15, 17, 15, 15, 16, 17, 21, 21, 18, 14, 15, 16, 15, 17, 22, 19, 19, 24, 19, 14, 22, 15, 17, 15, 13, 20, 19, 11, 11, 10, 13, 14, 14, 14, 15, 13, 16, 14, 16, 13, 15, 14, 16, 16, 14, 16, 17, 19, 14, 13, 17, 18, 18, 17, 17, 15, 19, 19, 18, 14, 10, 16, 19, 17, 20, 20, 21, 19, 15, 18, 18, 20, 16, 13, 13, 16, 19, 18, 18, 21, 18, 13, 15, 14, 18, 20, 19, 19, 17, 14, 17, 16, 16, 16, 20, 18, 16, 14, 14, 16, 13, 14, 17, 22, 20, 18, 16, 18, 12, 14, 18, 19, 17, 20, 17, 16, 16, 16, 13, 16, 12, 16, 18, 16, 11, 9, 10, 15, 12, 13, 14, 17, 11, 13, 14, 11, 10, 7, 11, 13, 14, 11, 9, 11, 18, 18, 17, 11, 13, 13, 13, 15, 12, 13, 14, 19, 16, 14, 10, 13, 11, 12, 15, 8, 17, 16, 18, 13, 10, 11, 11, 17, 13, 14, 17, 18, 20, 17, 16, 14, 19, 17, 13, 18, 18, 19, 12, 15, 17, 16, 15, 14, 15, 13, 15, 16, 13, 15, 16, 14, 13, 12, 10, 14, 17, 15, 10, 10, 7, 10, 15, 14, 13, 17, 15, 12, 14, 15, 14, 15, 15, 15, 12, 15, 15, 14, 18, 16, 12, 12, 15, 18, 15, 14, 18, 18, 19, 17, 18, 16, 12, 14, 20, 22, 18, 21, 18, 15, 16, 13, 14, 14, 16, 17, 15, 15, 16, 17, 18, 18, 18, 18, 16, 18, 18, 19, 22, 18, 16, 18, 17, 16, 19, 17, 19, 21, 18, 18, 19, 12, 11, 9, 17, 19, 17, 14, 14, 7, 11, 12, 15, 16, 20, 18, 18, 16, 16, 16, 17, 19, 19, 18, 20, 17, 16, 15, 14, 12, 14, 16, 12, 17, 13, 15, 15, 14, 13, 13, 12, 16, 15, 15, 19, 18, 18, 16, 16, 19, 18, 18, 19, 19, 16, 17, 19, 15, 14, 12, 14, 15, 17, 16, 17, 18, 19, 18, 14, 14, 15, 15, 17, 17, 15, 14, 13, 20, 16, 16, 15, 12, 8, 12, 16, 11, 11, 15, 16, 18, 21, 17, 17, 16, 17, 11, 12, 13, 17, 18, 18, 16, 14, 16, 14, 15, 10, 16, 15, 14, 12, 13, 15, 12, 15, 17, 17, 18, 22, 14, 15, 17, 17, 18, 17, 14, 20, 21, 19, 18, 15, 15, 14, 15, 15, 16, 16, 15, 14, 19, 19, 17, 16, 19, 18, 18, 15, 16, 19, 21, 20, 23, 19, 16, 14, 11, 14, 16, 17, 17, 14, 11, 12, 14, 11, 13, 12, 11, 12, 14, 18, 16, 15, 13, 16, 13, 14, 10, 9, 8, 12, 8, 10, 8, 6, 10, 10, 7, 13, 15, 13, 14, 16, 17, 13, 19, 15, 15, 16, 16, 17, 17, 15, 14, 13, 13, 12, 15, 14, 17, 18, 17, 19, 18, 20, 18, 12, 16, 15, 15, 13, 9, 11, 11, 12, 17, 14, 17, 19, 15, 16, 14, 13, 14, 13, 15, 21, 19, 18, 17, 15, 12, 19, 18, 19, 18, 13, 14, 13, 20, 22, 20, 18, 14, 14, 14, 17, 13, 17, 17, 15, 13, 14, 19, 16, 16, 16, 17, 12, 11, 12, 13, 13, 11, 13, 13, 17, 19, 15, 14, 17, 13, 14, 13, 13, 14, 19, 18, 23, 20, 19, 18, 19, 17, 19, 15, 15, 15, 14, 17, 18, 19, 18, 16, 13, 10, 6, 5, 1, 0, 0, 2, 1, 3, 3, 1, 2, 0, 2, 1, 2, 1, 0, 1, 3, 1, 0, 1, 1, 1, 2, 1, 0, 3, 1, 2, 1, 3, 3, 2, 1, 1, 2, 2, 3, 1, 4, 1, 2, 0, 1, 1, 2, 1, 0, 2, 3, 3, 2, 2, 1, 3, 2, 4, 3, 7, 5, 5, 6, 6, 2, 3, 5, 5, 6, 4, 1, 2, 6, 2, 4, 2, 3, 1, 2, 3, 2, 1, 3, 4, 2, 4, 4, 1, 3, 4, 2, 3, 4, 2, 1, 1, 4, 2, 3, 4, 2, 2, 2, 5, 4, 8, 3, 5, 7, 5, 4, 7, 5, 7, 8, 10, 6, 5, 6, 5, 6, 5, 5, 11, 5, 7, 4, 4, 5, 4, 2, 2, 3, 5, 5, 5, 5, 3, 4, 5, 1, 2, 2, 2, 1, 4, 5, 5, 0, 2, 4, 1, 2, 5, 4, 2, 2, 4, 5, 2, 4, 7, 2, 2, 3, 4, 3, 3, 2, 3, 3, 5, 6, 3, 6, 4, 4, 1, 2, 2, 3, 7, 7, 7, 6, 5, 1, 4, 1, 3, 2, 2, 3, 4, 4, 5, 5, 5, 8, 3, 3, 6, 5, 5, 3, 3, 8, 9, 5, 3, 3, 6, 7, 4, 7, 6, 5, 2, 3, 5, 5, 5, 4, 3, 4, 8, 6, 9, 7, 3, 6, 4, 6, 7, 6, 7, 4, 3, 7, 5, 1, 2, 6, 2, 2, 5, 6, 4, 8, 8, 4, 4, 6, 2, 5, 2, 5, 6, 5, 6, 3, 4, 7, 6, 4, 4, 3, 4, 3, 5, 2, 5, 1, 4, 5, 4, 4, 2, 2, 1, 2, 5, 3, 3, 2, 3, 6, 2, 5, 3, 2, 3, 7, 5, 2, 6, 4, 5, 6, 6, 5, 7, 3, 6, 7, 2, 6, 3, 4, 5, 6, 5, 4, 6, 7, 5, 4, 3, 2, 2, 5, 4, 3, 6, 4, 5, 4, 6, 3, 2, 5, 5, 5, 3, 3, 2, 1, 2, 3, 6, 4, 5, 2, 3, 2, 1, 3, 2, 1, 3, 5, 0, 4, 6, 4, 5, 9, 6, 6, 9, 7, 13, 11, 8, 11, 14, 11, 11, 10, 10, 9, 11, 11, 9, 9, 6, 13, 12, 7, 10, 11, 10, 10, 9, 7, 10, 9, 7, 5, 7, 9, 9, 11, 12, 11, 8, 14, 18, 16, 16, 14, 13, 17, 15, 12, 11, 10, 13, 10, 13, 16, 14, 16, 18, 18, 14, 14, 17, 15, 15, 14, 11, 13, 13, 14, 18, 15, 16, 15, 17, 18, 14, 14, 16, 17, 13, 14, 14, 15, 16, 12, 15, 16, 12, 18, 16, 19, 19, 14, 14, 16, 16, 19, 19, 18, 18, 17, 22, 19, 21, 17, 14, 15, 13, 16, 18, 17, 19, 17, 16, 14, 13, 15, 18, 14, 12, 14, 12, 13, 17, 16, 19, 17, 15, 18, 17, 13, 10, 9, 8, 14, 12, 15, 18, 11, 11, 15, 11, 7, 13, 10, 17, 17, 17, 15, 9, 14, 13, 12, 13, 17, 19, 20, 18, 18, 15, 17, 15, 18, 13, 14, 16, 12, 13, 16, 18, 16, 17, 13, 19, 11, 14, 14, 12, 11, 10, 13, 12, 9, 15, 16, 18, 14, 20, 20, 20, 16, 12, 18, 16, 14, 17, 13, 13, 14, 14, 10, 12, 13, 15, 18, 18, 14, 12, 13, 14, 13, 14, 13, 9, 11, 14, 17, 23, 18, 17, 16, 18, 20, 17, 14, 14, 12, 13, 12, 12, 9, 11, 12, 14, 15, 16, 15, 12, 16, 14, 11, 14, 12, 10, 10, 20, 21, 18, 12, 14, 13, 10, 13, 14, 13, 9, 16, 10, 9, 11, 15, 13, 16, 11, 13, 14, 17, 17, 12, 13, 11, 18, 16, 14, 13, 15, 13, 15, 13, 14, 20, 13, 16, 16, 19, 19, 19, 17, 19, 16, 16, 14, 17, 15, 15, 14, 14, 14, 15, 12, 11, 15, 18, 10, 13, 18, 15, 16, 17, 14, 17, 17, 21, 19, 16, 18, 12, 13, 13, 12, 20, 19, 14, 16, 14, 16, 16, 14, 16, 16, 13, 14, 14, 17, 18, 23, 15, 19, 17, 15, 12, 17, 19, 15, 16, 20, 14, 14, 21, 19, 17, 17, 12, 13, 13, 14, 16, 13, 14, 13, 10, 14, 14, 12, 10, 9, 14, 18, 16, 17, 13, 11, 11, 15, 17, 12, 16, 16, 16, 15, 8, 10, 11, 10, 13, 10, 12, 11, 15, 15, 14, 19, 21, 15, 16, 18, 16, 14, 11, 16, 19, 19, 20, 19, 22, 18, 18, 18, 10, 13, 16, 13, 13, 15, 11, 13, 12, 10, 13, 12, 14, 17, 15, 18, 18, 15, 15, 12, 14, 14, 18, 20, 20, 15, 18, 13, 12, 15, 17, 13, 13, 18, 18, 19, 15, 12, 14, 18, 15, 15, 17, 16, 14, 17, 16, 11, 17, 12, 15, 13, 11, 11, 14, 13, 17, 14, 12, 15, 15, 16, 16, 16, 16, 15, 16, 11, 13, 15, 18, 22, 22, 24, 22, 18, 24, 18, 15, 13, 17, 18, 22, 17, 20, 18, 14, 15, 14, 15, 11, 17, 16, 12, 12, 14, 13, 20, 18, 14, 15, 15, 15, 15, 14, 10, 10, 12, 13, 14, 19, 15, 12, 14, 10, 15, 15, 17, 19, 17, 14, 16, 15, 14, 15, 17, 16, 19, 14, 11, 10, 11, 14, 12, 10, 17, 19, 18, 14, 13, 12, 14, 15, 14, 13, 11, 11, 14, 9, 8, 12, 13, 18, 15, 18, 18, 14, 16, 19, 21, 19, 14, 14, 18, 15, 15, 20, 15, 17, 17, 14, 19, 18, 19, 18, 17, 16, 12, 17, 17, 18, 16, 17, 19, 16, 14, 15, 14, 13, 12, 11, 13, 11, 12, 15, 15, 19, 15, 16, 17, 16, 17, 14, 20, 20, 20, 20, 17, 19, 15, 19, 15, 17, 16, 14, 19, 15, 14, 14, 12, 13, 12, 15, 17, 16, 17, 15, 13, 10, 14, 18, 14, 15, 17, 17, 16, 17, 11, 11, 9, 12, 12, 14, 16, 19, 18, 19, 19, 16, 16, 13, 13, 12, 11, 14, 12, 12, 14, 20, 19, 15, 16, 13, 13, 12, 18, 19, 21, 18, 15, 15, 18, 14, 17, 15, 14, 14, 13, 14, 13, 14, 14, 15, 17, 17, 19, 18, 16, 17, 19, 19, 18, 16, 17, 17, 16, 18, 13, 11, 10, 16, 17, 17, 15, 15, 15, 14, 13, 9, 13, 17, 19, 16, 18, 18, 14, 17, 20, 15, 21, 16, 16, 12, 11, 11, 12, 15, 15, 19, 14, 17, 11, 11, 13, 12, 11, 17, 17, 15, 16, 18, 16, 13, 14, 16, 15, 11, 10, 11, 12, 15, 14, 14, 14, 14, 12, 9, 15, 16, 14, 13, 12, 14, 11, 14, 16, 17, 15, 15, 11, 12, 15, 20, 17, 16, 14, 11, 17, 10, 12, 13, 15, 16, 18, 13, 12, 19, 18, 15, 15, 12, 15, 12, 10, 12, 15, 14, 15, 16, 14, 15, 18, 10, 12, 16, 17, 11, 15, 11, 15, 14, 14, 19, 23, 23, 20, 15, 15, 19, 17, 17, 17, 15, 15, 14, 17, 20, 14, 15, 14, 14, 19, 14, 16, 17, 17, 17, 12, 15, 9, 9, 12, 13, 15, 18, 17, 12]

Seconds per sample: 0.12489592006661115
Offset in seconds: -25.7285595337219
Common region starts at 123.02248126561199 and ends at 171.3572023313905

Found intro ranges (in seconds) are:
 First File: [123.02248126561199, 171.3572023313905] 
 Second File: [148.75104079933388, 197.0857618651124]

result.png.1ca42e5bd26d5d38027a27f9860952fb.png

As you can see, the script compares both audio fingerprints to determine the proper offset and then finds the common region by using the Hamming distance algorithm (bit difference). After it finds the common region, it maps the region to both input video files to figure out exactly where the intro starts and stops.

As a whole, the script only takes a minute or two on my computer, but most of the execution time is simply getting the audio to my computer (since I was accessing my media via SMB on Wi-Fi). The actual time it takes to compare the fingerprints is under 30 seconds. The script could be further optimized, such as taking a shorter audio clip on shorter shows (I always take a 5 min clip currently), and also modified to take an input folder and find the intros for a whole season at once.

Since the script is somewhat long, you can see the script here.

Edited by samuelqwe
Specified a few things
  • Like 2
Link to comment
Share on other sites

Curious - does this work for all audio types - especially the multi channel ones

and also does it work with say a 2ch file against a 5.1+ file when looking for the match?

Link to comment
Share on other sites

1 hour ago, PenkethBoy said:

Curious - does this work for all audio types - especially the multi channel ones

and also does it work with say a 2ch file against a 5.1+ file when looking for the match?

Good question, I would assume it would work as long as FFmpeg can convert to mono (as my script already does), but I’ll be sure to test it some more.

The reason this is done is to make sure the fingerprint is representative of the entire audio stream, and not just some of the channels of the audio stream.

With that in mind, I suppose it could work between videos that have a different number of audio channels, but I don’t have anything I can use to test that right now as all the shows I have contain the same type of audio for all episodes.

EDIT: I made some slight modifications to the way audio is fetched in my script, but it works fine for multi-channel audio shows. Haven't been able to test between two files with different amount of audio channels yet.

Edited by samuelqwe
Link to comment
Share on other sites

Well done! So you can now find the intro finger print, use that fingerprint to capture all the data for the entire season.

That is amazing work! Very impressive!

How do we implement that into Emby? 

My python is not strong, it took me an hour to translate TeamBs code to c#.

I think it needs to be c# to create the scheduled task.

  • Like 1
Link to comment
Share on other sites

53 minutes ago, chef said:

Well done! So you can now find the intro finger print, use that fingerprint to capture all the data for the entire season.

That is amazing work! Very impressive!

How do we implement that into Emby? 

My python is not strong, it took me an hour to translate TeamBs code to c#.

I think it needs to be c# to create the scheduled task.

Feel free to ask me any questions you have towards my script, and I can try my best to help you understand what is going on if you want to try to translate it to C#. l had to translate parts of existing code written in Go myself to get this to work.

Also, my current way of getting audio is sometimes wonky, so I think some of the FFmpeg commands listed above would be more robust and also likely faster than what I have done. I’ll likely just go back and change it myself, but you’ve already got that part figured out I think.

EDIT: Fixed the audio fetching in my script with one of the suggested FFmpeg commands. Works much better now, and takes less storage space and time.

 

Edited by samuelqwe
  • Like 1
Link to comment
Share on other sites

8 hours ago, chef said:

Okay, I think I have converted this properly into c#, and I get some results which seem to score around 19 (right around where the intro must be located in the stream).

Here is some code refactored to c#... 

code removed

This reads out all the differences in the scores list, and some do drop as low as 19, which I would consider to be around where the intro starts.

Forgive me for using your python codes exact name structure, I wanted to read it and try to make sense of it all, as I was doing my best to translate to c#.

 

Question: Am I waaaaaaay off here? 

Here is your code with a few small changes, I have tested this on some fingerprint data and get the same results as the python code I wrote.

I added some test cals to the top to make sure the bit diff count was working, using some known numbers helps.

using System;
using System.Collections.Generic;

namespace AudioOffset
{
    class Program
    {
        public static int count_bit_diff(uint left, uint right)
        {
            var count = 0;
            for (int i = 0; i < 32; i++)
            {
                if ((left >> i & 1) != (right >> i & 1))
                {
                    count = count + 1;
                }
            }
            return count;
        }

        static void Main(string[] args)
        {
            uint val01 = 24;
            uint val02 = 4294967295;

            int bit_diff = count_bit_diff(val01, val02);

            Console.WriteLine(Convert.ToString(val01, 2).PadLeft(32, '0'));
            Console.WriteLine(Convert.ToString(val02, 2).PadLeft(32, '0'));
            Console.WriteLine(Convert.ToString(val02 ^ val01, 2).PadLeft(32, '0'));
            Console.WriteLine(bit_diff);

            List<uint> episode_fingerprint = new List<uint>() { ... };
            List<uint> theme_fingerprint = new List<uint>() { ... };
            List<int> scores = new List<int>();

            for (var index_offset = 0; index_offset < (episode_fingerprint.Count - theme_fingerprint.Count); index_offset++)
            {
                var index_score = 0;
                for (var index = 0; index < theme_fingerprint.Count; index++)
                {
                    var epp_int = episode_fingerprint[index + index_offset];
                    var theme_int = theme_fingerprint[index];
                    var this_score = count_bit_diff(epp_int, theme_int);
                    index_score += this_score;
                }
                scores.Add(index_score);
            }

            Console.WriteLine(String.Join(",", scores));

            int min_score = -1;
            int min_score_at = 0;
            for (int x = 0; x < scores.Count; x++)
            {
                int score = scores[x];
                if (min_score == -1 || score < min_score)
                {
                    min_score = score;
                    min_score_at = x;
                }
            }

            Console.WriteLine("Min Distance    : " + min_score);
            Console.WriteLine("Min Distance at : " + min_score_at);

        }
    }
}

I had to remove the fingerprint data but it was where the ... are now in the above, I can supply the data if you want it.

if you are extracting chromaprint data using fpcalc remember to set the -length to something long to make sure it does not cut off your data.
I was very confused yesterday when a show with a very delayed intro theme (7min in) would not work, eventually realised it was being sliently trimmed to 2 min by fpcalc by default.

 

Edited by TeamB
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...