Another analysis on the realization of quick preview of video thumbnail in station B, Bilibili

Posted by adamlacombe on Thu, 31 Oct 2019 20:52:41 +0100

There was an analysis in the previous article
In the video search results of station B, you can preview the video quickly without entering the video.

Today, I will analyze and repeat the implementation process in detail.

1. First, obtain the complete thumbnail resources of a video

Obtained through the following interface

https://api.bilibili.com/x/player/videoshot?index=1&aid=XXX

with https://www.bilibili.com/video/av8370807 take as an example
aid = 8370807
The interface returns data as follows

{
	"code": 0,
	"message": "0",
	"ttl": 1,
	"data": {
		"pvdata": "//i0.hdslb.com/bfs/videoshot/13778135.bin",
		"img_x_len": 10,
		"img_y_len": 10,
		"img_x_size": 160,
		"img_y_size": 90,
		"image": ["//i0.hdslb.com/bfs/videoshot/13778135.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-1.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-2.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-3.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-4.jpg"],
		"index": [0, 0, 12, 25, 37, 50, 62, 75, 87, 100, 112, 125, 137, 150, 162, 175, 187, 200, 212, 225, 237, 250, 262, 275, 287, 300, 312, 325, 337, 350, 362, 375, 387, 400, 412, 425, 437, 450, 462, 475, 487, 500, 512, 525, 537, 550, 562, 575, 587, 600, 612, 625, 637, 650, 662, 675, 687, 700, 712, 725, 737, 750, 762, 775, 787, 800, 812, 825, 837, 850, 862, 875, 887, 900, 912, 925, 937, 950, 962, 975, 987, 1000, 1012, 1025, 1037, 1050, 1062, 1075, 1087, 1100, 1112, 1125, 1137, 1150, 1162, 1175, 1187, 1200, 1212, 1225, 1237, 1250, 1262, 1275, 1287, 1300, 1312, 1325, 1337, 1350, 1362, 1375, 1387, 1400, 1412, 1425, 1437, 1450, 1462, 1475, 1487, 1500, 1512, 1525, 1537, 1550, 1562, 1575, 1587, 1600, 1612, 1625, 1637, 1650, 1662, 1675, 1687, 1700, 1712, 1725, 1737, 1750, 1762, 1775, 1787, 1800, 1812, 1825, 1837, 1850, 1862, 1875, 1887, 1900, 1912, 1925, 1937, 1950, 1962, 1975, 1987, 2000, 2012, 2025, 2037, 2050, 2062, 2075, 2087, 2100, 2112, 2125, 2137, 2150, 2162, 2175, 2187, 2200, 2212, 2225, 2237, 2250, 2262, 2275, 2287, 2300, 2312, 2325, 2337, 2350, 2362, 2375, 2387, 2400, 2412, 2425, 2437, 2450, 2462, 2475, 2487, 2500, 2512, 2525, 2537, 2550, 2562, 2575, 2587, 2600, 2612, 2625, 2637, 2650, 2662, 2675, 2687, 2700, 2712, 2725, 2737, 2750, 2762, 2775, 2787, 2800, 2812, 2825, 2837, 2850, 2862, 2875, 2887, 2900, 2912, 2925, 2937, 2950, 2962, 2975, 2987, 3000, 3012, 3025, 3037, 3050, 3062, 3075, 3087, 3100, 3112, 3125, 3137, 3150, 3162, 3175, 3187, 3200, 3212, 3225, 3237, 3250, 3262, 3275, 3287, 3300, 3312, 3325, 3337, 3350, 3362, 3375, 3387, 3400, 3412, 3425, 3437, 3450, 3462, 3475, 3487, 3500, 3512, 3525, 3537, 3550, 3562, 3575, 3587, 3600, 3612, 3625, 3637, 3650, 3662, 3675, 3687, 3700, 3712, 3725, 3737, 3750, 3762, 3775, 3787, 3800, 3812, 3825, 3837, 3850, 3862, 3875, 3887, 3900, 3912, 3925, 3937, 3950, 3962, 3975, 3987, 4000, 4012, 4025, 4037, 4050, 4062, 4075, 4087, 4100, 4112, 4125, 4137, 4150, 4162, 4175, 4187, 4200, 4212, 4225, 4237, 4250, 4262, 4275, 4287, 4300, 4312, 4325, 4337, 4350, 4362, 4375, 4387, 4400, 4412, 4425, 4437, 4450, 4462, 4475, 4487, 4500, 4512, 4525, 4537, 4550, 4562, 4575, 4587, 4600, 4612, 4625, 4637, 4650, 4662, 4675, 4687, 4700, 4712, 4725, 4737, 4750, 4762, 4775, 4787, 4800, 4812, 4825, 4837, 4850, 4862, 4875, 4887, 4900, 4912, 4925, 4937, 4950, 4962, 4975, 4987, 5000, 5012, 5025, 5037, 5050, 5062, 5075, 5087]
	}
}

2. Analysis and conclusion

First, the video lasts 84 minutes and 49 seconds, totaling 5089 seconds

"image": ["//i0.hdslb.com/bfs/videoshot/13778135.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-1.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-2.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-3.jpg", "//i0.hdslb.com/bfs/videoshot/13778135-4.jpg"],

5 sprites in total, 408 thumbnails in total

"index": [0, 0, 12, 25, 37, 50, 62, 75, 87, 100, 112, 125, 137, 150, 162, 175, 187, 200, 212, 225, 237, 250, 262, 275, 287, 300, 312, 325, 337, 350, 362, 375, 387, 400, 412, 425, 437, 450, 462, 475, 487, 500, 512, 525, 537, 550, 562, 575, 587, 600, 612, 625, 637, 650, 662, 675, 687, 700, 712, 725, 737, 750, 762, 775, 787, 800, 812, 825, 837, 850, 862, 875, 887, 900, 912, 925, 937, 950, 962, 975, 987, 1000, 1012, 1025, 1037, 1050, 1062, 1075, 1087, 1100, 1112, 1125, 1137, 1150, 1162, 1175, 1187, 1200, 1212, 1225, 1237, 1250, 1262, 1275, 1287, 1300, 1312, 1325, 1337, 1350, 1362, 1375, 1387, 1400, 1412, 1425, 1437, 1450, 1462, 1475, 1487, 1500, 1512, 1525, 1537, 1550, 1562, 1575, 1587, 1600, 1612, 1625, 1637, 1650, 1662, 1675, 1687, 1700, 1712, 1725, 1737, 1750, 1762, 1775, 1787, 1800, 1812, 1825, 1837, 1850, 1862, 1875, 1887, 1900, 1912, 1925, 1937, 1950, 1962, 1975, 1987, 2000, 2012, 2025, 2037, 2050, 2062, 2075, 2087, 2100, 2112, 2125, 2137, 2150, 2162, 2175, 2187, 2200, 2212, 2225, 2237, 2250, 2262, 2275, 2287, 2300, 2312, 2325, 2337, 2350, 2362, 2375, 2387, 2400, 2412, 2425, 2437, 2450, 2462, 2475, 2487, 2500, 2512, 2525, 2537, 2550, 2562, 2575, 2587, 2600, 2612, 2625, 2637, 2650, 2662, 2675, 2687, 2700, 2712, 2725, 2737, 2750, 2762, 2775, 2787, 2800, 2812, 2825, 2837, 2850, 2862, 2875, 2887, 2900, 2912, 2925, 2937, 2950, 2962, 2975, 2987, 3000, 3012, 3025, 3037, 3050, 3062, 3075, 3087, 3100, 3112, 3125, 3137, 3150, 3162, 3175, 3187, 3200, 3212, 3225, 3237, 3250, 3262, 3275, 3287, 3300, 3312, 3325, 3337, 3350, 3362, 3375, 3387, 3400, 3412, 3425, 3437, 3450, 3462, 3475, 3487, 3500, 3512, 3525, 3537, 3550, 3562, 3575, 3587, 3600, 3612, 3625, 3637, 3650, 3662, 3675, 3687, 3700, 3712, 3725, 3737, 3750, 3762, 3775, 3787, 3800, 3812, 3825, 3837, 3850, 3862, 3875, 3887, 3900, 3912, 3925, 3937, 3950, 3962, 3975, 3987, 4000, 4012, 4025, 4037, 4050, 4062, 4075, 4087, 4100, 4112, 4125, 4137, 4150, 4162, 4175, 4187, 4200, 4212, 4225, 4237, 4250, 4262, 4275, 4287, 4300, 4312, 4325, 4337, 4350, 4362, 4375, 4387, 4400, 4412, 4425, 4437, 4450, 4462, 4475, 4487, 4500, 4512, 4525, 4537, 4550, 4562, 4575, 4587, 4600, 4612, 4625, 4637, 4650, 4662, 4675, 4687, 4700, 4712, 4725, 4737, 4750, 4762, 4775, 4787, 4800, 4812, 4825, 4837, 4850, 4862, 4875, 4887, 4900, 4912, 4925, 4937, 4950, 4962, 4975, 4987, 5000, 5012, 5025, 5037, 5050, 5062, 5075, 5087]

index: 408 items in total, increasing from 0 to 5087

We have the following findings

  • Length of index = number of thumbnails
  • Maximum value of index < = Total Video duration
  • Maximum value of index ≈ total video duration

It is not difficult to deduce the following conclusions:

Suppose there is a number i of type int, and i < index.length
 Then the value of index[i] represents the time starting point of the i+1 thumbnail (thumbnail with index I)
Then the value of index[i+1] represents the time end point of the i+1 thumbnail (thumbnail with index I)
When i = index.length-1, the end of time is the total video time.