Ffmpeg creating m3u8 from mp4, video file size

cvdogan picture cvdogan · Feb 3, 2017 · Viewed 18.1k times · Source

I am using ffmpeg to convert mp4 to m3u8. But first I need to make mp4 smaller. I use this code to make it smaller:

ffmpeg -i big.mp4 -b 1000000 small.mp4

Then I use this code to convert it to m3u8

ffmpeg -i small.mp4 -g 60 -hls_time 2 -hls_list_size 0 -hls_segment_size 500000 output.m3u8

Is there a way to do this in once?

Answer

Gyan picture Gyan · Feb 3, 2017

Just combine them:

ffmpeg -i big.mp4 -b:v 1M -g 60 -hls_time 2 -hls_list_size 0 -hls_segment_size 500000 output.m3u8

Note that you're transcoding the video twice in your current workflow. Since the 2nd command hasn't set video codec option to copy, it gets transcoded again - in CRF mode with value 23.