H
H
Horosh2942020-07-25 11:19:39
fmpeg
Horosh294, 2020-07-25 11:19:39

How to encode video in ffmpeg to pass over HLS?

I was inspired by this article: https://playerjs.com/docs/ru=mp4hlsencoding
I have a video in mkv in 2k quality, I want to make the quality 360 480 720 1080 2160 for it, and so that they are transmitted by HLS. There are 8 more audio tracks in this video. I got this command

ffmpeg -y -i 1.mkv -map_metadata -1 -map 0:v:0 -map 0:a:0 -map 0:a:1 -map 0:a:2 -map 0:a:3 -map 0:a:4 -map 0:a:5 -map 0:a:6 -map 0:a:7  -vcodec libx264 -pix_fmt yuv420p -vsync 1 -async 1 -color_primaries 1 -color_trc 1 -colorspace 1 -vf scale="'w=if(gt(a,16/9),640,-2):h=if(gt(a,16/9),-2,360)'" -ab 128k -maxrate 800k -bufsize 1200k -bufsize 4200k -acodec aac -ac 2 -ab 128k -f mp4 -movflags +faststart out1.mp4

The output is an mp4 file that contains 8 audio tracks, but if I understand correctly for my task, as a result, there should also be 5 video tracks inside, all of the appropriate quality. I understand correctly?
What team is needed?
And one more thing: I don’t understand the article says "hls is available at: localhost/hls/output.mp4/index.m3u8" , but where does this file come from? Should I create it myself? How does it even work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-07-26
@Horosh294

Well, in general, you should get 5 separate qualities, in each - 8 audio tracks and 1 video track, each of its own size and bitrate. Those. take your command and change the bitrate and frame size in it.
At the same time, your command makes an mp4 file, you can make HLS from it using nginx-vod-module, or remake the ffmpeg command like this (-f hls) to immediately get a set of TS segments plus an index M3U8 file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question