Today I found this blog post teaching me about fragmented mp4s (fmp4s).
Using the ffmpeg docs, I've made great progress.
I run this:
'/usr/bin/ffmpeg' '-y' '-i' '/myproject/storage/app/sample_media/2020-02-27/Sample Videos 5.mp4' \
'-c:v' 'libx264' '-s:v' '1920x1080' \
'-crf' '20' '-sc_threshold' '0' '-g' '48' '-keyint_min' '48' \
'-hls_list_size' '0' '-hls_time' '10' '-hls_allow_cache' '0' '-b:v' '4889k' \
'-maxrate' '5866k' '-hls_segment_type' 'fmp4' \
'-hls_fmp4_init_filename' '/myproject/public/storage/000000002/init.mp4' \
'-hls_segment_filename' '/myproject/public/storage/000000002/list_1080p_%04d.m4s' \
'-hls_key_info_file' '/myproject/hls_hls.keyInfo' '-strict' '-2' '-threads' '12' \
'/myproject/public/storage/000000002/list_1080p.m3u8'
And then I use hls.js on my webpage to try to show the video.
Initially, it won't load.
But then I can get the video to load properly if I refresh the page after making this edit to list_1080p.m3u8:
Change from:
#EXT-X-MAP:URI="/myproject/public/storage/000000002/init.mp4"
To:
#EXT-X-MAP:URI="init.mp4"
How can I change my ffmpeg command so that it knows the absolute path of where to save the init.mp4 but also knows to write in the m3u8 only the filename init.mp4
without any path?
(I've tried using -hls_fmp4_init_filename init.mp4
without the abosolute path, but then it creates the init.mp4 at the root, which also doesn't work. I need each video's init.mp4 to be in its own folder.)