basic streaming to icecast

This commit is contained in:
zuckerberg 2021-05-28 22:19:37 -04:00
parent 7c318896be
commit f398cc448b
4 changed files with 11 additions and 13 deletions

View File

@ -4,5 +4,5 @@ pkgs.python3Packages.buildPythonApplication {
pname = "radio"; pname = "radio";
src = self; src = self;
version = "0.1"; version = "0.1";
propagatedBuildInputs = with pkgs.python3Packages; [ pip ffmpeg-python youtube-dl ]; propagatedBuildInputs = with pkgs.python3Packages; [ pip ffmpeg-python ];
} }

View File

@ -31,7 +31,7 @@ def executeYoutubeDL(url, cb):
"-o", "-", "-o", "-",
"-f", "bestaudio/best", "-f", "bestaudio/best",
# "--extract-audio", # "--extract-audio",
"--audio-format", "wav", "--audio-format", "mp3",
"--prefer-ffmpeg", "--prefer-ffmpeg",
#"--postprocessor-args", "-re", #"--postprocessor-args", "-re",
#"--external-downloader", "ffmpeg", #"--external-downloader", "ffmpeg",

View File

@ -3,20 +3,18 @@ import ffmpeg
import sys import sys
def run(): def run():
# process = ( process = ( ffmpeg
# ffmpeg .input('pipe:', re=None)
# .input('pipe:', format='wav') .output("icecast://source:hackme@localhost:8000/stream.mp3", format='mp3', content_type="audio/mpeg")
# .output("icecast://source:hackme@localhost:8000/stream.mp3", format='mp3', content_type="audio/mpeg") .run_async(pipe_stdin=True)
# .global_args("-re") # argument to act as a live stream )
# .run_async(pipe_stdin=True)
# )
def cb(chunk): def cb(chunk):
# process.stdin.write(chunk) process.stdin.write(chunk)
sys.stdout.write("".join(map(chr, chunk)))
return False return False
downloader.download('https://www.youtube.com/watch?v=BaW_jenozKc', cb) downloader.download('https://www.youtube.com/watch?v=EbnH3VHzhu8', cb)
# downloader.download('https://www.youtube.com/watch?v=BaW_jenozKc', cb)
# downloader.download('https://www.youtube.com/watch?v=kgBcg4uBd9Q', cb) # downloader.download('https://www.youtube.com/watch?v=kgBcg4uBd9Q', cb)
# downloader.download('https://www.youtube.com/watch?v=EbnH3VHzhu8', cb) # downloader.download('https://www.youtube.com/watch?v=EbnH3VHzhu8', cb)

View File

@ -1,6 +1,6 @@
from setuptools import setup from setuptools import setup
requires = ["pip"] requires = ["pip","ffmpeg-python"]
setup( setup(
name='radio', name='radio',