[mythtv-users] IPTV recorder seems broken -- large jumpy files

Brian J. Murrell brian at interlinx.bc.ca
Mon Mar 19 11:47:19 UTC 2018


On Sun, 2018-03-18 at 14:51 -0400, Greg Thompson wrote:
> 
> Would you mind sharing your script or code to do this? I am looking
> at
> doing something like this myself with my TBS2603 HDMI to IP encoder
> due to
> some Live TV issues with the IPTV recorder.

Sure:

#!/bin/bash

exec 3>/var/tmp/"${0##*/}".debug$$
export BASH_XTRACEFD=3
set -x
echo "$@" >&3
env >&3

send() {

    echo "Sending $1" >&3
    echo "$1" >&2

}

while read -r cmd; do
    echo "Got \"$cmd\"" >&3
    case $cmd in
        "Version?")
            send "OK:1.0.0"
            ;;
        "HasTuner?")
            send "OK:Yes"
            ;;
        "CloseRecorder")
            send "OK:Terminating"
            exit 0
            ;;
        "HasPictureAttributes?")
            send "OK:No"
            ;;
        "FlowControl?")
            send "OK:XON/XOFF"
            ;;
        BlockSize:*)
            send "OK"
            ;;
        TuneChannel:*)
	    channel=${cmd##*:}
	    case $channel in
	        3) URL="https://..."
		;;
	        4) URL="https://..."
		;;
            esac
            send "OK"
            ;;
        "LockTimeout?")
            send "OK:5000"
            ;;
        "SignalStrengthPercent?")
            send "OK:100"
            ;;
        "HasLock?")
            send "OK:Yes"
            ;;
        "StartStreaming")
            ffmpeg -i "$URL" -acodec copy -vcodec copy -f mpegts - 2>&3 &
            ffmpeg_pid=$!
            send "OK:Started"
            ;;
        "StopStreaming")
            if [ -n "$ffmpeg_pid" ] && [ -d /proc/$ffmpeg_pid ]; then
                kill $ffmpeg_pid
            fi
            send "OK:Stopped"
            ;;
        "IsOpen?")
            if [ -n "$ffmpeg_pid" ] && [ -d /proc/$ffmpeg_pid ]; then
                send "OK:Open"
            else
                send "OK:No"
            fi
            ;;
        "XON")
            echo "Uh oh! need to handle \"$cmd\" at $(date)" >&3
            send "OK"
            ;;
        "XOFF")
            echo "Uh oh! need to handle \"$cmd\" at $(date)" >&3
            send "OK"
            ;;
        *)
            echo "Unknown cmd \"$cmd\"" >&3
            ;;
    esac
done

Clearly, this hack doesn't handle flow control but it seems to get the
job done.

I did come across a python External recorder in my research that did
handle flow control.

Cheers,
b.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20180319/d08c4963/attachment.sig>


More information about the mythtv-users mailing list