# A Novel Video Transmission Latency Measurement Method for Intelligent Cloud Computing
## 3 Methodology
### Method 1: Timecode Latency Measurement  
The measurement scheme is shown in Figure 2(a). The camera captures raw video and feeds it into the latency measurement device. The latency measurement device takes the arrival time of the synchronization pulse of the video frame as the input time of each frame. The frame input time and frame number are injected into the fixed position of the original video picture in the form of a barcode, and the video with the timecode is encoded, transmitted, and decoded to obtain a reconstructed video. The reconstructed video is also sent to the latency measurement device and the device records the arrival time of the synchronization pulse of the reconstructed video frame as the time when each frame of the reconstructed video reaches the display end. The barcode is read at the fixed position of the reconstructed video to obtain the frame number and frame input time and the arrival time and input time of the same frame are compared to obtain the end-to-end latency of each frame of the video transmission system. The timecode injected into the original video appears as a short barcode at the bottom of the screen, as shown in Figure 2(b). The timecode contains frame number and frame input time information, and a color block of 16 \(\times\) 16 pixels represents a bit, and the 0 and 1 of the bit are represented by the colors YcbCr (0, 80, 80) and YcbCr (80, 80, 80). Taking a 1280 \(\times\) 720 video frame as an example, there are 80 horizontal blocks in total, which can represent data with a data bit width of 80 bits. Splicing the data to be represented (e.g., frame number and timestamp), it can be written as: [Frame cnt [7:0], Time cnt [31:0]], which uses a total of 40 bits. The time value in the actual measurement uses a 32-bit counter that counts with a 25 MHz clock. When the frame synchronization signal of the original video is detected, the value of the counter is saved in the latency measuring device as the input time \(T_{i}(n)\) of each frame of the original video, where \(n\) represents the frame number. After encoding, transmitting, and decoding, the reconstructed video arrives at the receiving end and the frame synchronization signal time of each reconstructed video frame is \(T_{r}(n)\), where \(n\) represents the frame number. According to Equation (2), the delay D(n) of the nth frame in the video transmission system can be obtained. \[\mathrm{D}(n)=\left\{ \begin{array}{l}\left(T_{r}(n)-T_{i}(n)\right)*40\; \mathrm{ns},T_{r}(n)\geq T_{i}(n)\\ \left(2^{32}+T_{i}(n)-T_{r}(n)\right)*40\;\mathrm{ns},T_{r}(n)<T_{i}(n)\end{array} \right. \tag{2}\]  
where \(T_{i}(n)\) represents the input time of the input latency measurement device for each frame of the original video, \(T_{r}(n)\) represents the frame synchronization signal time for each frame, and n represents the frame number. Because the input time of the original video and the arrival time of the reconstructed video are obtained from the same clock source, an error of \(\pm 1\) may be caused by over-counting or undercounting a number. The variance \(S_{D}\) of the latency measurement error is recorded as the sum of the variance \(S_{i}\) of the original video input time acquisition error and the variance \(S_{r}\) of the arrival time acquisition error of the reconstructed video. The variance of the measurement error can be described by Equation (3):  
\[S_{D}=S_{i}+S_{r} \tag{3}\]  
Since the unit time of the 25 MHz clock is 40 ns, the variance \(S_{D}\) of the latency measurement is 3200 ns\({}^{2}\), and the theoretical standard deviation of the latency measurement can be deduced to be 56.6 ns [47], which meets the requirements of high-precision online latency measurement. Compared with the side-by-side shooting method, the measurement accuracy of Method 1 is significantly improved, but there are still shortcomings. First, the original video content is partially destroyed in the measurement process. Although the influence is not large, this method cannot be used for online measurement in formal video applications.