28 lines
824 B
Python
28 lines
824 B
Python
from ffmpeg_streaming import Formats, Bitrate, Representation, Size
|
|
import os
|
|
import ffmpeg_streaming
|
|
|
|
|
|
dirs = [
|
|
"exercise_videos"
|
|
]
|
|
|
|
for dir in dirs:
|
|
complete_dir = os.getcwd() + "/media/" + dir
|
|
for filename in os.listdir(complete_dir):
|
|
if "mp4" not in filename:
|
|
continue
|
|
print(filename)
|
|
end_location = os.getcwd() + '/media/hls/'+ str(filename) +'.m3u8'
|
|
|
|
if os.path.isfile(end_location):
|
|
pass
|
|
|
|
media_location = os.getcwd() + "/media/" + dir + "/" + str(filename)
|
|
video = ffmpeg_streaming.input(media_location)
|
|
|
|
hls = video.hls(Formats.h264())
|
|
_720p = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))
|
|
hls.representations(_720p)
|
|
hls.output(end_location)
|
|
print("------") |