Skip to content

Instantly share code, notes, and snippets.

@lukebussey
Created January 3, 2017 21:43
Show Gist options
  • Save lukebussey/4d27678c72580aeb660c19a6fb73e9ee to your computer and use it in GitHub Desktop.
Save lukebussey/4d27678c72580aeb660c19a6fb73e9ee to your computer and use it in GitHub Desktop.

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8
@joshnissenbaum
Copy link

Doesn't work with a HEVC unfortunately - audio only, no video

@loopkinng
Copy link

Great for me

@codenoid
Copy link

codenoid commented Mar 5, 2024

I can't imagine developer burden without FFMPEG

@horasjey
Copy link

-codec: copy this is a very fast .but -hls_time not working. default every ts file time always it's 8s. how to do can change ts time, for example 4s or shorter time.

... https://ffmpeg.org/ffmpeg-formats.html#hls-2
Please, just read the docs? It's not that hard.

sorry.I read already.But still no answer why -hls_time 2 not work. this is my command.

ffmpeg -i file.mp4 -codec: copy -start_number 0 -hls_time 4 -hls_list_size 0 -f hls m3u8/file.m3u8. but in the m3u8 file always is #EXTINF:8.341667. then I try ffmpeg -i file.mp4 -force_key_frames "expr:gte(t,n_forced*4)" -codec: copy -start_number 0 -hls_time 4 -hls_list_size 0 -f hls m3u8/file.m3u8. Same result.

then I use other command. ffmpeg -i file.mp4 -codec: copy -map 0 -f segment -segment_list file.m3u8 -segment_time 00:00:04 file%03d.ts. in the m3u8 file also is #EXTINF:8.341667. this -segment_time 00:00:04 also not work.

but when I not use -codec: copy this command can work normal. ffmpeg -i file.mp4 -start_number 0 -hls_time 4 -hls_list_size 0 -f hls m3u8/file.m3u8. or ffmpeg -i file.mp4 -map 0 -f segment -segment_list file.m3u8 -segment_time 00:00:04 file%03d.ts. in the m3u8 file #EXTINF:4.004000. time change already. but it's very slow not with -codec: copy.

I don't why -codec: copy can't use -segment_time or -hls_time? if anyone have answer plases tell me.

Any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment