Added some sample audio tracks to always be available
This commit is contained in:
parent
dd216e54d3
commit
87bd553bb8
BIN
data/sampleaudio/BabyElephantWalk60.mp3
Normal file
BIN
data/sampleaudio/BabyElephantWalk60.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/CantinaBand3.mp3
Normal file
BIN
data/sampleaudio/CantinaBand3.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/CantinaBand60.mp3
Normal file
BIN
data/sampleaudio/CantinaBand60.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/Fanfare60.mp3
Normal file
BIN
data/sampleaudio/Fanfare60.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/ImperialMarch60.mp3
Normal file
BIN
data/sampleaudio/ImperialMarch60.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/PinkPanther30.mp3
Normal file
BIN
data/sampleaudio/PinkPanther30.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/PinkPanther60.mp3
Normal file
BIN
data/sampleaudio/PinkPanther60.mp3
Normal file
Binary file not shown.
1
data/sampleaudio/SOURCE
Normal file
1
data/sampleaudio/SOURCE
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://www2.cs.uic.edu/~i101/SoundFiles/
|
||||||
BIN
data/sampleaudio/StarWars3.mp3
Normal file
BIN
data/sampleaudio/StarWars3.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/StarWars60.mp3
Normal file
BIN
data/sampleaudio/StarWars60.mp3
Normal file
Binary file not shown.
BIN
data/sampleaudio/taunt.mp3
Normal file
BIN
data/sampleaudio/taunt.mp3
Normal file
Binary file not shown.
50
fileradio.py
Normal file
50
fileradio.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
from streamer import Streamer, is_alive
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
class FileRadio(Streamer):
|
||||||
|
PORT = 8554
|
||||||
|
|
||||||
|
def __init__(self, path):
|
||||||
|
self.path = path
|
||||||
|
self.basename = os.path.basename(self.path)
|
||||||
|
self.name, self.ext = os.path.splitext(self.basename)
|
||||||
|
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
def _stream_path(self):
|
||||||
|
return f":{FileRadio.PORT}/sample/{self.name}"
|
||||||
|
|
||||||
|
def _stream_thread(self):
|
||||||
|
self.playback = subprocess.Popen(
|
||||||
|
[
|
||||||
|
'/usr/bin/ffmpeg', '-re', '-stream_loop', '-1', '-i',
|
||||||
|
f"{self.path}", '-c', 'copy',
|
||||||
|
'-f', 'rtsp', f"rtsp://localhost{self._stream_path()}"
|
||||||
|
],
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
|
||||||
|
while self.run:
|
||||||
|
if not is_alive(self.playback):
|
||||||
|
print('Playback failed, aborting stream.', file=sys.stderr)
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
self.run = False
|
||||||
|
|
||||||
|
self.playback.kill()
|
||||||
|
self.playback.wait()
|
||||||
|
self.playback = None
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
fr = FileRadio('./data/sampleaudio/taunt.mp3')
|
||||||
|
fr.start_stream()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
time.sleep(1)
|
||||||
@ -1,9 +1,12 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import requests
|
import requests
|
||||||
import SoapySDR as soapy
|
import SoapySDR as soapy
|
||||||
from radio import Radio
|
from radio import Radio
|
||||||
from tuuube import Tuuube
|
from tuuube import Tuuube
|
||||||
|
from fileradio import FileRadio
|
||||||
|
|
||||||
from flask import Flask, jsonify
|
from flask import Flask, jsonify
|
||||||
from flasgger import Swagger
|
from flasgger import Swagger
|
||||||
@ -257,6 +260,13 @@ if __name__ == '__main__':
|
|||||||
stderr=subprocess.DEVNULL
|
stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for path, _, files in os.walk('./data/sampleaudio'):
|
||||||
|
for file in files:
|
||||||
|
name,ext = os.path.splitext(file)
|
||||||
|
if ext == '.mp3':
|
||||||
|
tubes[name] = FileRadio(f"{path}/{file}")
|
||||||
|
tubes[name].start_stream()
|
||||||
|
|
||||||
app.run(
|
app.run(
|
||||||
host='0.0.0.0',
|
host='0.0.0.0',
|
||||||
threaded=True,
|
threaded=True,
|
||||||
|
|||||||
8
scripts/wav2mp3.sh
Executable file
8
scripts/wav2mp3.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
path="${arg%/*}"
|
||||||
|
file="${arg##*/}"
|
||||||
|
filename="${file%%.*}"
|
||||||
|
ffmpeg -i $path/$file -vn -ar 44100 -ac 2 -b:a 100k $path/$filename.mp3
|
||||||
|
done
|
||||||
Loading…
Reference in New Issue
Block a user