Implementation of HLS Protocol for an IP Camera - onlinepresent.org

65 downloads 81225 Views 675KB Size Report
The media encoder converts the generated raw H.264 stream file to a segmented. MPEG-2 TS file ... For Android devices, we have to use a default media player.
Advanced Science and Technology Letters Vol.46 (Networking and Communication 2014), pp.111-114 http://dx.doi.org/10.14257/astl.2014.46.26

Implementation of HLS Protocol for an IP Camera Byoung Wook Choi 1, Gil Jin Yang2 and Jong Hun Kim3, 1, 2

Dept. of Electrical and Information Engineering, Seoul National Univ. of Science and Technology, Seoul, Korea, 3 R&D Center, Seyeon Tech Co., Ltd., Seoul, Korea [email protected], [email protected] and [email protected]

Abstract. HTML5 is designed to deliver almost everything you want to do without requiring additional plugins. We produced an implementation of a HTTP Live Streaming (HLS) for an IP camera to provide live streaming by using elements of HTML5 for media playback. This implementation follows HLS standard in which we utilizes an open-source library named FFmpeg. A conclusion of this paper is that live steaming on mobile devices over HTTP is achieved without any plugins. Keywords: HTML5, HLS, IP Camera, FFmpeg.

1

Introduction

Security service has rapidly changed from analog-based CCTV to digital-based IP camera by which multimedia content is delivered continuously to clients over internet. The de facto protocol of today’s internet, Hypertext Transfer Protocol (HTTP), is widely used in streaming technology. In recent years, smartphones have become enduser devices as well as PC for live streaming, as they run various operating systems. Generally multimedia contents generated from IP camera are played with dedicated applications called plugins. The live streaming, however, should be transparent to the multimedia player which is running on internet browsers because of the immense variety of end-user device operating various operating systems. That is the reason why HTML5 is intended. HTML5 is designed to deliver almost everything you want to do without requiring additional plugins [1]. For live streaming, Apple Inc. published a protocol known as HTTP Live Streaming (HLS) [2-3] and it is in the process of becoming an Internet Engineering Task Force (IETF) standards. MPEG proposed a standard for adaptive streaming over HTTP, known as Dynamic Adaptive Streaming over HTTP (DASH) [4]. In this paper, we produced an implementation of HLS for a commercial IP camera to provide live streaming by using and elements of HTML5 for media playback. This implementation follows HLS standard in which we utilizes an

1 Corresponding Author

ISSN: 2287-1233 ASTL Copyright © 2014 SERSC

Advanced Science and Technology Letters Vol.46 (Networking and Communication 2014)

open-source library named FFmpeg. A clear conclusion of this paper is that live steaming on mobile devices over HTTP is achieved without any plugins.

2

Live Streaming for an IP Camera

Apple released a HTTP-based streaming media communication protocol called HLS to transmit bounded and unbounded streams of multimedia data. According to this specification, an overall stream broken into a sequence of small HTTP-based file downloads, where users can select alternate streams encoded at different data rates. Initially, users download an extended M3U playlist which contains several Uniform Resource Identifiers (URIs) corresponding to media files, where each file must be a continuation of the encoded stream. Each individual media file must be formatted as an MPEG-2 transport stream (TS) or a MPEG-2 audio elementary stream. The overall process performed in the HLS architecture is shown in Fig. 1.

Fig. 1. HTTP live streaming protocol architecture.

Fig. 2. Implementation of HLS for an IP Camera.

Figure 2 shows an overall implementation of a HLS for a commercial IP camera. Seyeon Tech. provides common gateway interface (CGI) to send image data to a server. The image date was encoded with H.264. To accommodate HLS protocol, raw H.264 steam should be segmented into a series of MPEG-2 TS. The media encoder converts the generated raw H.264 stream file to a segmented MPEG-2 TS file which has 10 seconds stream. The open source multimedia converter, FFMPEG, is used to build MPEG-2 media. The media encoder is designed to 112

Copyright © 2014 SERSC

Advanced Science and Technology Letters Vol.46 (Networking and Communication 2014)

minimize the memory size of an embedded LINUX based IP camera by using only necessary part of the FFMPEG library [5]. The employed libraries in FFMPEG library for the media encoder on converting raw H.264 stream data to MPEG-2 TS format include libavformat, libavcodec and libavutil. The output file is subsequently generated in MPEG-2 TS format using the file creation function of the FFMPEG library. The procedure for generating and extracting a raw H.264 stream from an IP camera in MPEG-2 TS file format is initiated at the same time as when the raw H.264 stream, with play back time of 10 seconds is obtained. The generated the raw H.264 stream is converted to MPEG-2 TS file format through FFMPEG thread. Once conversion is complete, FFMPEG thread returns the resource and modifies the playlist of the MPEG-2 TS file. Thus, by repeating this procedure, MPEG-2 TS files and playlist required for live streaming of the HLS protocol, are continuously generated with multi thread program. Apache2 web server (Apache Software Foundation) is used to serve fragmented MPEG-2 TS files to clients by using a web page as shown in Figure 2 [6]. HLS protocol that supports HTML5 elements of provides playlist of m3u8 format in the tag. Therefore, the client is able to play multimedia files included in the playlist on a standard browser without plug-ins.

3

Experimental Results

Experiments for HLS playback were performed on iOS 7.0.4 (iPhone 4S). As shown in Figure 3, the streaming data for the IP camera is played in real-time on an iPhone without any plug-ins. The real streaming data has delay of 30 seconds because the real-time streaming can be started after the playlist have 3 MPEG-2 TS files which have 10 seconds duration each. End-to-End Latency is 30 seconds for HLS protocol.

Fig. 3. Live Streaming on iPhone.

Copyright © 2014 SERSC

113

Advanced Science and Technology Letters Vol.46 (Networking and Communication 2014)

4

Conclusion

HTTP based live streaming has the better traversal of NAT and firewalls, ease of deployment and built-in friendly bandwidth sharing. One of adaptive streaming approaches over HTTP is Apple’s HLS. This paper details a method for realizing HLS for a commercial IP camera since IP cameras are major devices for security surveillance system. This implementation follows the MPEG standard and HLS protocols so client device is able to play live stream data on Apple devices without any plug-ins. This paper utilizes FFMPEG library to use the transcoding capabilities when making MPEG-2 TS files. FFMPEG library supports many container formats include MPEG2 TS and raw H.264. Generally, the commercial IP cameras produce raw image data encoded with H.264 format and HLS is based on MPEG-2 TS files. Therefore, FFMPEG library is useful to implement HLS protocol and the function of FFMPEG is ported into the IP camera as an embedded system program. In order to generate live streaming continuously, we developed a thread program to update M3U playlist files which contains three TS files of 10 seconds duration. Based on HTML5 in the Web server, live media was played on the client by using an Apple Device without any kinds of plug-ins. For Android devices, we have to use a default media player. Results showed that 30 seconds latency due to the standard of HLS which have three TS files prior to send media data to the client.

References 1. Wijering, J.: “The State of HTML5 Video.” http://www.jwplayer.com/html5/, (2013) 2. Pantos, R., May, W.: HTTP Live Streaming. IETF draft, http://tools.ietf.org/html/draftpantos-http-live-streaming-12, Oct (2013) 3. Apple Corporation. “HTTP Live Streaming Overview.” iOS Reference Library, (2011) 4. Stockhammer, T.: Dynamic Adaptive Streaming over HTTP - Standards and Design Principles. ACM Multimedia Systems Conference (MMSys). San Jose, California, USA (2011) 5. FFmpeg, http://ffmpeg.org 6. Apache Software Foundation, http://www.apache.org

114

Copyright © 2014 SERSC