Last active
December 1, 2017 17:34
-
-
Save lkfken/e6c1ac543937ad439e724bbecfb1f02e to your computer and use it in GitHub Desktop.
save audio stream to .m4a file using VLC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'pp' | |
require 'pathname' | |
url = URI('http://66.55.135.155:8000/Channel1') | |
##### VLC ##### | |
stop_time = ARGV.shift # duration in secords | |
abort 'no stop tiime defined' unless stop_time | |
visible = true | |
vlc_path = Pathname('c:/usr/bin/VLC') | |
vlc = visible ? vlc_path + 'vlc.exe' : vlc_path + 'cvlc.exe' | |
############### | |
##### target file ##### | |
target_dir = File.join('c:', 'usr') | |
stream_tag = 'Singtao' | |
savedir = Pathname(File.join(target_dir, Time.now.strftime('%Y%m%d'))) | |
filename = savedir + Time.now.strftime("#{stream_tag}_%Y%m%d_%H%M%S.m4a") | |
##### target file ##### | |
savedir.mkpath | |
pp cmd = "#{[vlc.to_s, url.to_s, '--sout', "file/mp4:#{filename}", "--stop-time=#{stop_time}", 'vlc://quit'].join(' ')}" | |
`#{cmd}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment