Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Last active May 9, 2026 15:50
Show Gist options
  • Select an option

  • Save tzmartin/fb1f4a8e95ef5fb79596bd4719671b5d to your computer and use it in GitHub Desktop.

Select an option

Save tzmartin/fb1f4a8e95ef5fb79596bd4719671b5d to your computer and use it in GitHub Desktop.
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4

Alt text

Example final command

ffmpeg -i "http://host/folder/file.m3u8" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4
@oong819
Copy link
Copy Markdown

oong819 commented May 8, 2026

Is there any way to add a delay equal to segment length? I don't want to stress out the server

@oong819
Copy link
Copy Markdown

oong819 commented May 9, 2026

Update to my comment:

From ffmpeg documentation:

-re (input)

Read input at native frame rate. This is equivalent to setting -readrate 1.

Not yet tested, but based on the description of -readrate, it's likely the thing I'm looking for.

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