Mp4 to dynamic adaptive hls with multiple bitrates using ffmpeg

13k views Asked by At

I tried converting mp4 video to HLS for online streaming which I have successfully done using FFmpeg.

Command:

ffmpeg -i /var/www/html/file_conversion/heli.mp4 -map 0 -profile:v baseline -level 3.0 -s 640x360 -c:v libx264 -b:v 500k -c:a libfdk_aac -b:a 320k -hls_list_size 0 -start_number 0 -hls_init_time 0 -hls_time 2  -f hls /var/www/html/file_conversion/hlstest2/heli.m3u8

But now I am trying to convert the same video with multiple bitrates for dynamic adaptive streaming.

Any idea how can I achieve this?

1

There are 1 answers

0
GuilhermeSantos001 On BEST ANSWER

I was having the same doubt, and found this article: https://dev.to/nodir_dev/transcode-video-source-to-hls-playlist-format-for-video-on-demand-vod-streaming-3h99

After making transcoding files, just create a *.m3u8 file, with the following content:

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=375000,RESOLUTION=640x360
360_out.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=750000,RESOLUTION=854x480
480_out.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2000000,RESOLUTION=1280x720
720_out.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3500000,RESOLUTION=1920x1080
1080_out.m3u8

now just send this file to the streams.

My HLS folder:

image_folder

The content of the master file:

content_of_master_file

I made the transcoding two resolutions: 1280x720 and 640x480

- Author of the article: Nodirbek Sharipov