|
SageTV v7 Customizations This forums is for discussing and sharing user-created modifications for the SageTV version 7 application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss plugins for SageTV version 7 and newer. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Question about tuning scripts and post recording commands
I'm attempting to integrate Sling TV with SageTV. My testing has gone well so far. I've piped the composite and audio output to my PVR150 capture card and can view the Roku on a channel I've set up. I can also launch the app and tune a specific station stream via a script that uses CURL to send virtual keypresses.
I thought that Sage could pass channel numbers to a script or exe but it seems my memory is failing me and perhaps that was MythTV or GBPVR/nPVR that had that functionality. Is there an easy way to accomplish this in SageTV? My plan is to set up a separate channel for each Sling TV channel and ideally I'd like Sage to pass that logical channel number to a script that will digest that channel number and call the right sequence of keypresses to launch the app and tune that channel stream. Also, I would need to stop the stream at the end of the recording. Is there a mechanism that I can use to call a script that would send the keypresses to stop a stream? Otherwise I'd have SlingTV running all the time consuming much more bandwidth than necessary. Here's my original reply to the thread outlining what I'm working on: http://forums.sagetv.com/forums/show...8&postcount=20 Any info is greatly appreciated.
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#2
|
||||
|
||||
I think you're looking for the EXEMultiTunerPlugin (and yes, the file IS that old) to initiate your channel changes. Regarding triggering something at the end, I'm not sure what would work for you.
Keep in mind, this is if you are using Sage to interface with the capture card. Antoher alternative for you would be to create a network encoder, which would be a standalone program that listens to a TCP port, and gets plain text commands from sage to tune, start, and stop recordings.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#3
|
||||
|
||||
Quote:
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#4
|
||||
|
||||
Quote:
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#5
|
||||
|
||||
Thank you very much. This is really cool indeed!
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#6
|
||||
|
||||
Fuzzy, can you tell me what port this needs to be running on? I didn't see anything in the docs you sent. I'm not sure how Sage will be able to add this network tuner. In reading the docs it seems that it will autodiscover the tuner if I code it to send the NOOP command to the server, but I don't know what port the server is listening to.
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#7
|
||||
|
||||
Quote:
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#8
|
|||
|
|||
dinki,
As Fuzzy mentions, the API and autodiscovery aren't fully officially documented. I wrote a network encoder for SageTV called prime_encoder (see https://github.com/jwittkoski/prime_encoder), which allows the Sage server to tune channels on an HDHR Prime. I really wanted installing it to be as seamless as possible so I did work out the details and implement autodiscovery in prime_encoder. No manual additions to the sage.properties file are required. I reviewed a combination of the document Fuzzy listed, several other network encoders that people have written and also did some network snooping to figure out how things worked. There seemed to be multiple versions of the API (2.1, 3.0, and 4.1 are the ones I "saw" when testing). They have slightly different (mostly undocumented) formats and some of the commands are subtly different (i.e. different number of arguments or arguments in different order). I only implemented what I needed to get prime_encoder working, so I can't guarantee that my code actually implements the API correctly. However, it has been working for myself and others for almost two years without any serious problems. You may want to look at the code. It's not a complete API document but the code and comments might help. I haven't had time to better document what I learned. I'll note that most of the code is "generic" as far as the autodiscovery and API goes - it's only the "tuning" and defining how to generate the video file that are specific to the Prime, so you could replace those parts with anything else that you need. I created an issue on the github project to make the code more generic to support other video "sources" but have not done any work on it. --John |
#9
|
||||
|
||||
Quote:
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#10
|
||||
|
||||
Thank you both for the information. I'm planning on looking at all of this soon.
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#11
|
||||
|
||||
I've looked at prime_encoder source and see how it's sending the properties to the server via auto discovery, but I think that's too advanced for my skill level.
I'd like to manually create the device in sage.properties, and then work from there with the communications portion. I'm not a programmer but I can usually accomplish what I'm trying to do with some python scripts. The SDK document looks really straightforward as far as the commands go, but I could use some help setting things up on the server. Can anyone tell me what additional properties I need to set to be able to tell sage the network encoder programs address and port? I'm guess there's also a properties option for telling the server that this is a network tuner as well? I'm thinking I can copy the mmc/encoders/ entries from one of devices, change the id # (these are just unique numbers?), name, etc, and set any additional options pertaining to this being a network tuner (address, port, etc). Once I can at least talk to SageTV server I'm guessing the rest will be fairly straightforward. I'm already capable of scripting the sending of the tuning sequence to the roku and I have been able to set up an ffmpeg command that records the output of my capture card to a file. I just need to figure out how to set up the communications side between my SageTV server and the tuning and recording commands using the SDK linked above. Any help with these configuration settings would be most appreciated.
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#12
|
||||
|
||||
To answer my own question. These properties work:
Code:
mmc/encoders/124/1/0/available_channels= mmc/encoders/124/1/0/brightness=-1 mmc/encoders/124/1/0/broadcast_standard= mmc/encoders/124/1/0/contrast=-1 mmc/encoders/124/1/0/device_name= mmc/encoders/124/1/0/hue=-1 mmc/encoders/124/1/0/last_channel=2 mmc/encoders/124/1/0/provider_id=9999 mmc/encoders/124/1/0/saturation=-1 mmc/encoders/124/1/0/sharpness=-1 mmc/encoders/124/1/0/tuning_mode=Cable mmc/encoders/124/1/0/tuning_plugin= mmc/encoders/124/1/0/tuning_plugin_port=0 mmc/encoders/124/1/0/video_crossbar_index=0 mmc/encoders/124/1/0/video_crossbar_type=1 mmc/encoders/124/audio_capture_device_name= mmc/encoders/124/broadcast_standard= mmc/encoders/124/capture_config=2050 mmc/encoders/124/default_device_quality= mmc/encoders/124/delay_to_wait_after_tuning=0 mmc/encoders/124/device_class= mmc/encoders/124/encoder_merit=0 mmc/encoders/124/encoding_host=localhost\:4510 mmc/encoders/124/encoding_host_login_md5= mmc/encoders/124/fast_network_encoder_switch=false mmc/encoders/124/forced_video_storage_path_prefix= mmc/encoders/124/last_cross_index=0 mmc/encoders/124/last_cross_type=1 mmc/encoders/124/live_audio_input= mmc/encoders/124/multicast_host= mmc/encoders/124/never_stop_encoding=false mmc/encoders/124/video_capture_device_name=SageSlingBox-1 mmc/encoders/124/video_capture_device_num=0 mmc/encoders/124/video_encoding_params=Great mmc/encoders/124/encode_digital_tv_as_program_stream=true Code:
root@debian# nc -l -k -p 4510 VERSION 1 STOP OK
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
#13
|
||||
|
||||
Even a dummy (me) can do this
So I'm making great progress with my Python script. I've managed to pull enough information together to create a network device that listens for commands and acts upon them. I've done some testing and it does work though I have not added channel tuning yet. I am not a programmer, but perhaps this would be of benefit to someone thinking about writing a network encoder. It surely can be expanded but here's the basic version as it stands now:
Code:
import asyncio import os import subprocess @asyncio.coroutine def handler(reader, writer): global pid def send(msg): print("send to device: {}".format(msg)) writer.write((msg + '\n').encode()) print("device connected") while True: msg = yield from reader.readline() if not msg: print("device disconnected") break msg = msg.decode().strip() print("got from device: {}".format(msg)) if msg == 'VERSION': send('1') elif msg == 'STOP': if pid: subprocess.Popen("TASKKILL /F /PID " + str(pid) + " /T") pid = "" send('OK') elif msg == 'NOOP': send('OK') elif "BUFFER" in msg: msgsplit = msg.split('|') channel = msgsplit[1] size = msgsplit[2] filename = msgsplit[3] # Add change channel here recordcommand = ffmpeg_command + " -fs "+ size + " -y " + filename + " 2>NUL" pro = subprocess.Popen(recordcommand, shell=True) pid = pro.pid elif "GET_FILE_SIZE" in msg: msgsplit = msg.split(' ') filename = msgsplit[1] size = os.path.getsize(filename) send(str(size)) elif "START" in msg: msgsplit = msg.split('|') channel = msgsplit[1] recordtime = str(int(msgsplit[2])/1000) # Convert time from milli to seconds filename = msgsplit[3] # Add change channel here recordcommand = ffmpeg_command + " -t "+ recordtime + " -y " + filename + " 2>NUL" print (recordcommand) pro = subprocess.Popen(recordcommand, shell=True) pid = pro.pid loop = asyncio.get_event_loop() coro = asyncio.start_server(handler, '0.0.0.0', 4510, loop=loop) server = loop.run_until_complete(coro) global pid ffmpeg_command='C:/Users/User/Desktop/ffmpeg-20150928-git-235381e-win64-static/bin/ffmpeg.exe -f dshow -crossbar_video_input_pin_number 2 -i video="ATI AVStream Analog Capture" -f mpegts' try: loop.run_forever() except KeyboardInterrupt: pass server.close() loop.run_until_complete(server.wait_closed()) loop.close()
__________________
Intel Core i5-2500, 16GB RAM, OMV Linux 4.17, 3 TB of Data SageTV 9 Docker, Open DCT Docker Silicondust HDHomeRun Duo + Quatro Sage Mini Client on Amazon Fire Sticks and Android TVs |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Could I pay one of you to write some SJQ scripts for me? | FlyingShawn | SageTV v7 Customizations | 14 | 01-31-2012 04:09 AM |
Scripts: SageTV backup scripts (dailly config, full weekly, full manual) | robogeek | SageTV Customizations | 50 | 01-24-2012 07:24 AM |
PRE and POST recording times.. HOW ?? | vvulture | SageTV Software | 5 | 04-28-2007 10:26 PM |
init scripts | ChePazzo | SageTV Linux | 0 | 12-16-2006 12:28 PM |
Question about Linking Infrared commands. | flagg0204 | SageTV Software | 1 | 05-20-2004 09:42 PM |