Skip to content

Commit 42c497f

Browse files
committed
Initial commit
0 parents  commit 42c497f

15 files changed

+91
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__/
2+
env/
3+
.idea/
4+
.DS_Store

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Simple Flask HLS Demo
2+
3+
How to run
4+
5+
~~~bash
6+
pip install -r requirements.txt
7+
./run.sh
8+
~~~
9+
10+
go [http://localhost:5000](http://localhost:5000)

app.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from flask import render_template, Flask, send_from_directory
2+
3+
app = Flask(__name__)
4+
5+
6+
@app.after_request
7+
def add_header(response):
8+
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
9+
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
10+
response.headers['Pragma'] = 'no-cache'
11+
response.headers['Expires'] = '0'
12+
return response
13+
14+
15+
@app.route('/')
16+
def index():
17+
return render_template('index.html')
18+
19+
20+
@app.route('/video/<string:file_name>')
21+
def stream(file_name):
22+
video_dir = './video'
23+
return send_from_directory(directory=video_dir, filename=file_name)
24+
25+
26+
if __name__ == '__main__':
27+
app.run()

requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
click==6.7
2+
Flask==0.12.2
3+
itsdangerous==0.24
4+
Jinja2==2.10
5+
MarkupSafe==1.0
6+
Werkzeug==0.13

run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
export FLASK_APP=app.py
4+
flask run --no-reload --host=0.0.0.0

templates/index.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Test</title>
6+
<link href="http://vjs.zencdn.net/6.2.8/video-js.css" rel="stylesheet">
7+
</head>
8+
<body>
9+
<video id="player" class="video-js vjs-default-skin" controls preload>
10+
<source src="/video/playlist.m3u8" type="application/x-mpegURL">
11+
</video>
12+
<script src="http://vjs.zencdn.net/6.2.8/video.js"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.12.2/videojs-contrib-hls.min.js"></script>
14+
<script>
15+
var player = videojs('player', {width: 350, height: 200});
16+
player.play();
17+
</script>
18+
</body>
19+
</html>

video/playlist.m3u8

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#EXTM3U
2+
#EXT-X-VERSION:3
3+
#EXT-X-TARGETDURATION:3
4+
#EXT-X-MEDIA-SEQUENCE:0
5+
#EXTINF:2.039989,
6+
segment000.ts
7+
#EXTINF:2.000000,
8+
segment001.ts
9+
#EXTINF:2.000000,
10+
segment002.ts
11+
#EXTINF:2.000000,
12+
segment003.ts
13+
#EXTINF:2.000000,
14+
segment004.ts
15+
#EXTINF:2.000000,
16+
segment005.ts
17+
#EXTINF:2.000000,
18+
segment006.ts
19+
#EXTINF:0.840011,
20+
segment007.ts
21+
#EXT-X-ENDLIST

video/segment000.ts

891 KB
Binary file not shown.

video/segment001.ts

1.03 MB
Binary file not shown.

video/segment002.ts

930 KB
Binary file not shown.

video/segment003.ts

998 KB
Binary file not shown.

video/segment004.ts

990 KB
Binary file not shown.

video/segment005.ts

997 KB
Binary file not shown.

video/segment006.ts

975 KB
Binary file not shown.

video/segment007.ts

433 KB
Binary file not shown.

0 commit comments

Comments
 (0)