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";
src = self;
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", "-",
"-f", "bestaudio/best",
# "--extract-audio",
"--audio-format", "wav",
"--audio-format", "mp3",
"--prefer-ffmpeg",
#"--postprocessor-args", "-re",
#"--external-downloader", "ffmpeg",

View File

@ -3,20 +3,18 @@ import ffmpeg
import sys
def run():
# process = (
# ffmpeg
# .input('pipe:', format='wav')
# .output("icecast://source:hackme@localhost:8000/stream.mp3", format='mp3', content_type="audio/mpeg")
# .global_args("-re") # argument to act as a live stream
# .run_async(pipe_stdin=True)
# )
process = ( ffmpeg
.input('pipe:', re=None)
.output("icecast://source:hackme@localhost:8000/stream.mp3", format='mp3', content_type="audio/mpeg")
.run_async(pipe_stdin=True)
)
def cb(chunk):
# process.stdin.write(chunk)
sys.stdout.write("".join(map(chr, chunk)))
process.stdin.write(chunk)
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=EbnH3VHzhu8', cb)

View File

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