Open zamanuhina opened 4 years ago
Tell me please.
Is it possible to save segments to disk when the video is first played? After that, give the second user segments from the disk as static files?
Can I win in server performance this way? Adding new gigabytes of disk costs a lot less than adding kernels and RAM.
The CPU usage of the module is usually very low, and it doesn't use GPU at all. The CPU usage can get higher if you use DRM or features that involve decoding/encoding, e.g. playback rate change / thumbnail capture. The difference between the maximum throughput you can get when serving static files to what you can get when using this module (assuming no decoding/encoding is involved...) is usually very small. If you use the module, you may lose a few percentages in performance, but you gain a lot of flexibility - support for multiple protocols, future proof solution etc.
@erankor Thanks for your reply.
I have already started making a solution, without using nginx-vod-module, since 2 months have passed since the question was created.
Now I already have an exact idea of what I need.
Tell me, can nginx-vod-module compose such a manifest master.m3u8
? Stereo/surround audio, subtitle and video.
https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/stereo/en/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/surround/en/320kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Deutsch",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="de",URI="subtitles_de.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI="subtitles_en.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Espanol",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="es",URI="subtitles_es.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="fr",URI="subtitles_fr.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=258157,CODECS="avc1.4d400d,mp4a.40.2",AUDIO="stereo",RESOLUTION=422x180,SUBTITLES="subs"
video/250kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=520929,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="stereo",RESOLUTION=638x272,SUBTITLES="subs"
video/500kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=831270,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="stereo",RESOLUTION=638x272,SUBTITLES="subs"
video/800kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1144430,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="surround",RESOLUTION=958x408,SUBTITLES="subs"
video/1100kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1558322,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="surround",RESOLUTION=1277x554,SUBTITLES="subs"
video/1500kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4149264,CODECS="avc1.4d4028,mp4a.40.2",AUDIO="surround",RESOLUTION=1921x818,SUBTITLES="subs"
video/4000kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=6214307,CODECS="avc1.4d4028,mp4a.40.2",AUDIO="surround",RESOLUTION=1921x818,SUBTITLES="subs"
video/6000kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10285391,CODECS="avc1.4d4033,mp4a.40.2",AUDIO="surround",RESOLUTION=4096x1744,SUBTITLES="subs"
video/10000kbit.m3u8
Yes, it can generate such a master, only gap is that you use the same audio codec (AAC) for both stereo & surround, while the grouping of audio tracks is based on codec. We are using AC-3/EAC-3 codecs for surround and AAC for stereo, this makes the module output 2 audio groups, as in your sample manifest.
@erankor But AC-3 won't work in a browser.
https://bugs.chromium.org/p/chromium/issues/detail?id=611517
My VOD service is mainly for browser users.
Why does grouping work by codec and not by bit rate?
I don't think bitrate makes sense, different bitrates can also just indicate different qualities... but maybe it makes sense to add the number of channels to the grouping criteria
@erankor Could you show me an example of what the URL needs to be to get such a manifest structure? Thank you.
If you use AC-3 (or multiple audio codecs in general) you just supply all input files to the module using either JSON: https://github.com/kaltura/nginx-vod-module/#adaptive-set or multi-url: https://github.com/kaltura/nginx-vod-module/#multi-url-structure and you'll get a manifest like the one you pasted.
Grouping by number of channels is not something that currently exists, requires some code change...
http://example.com/hls/videos/250kbit.mp4,500kbit.mp4,800kbit.mp4,1100kbit.mp4,1500kbit.mp4,4000kbit.mp4,6000kbit.mp4,10000kbit.mp4,128kbit.m4a,subtitles_de.vtt,subtitles_en.vtt,subtitles_es.vtt,subtitles_fr.vtt.urlset/master.m3u8
Please tell me, will this url make the manifest I need? Along with video, audio and subtitles? The system will understand that m4a is the audio track for all video tracks.
Well, the module will need to get the languages of the subtitles from somewhere... if you use mapped mode, you can return the language there, otherwise, you'll need to change subtitles_en.vtt
to /lang/eng/subtitles_en.vtt
I have video MOV files. I want to upload them to the server so that anyone can watch them on any device.
I am faced with a choice:
ffmpeg -i input.mov -preset slow -codec:a libfdk_aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 1400k -maxrate 1498k -bufsize 2100k -vf scale=842:480 480.mp4
ffmpeg -i input.mov -vf scale=w=842:h=480:force_original_aspect_ratio=decrease -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 1400k -maxrate 1498k -bufsize 2100k -b:a 128k -hls_segment_filename %d.ts 480.m3u8
In the second choice, I will already have
.ts
files and my server will essentially just serve static. We can say that there will be no load on the server. In the case of using the module, will there be a heavy load on the server CPU or GPU? Will the segments be cached to avoid pulling them out of the MP4 file again?