# Efficient Transcoding and Encryption for Live 360 CCTV System
## 3 Fast Multiple Transcoding and Encryption  
### Multiple Transcoding  
Instead of using a multiplexer to aggregate various video streams, the proposed method provides a parallel-processing mechanism for transcoding based on Intel Media Software Development Kit (Intel Media SDK), ARIA block cypher encryption and FFmpeg library. Additionally, Real-Time Streaming Protocol (RPSP) is used to handle input/output real-time streams from CCTV cameras to RTSP clients. As shown in Figure 6, each video transcoding session was handled by a CPU-core within one or more threads. One thread can process a number of video frames as a batching or all frames of a video stream. Figure 7 shows an example of parsing input streams, pipelining and multi-threading techniques handle the input streams as parallel processing. Each input stream could be attached to one session. Then, all sessions will be joined together to work simultaneously.  
To handle multiple transcoding sessions, FFmpeg library software [16] can also provide a mixing mechanism to multiplex video streams. However, the outputting, re-encoding and decoding multiple times in the same FFmpeg process will slow down some encoders. A few video encoders such libx264 [15] perform the encoding as threading, so they allow for parallel processing. However, audio encoding may be serial and become the bottleneck issue. This leads to FFmpeg treating them as real serial-processing. Thus, FFmpeg may not use all available cores. Another available solution can be achieved by using multiple FFmpeg instances running in parallel or piping from one FFmpeg to another encoding session. All these reasons lead to FFmpeg not working effectively for parallel encoding.  
Even though Intel Quick Sync Video technology [17] integrated into FFmpeg can handle multiple sessions, it can only support two sessions of 1080p video streams at the same time with high-latency for the second streaming. Therefore, the proposed method suggests directly using video and audio processing acceleration application programming interfaces (APIs) to improve the parallel processing for the encoders. As shown in Figure 7, to optimize CPU cores and graphics power, the proposed method uses Intel Media Software Development Kit (SDK) APIs to accelerate the video transcoding application as in parallel processing. The main architecture of Intel Media SDK is illustrated in Figure 8.  
Figure 6: Multiple real-time streaming over transcoder box.  
Figure 7: Transcoding and encryption for video streaming on multi-core platforms.  
To encrypt the video and audio simultaneously, we propose a model to transcode multiple audio and video sessions. The audio sessions are classified into two categories. First, audio data from video sessions are demuxed, and then the transcoder convert audio codec into AAC codec, as shown in Figure 9. After that, the muxer combines video and audio elementary stream into one output bitstream. Second, another audio transcoder is designed to adopt independent audio sessions based on importance in emergency situations. These audio microphones are set up near the CCTV camera to provide voice call. The audio transcoder allows converting multiple audio sessions simultaneously.