Skip to content

Instantly share code, notes, and snippets.

@stefansundin

stefansundin/ffmpeg.rb

Last active Sep 11, 2020
Embed
What would you like to do?
Download Twitch video that has muted sound.
#!/usr/bin/env ruby
files = Dir["*.ts"].sort_by { |fn| fn.split(".")[0].to_i }
puts "ffmpeg -i 'concat:#{files.join("|")}' -codec copy output.mkv"
puts
puts "run this first:"
puts "ulimit -n 4096"
#!/usr/bin/env ruby
# https://www.twitch.tv/videos/574519037
playlist_url = "http://dqrpb9wgowsf5.cloudfront.net/afe4f2fd56853c62507b_monstercat_37252580992_1397079807/chunked/index-muted-YE1NQ5PUXI.m3u8"
playlist_baseurl = playlist_url[0..playlist_url.rindex("/")]
File.read("index-muted-YE1NQ5PUXI.m3u8").split("\n").reject { |line| line.start_with?("#") }.each do |line|
url = if !line.start_with?("http://", "https://")
"#{playlist_baseurl}#{line}"
else
line
end
if url.end_with?("-muted.ts")
url = url[..-("-muted.ts".length+1)] + ".ts"
end
puts "wget #{url}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.