Skip to content

Instantly share code, notes, and snippets.

@tianying484
Forked from larvata/ffmpeg-cheatsheet.md
Created March 2, 2017 03:45
Show Gist options
  • Save tianying484/d07be5703493e5f6c2cfac087b005af3 to your computer and use it in GitHub Desktop.
Save tianying484/d07be5703493e5f6c2cfac087b005af3 to your computer and use it in GitHub Desktop.

ffmpeg Cheatsheet

  • Join TS Files
  • Convert TS to MP4
  • Download Online AES-128 Encrypted HLS video
  • Convert Video to GIF
  • Extract Audio and Convert it to MP3
  • Burn Subtitles into Video

Join TS Files

ref: http://superuser.com/questions/692990/use-ffmpeg-copy-codec-to-combine-ts-files-into-a-single-mp4

# create ts filelist as following format:
file '<filepath>'
# or use following command to generate:
(for %i in (*.ts) do @echo file '%i') > ts.lst

# concat the ts files by ffmpeg
ffmpeg -f concat -i ts.lst -c copy all.ts

Convert TS to MP4

ref: https://ffmpeg.org/ffmpeg-bitstream-filters.html

ffmpeg -i <source.ts> -c copy -bsf:a aac_adtstoasc <target.mp4>

Download Online AES-128 Encrypted HLS Video

ref: http://forum.videohelp.com/threads/343902-Looking-for-ts-to-mp4-conversion-tool

# step 1: download m3u8 and key file
# step 2: modify key file path in m3u8 file
# step 3: download m3u8
ffmpeg -i <source.m3u8> -c copy <target.ts>

Convert Video to GIF

ref: http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality

# extract frames from video
mkdir frames
ffmpeg -i <input.mp4> -vf scale=320:-1 -r 10 frames/ffout%03d.png

# merge frames to gif
convert -delay 5 -loop 0 [-crop '100%x56%'] frames/ffout*.png <output.gif

Extract Audio and Convert it to MP3

ffmpeg -i <input.mp4> <out.mp3>

Burn Subtitles into Video

ref: https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo

ffmpeg -i video.avi -vf "ass=subtitle.ass" out.avi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment