This example is part of this article.
This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:
- Domain filtering
- Referrer filtering
- Embed buster
| #!/bin/sh | |
| rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm | |
| yum -y update | |
| yum -y install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel freetype-devel speex-devel | |
| #YASM | |
| mkdir ~/ffmpeg_sources | |
| cd ~/ffmpeg_sources | |
| curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz |
| #!/bin/sh | |
| set -x | |
| nginx_version=1.0.10 | |
| sudo apt-get install gcc | |
| sudo apt-get install libpcre3-dev | |
| sudo apt-get install libssl-dev | |
| mkdir install_nginx && cd install_nginx |
This example is part of this article.
This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:
These Scripts will install NGINX with the RTMP Module in the usual directories similar to installation with apt-get.
The RTMP-Server you get with this can then be used to do one ore more of the following:
| <?php | |
| /** | |
| * @param $baseUrl - non protected part of the URL including hostname, e.g. http://example.com | |
| * @param $path - protected path to the file, e.g. /downloads/myfile.zip | |
| * @param $secret - the shared secret with the nginx server. Keep this info secure!!! | |
| * @param $ttl - the number of seconds until this link expires | |
| * @param $userIp - ip of the user allowed to download | |
| * @return string | |
| */ |
| <?php | |
| $ts = '1463646983'; | |
| $hash = str_replace('=', '',strtr(base64_encode(md5('1463646983 secret', TRUE)), '+/', '-_')); // base64url | |
| echo $hash; | |
| ?> |
| <?php | |
| /** | |
| * cd into folder with video files and run: | |
| * php /path/to/ffmpeg2mp4.php mp4 | |
| */ | |
| class Transcoder{ | |
| protected static $ffmpeg='ffmpeg'; |
| #!/bin/bash | |
| # Change this to path of file to stream /edit/to/vod/path.mp4 | |
| mediaFile="/edit/to/vod/path.mp4" | |
| ### 480x video400kbps audio40kbps ### | |
| mediaStreams="-map 0" | |
| audCodec="-acodec mp2" | |
| audKbps="-b:a 40k" |
| #!/bin/sh | |
| # use ffmpeg to concatenate all the mp4 files in the media directory | |
| # make file executable and run like this | |
| # ./make247.sh /path/to/media/folder | |
| # | |
| IN_DIR="$1"; | |
| if [ "$IN_DIR" = '' ] ; then | |
| IN_DIR="." | |
| fi | |
| for f in ${IN_DIR}/*.mp4; do echo "file '$f'" >> concat-list.txt; done |
Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.
loosely based on https://gist.github.com/bnerd/2011232
// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory