Skip to content

Instantly share code, notes, and snippets.

@LeeiFrankJaw
Last active March 4, 2020 20:03
Show Gist options
  • Save LeeiFrankJaw/98ab543a0da2f48993ebfca44ad68bf6 to your computer and use it in GitHub Desktop.
Save LeeiFrankJaw/98ab543a0da2f48993ebfca44ad68bf6 to your computer and use it in GitHub Desktop.
Convert HLS stream from m3u8 to MP4
# Convert HLS stream from m3u8 to MP4
gst-launch-1.0 -v mp4mux name=mux ! filesink location=output.mp4 filesrc location=GOPR7003.m3u8 ! hlsdemux ! decodebin name=decoder decoder. ! queue ! videoconvert ! x264enc ! mux. decoder. ! queue ! audioconvert ! voaacenc ! mux.
# Combine normal TS files into MP4
cvlc -v segment-*.ts \
--sout='#gather:file{dst=output.mp4}' \
--sout-keep \
'vlc://quit'
# The above approach will probably produce imperfect output.
cat segment-*.ts | ffmpeg -i - -acodec copy -vcodec copy output.mp4
# Presumably better than previous method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment