From 5ba5ad9ac3f2b2728312a0ef864b2a31dfe2b082 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Thu, 21 Sep 2023 19:53:23 -0600 Subject: [PATCH] Stream URL to sndid-server --- sndid-stream | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 sndid-stream diff --git a/sndid-stream b/sndid-stream new file mode 100755 index 0000000..cdaa247 --- /dev/null +++ b/sndid-stream @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +""" +sndid-stream + +Copyright 2023, Jeff Moe + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import argparse +import os + +parser = argparse.ArgumentParser(description="Run sndid-client") +parser.add_argument( + "-i", + "--ip", + help="Server IP address (default 127.0.0.1)", + type=str, + required=False, + default="127.0.0.1", +) +parser.add_argument( + "-p", + "--port", + help="Server network port (default 9988)", + type=int, + required=False, + default="9988", +) +parser.add_argument( + "-t", + "--time", + help="Length of segments in seconds (default 60)", + type=int, + required=False, + default="60", +) +parser.add_argument("-u", "--url", help="Input url", type=str, required=True) + +args = parser.parse_args() +IP = args.ip +PORT = str(args.port) +TIME = str(args.time) +URL = args.url + +CMD = ( + "ffmpeg -hide_banner -loglevel quiet -i " + + "'" + + URL + + "'" + + " -acodec pcm_s16le -ac 1 -vcodec vnull -f wav -t " + + TIME + + " - 2>/dev/null | nc -q 0 " + + IP + + " " + + PORT +) + +# XXX +while 1: + print("Sending " + URL + " to " + IP + ":" + PORT) + os.system(CMD)