basic streaming to icecast
This commit is contained in:
		
							parent
							
								
									7c318896be
								
							
						
					
					
						commit
						f398cc448b
					
				| @ -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 ]; | ||||
| } | ||||
| @ -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", | ||||
|  | ||||
							
								
								
									
										18
									
								
								radio.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								radio.py
									
									
									
									
									
								
							| @ -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) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user