Project

General

Profile

Bug #3630

pipe doesn't work on mux url but works on command line

Added by Jose Silva over 8 years ago. Updated over 8 years ago.

Status:
Invalid
Priority:
Normal
Assignee:
-
Category:
IPTV
Target version:
-
Start date:
2016-03-15
Due date:
% Done:

0%

Estimated time:
Found in version:
4.1-1429~ge29df17~jessie
Affected Versions:

Description

This works on command line:

rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf" -p "http://www.rtp.pt/play/direto/rtp1" --live --timeout 15 -q -o test.flv

But it doesn't work as piped url for mux:

pipe:///usr/bin/rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf" -p "http://www.rtp.pt/play/direto/rtp1" --live --timeout 15 -q pipe:1

Result:
2016-03-15 00:44:38.766 subscription: 016A: "scan" subscribing to mux "RTP 1 Test", weight: 6, adapter: "IPTV", network: "IPTV Test", service: "Raw PID Subscription"
2016-03-15 00:44:38.947 iptv: stdin pipe unexpectedly closed: No data
2016-03-15 00:44:53.000 mpegts: RTP 1 Test in IPTV Test - scan no data, failed
2016-03-15 00:44:53.000 subscription: 016A: "scan" unsubscribing

rtp1.pt is Portuguese national television official site.

Shouldn't this work?

History

#1

Updated by Jaroslav Kysela over 8 years ago

You should discover, why the program aborts when run as the pipe. Redirecting stderr to a file might help.

#2

Updated by Jose Silva over 8 years ago

Thank you for the suggestion, I should have thought of that myself.

Anyway, I tried and it doesn't work the usual way:

pipe:///usr/bin/rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf" -p "http://www.rtp.pt/play/direto/rtp1" --live --timeout 15 2> /home/hts/errors.log pipe:1 # took out the -q quiet option

I think I don't know enough about pipe://, can you suggest the right way, please?

#3

Updated by Jose Silva over 8 years ago

Actually I thing the process isn't even getting spawned and that's why I can't get the stderr to a file.

I made a file:
-rwxrwxrwx 1 pi pi 256 Mar 15 13:08 /home/pi/bin/rtmptest.sh

containing:
echo "Hi" > /home/hts/sign && /usr/bin/rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf?v3" -p "http://www.rtp.pt/play/direto/rtp1?mag" --live --timeout 15 2> /home/pi/error.log

and touched /home/hts/sign:
rw-rw-rw 1 hts hts 0 Mar 15 13:10 /home/hts/sign

Then inserted in the mux url window:
pipe:///home/pi/bin/rtmptest.sh pipe:1

And fired it by making Scan Status= PEND and saving. The debug windows says:

2016-03-15 13:19:58.443 mpegts: RTP 1 Test in IPTV Test - tuning on IPTV
2016-03-15 13:19:58.451 spawn: Executing "/home/pi/bin/rtmptest.sh"
2016-03-15 13:19:58.455 subscription: 017F: "scan" subscribing to mux "RTP 1 Test", weight: 6, adapter: "IPTV", network: "IPTV Test", service: "Raw PID Subscription"
2016-03-15 13:19:58.458 iptv: stdin pipe unexpectedly closed: No data
2016-03-15 13:20:13.000 mpegts: RTP 1 Test in IPTV Test - scan no data, failed
2016-03-15 13:20:13.000 subscription: 017F: "scan" unsubscribing

But in fact rtmptest.sh never gets executed, although the debug windows says it is, because it neither shows with ps aux nor /home/hts/sign gets written.

Of course I tested /home/pi/bin/rtmptest.sh on the command line and it works correctly.

Hope you can shed some light on this.

#4

Updated by danny skjodt over 8 years ago

Jose Silva wrote:

This works on command line:

rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf" -p "http://www.rtp.pt/play/direto/rtp1" --live --timeout 15 -q -o test.flv

But it doesn't work as piped url for mux:

pipe:///usr/bin/rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf" -p "http://www.rtp.pt/play/direto/rtp1" --live --timeout 15 -q pipe:1

Result:
2016-03-15 00:44:38.766 subscription: 016A: "scan" subscribing to mux "RTP 1 Test", weight: 6, adapter: "IPTV", network: "IPTV Test", service: "Raw PID Subscription"
2016-03-15 00:44:38.947 iptv: stdin pipe unexpectedly closed: No data
2016-03-15 00:44:53.000 mpegts: RTP 1 Test in IPTV Test - scan no data, failed
2016-03-15 00:44:53.000 subscription: 016A: "scan" unsubscribing

rtp1.pt is Portuguese national television official site.

Shouldn't this work?

Just so you know, rtmpdump will dump flv, tvheadend pipe only takes mpegts, so you need to make it into that first with like ffmpeg.

#5

Updated by Jaroslav Kysela over 8 years ago

Also, you must put this as the first line to your shell script:

#!/bin/bash

... your code here ...

And do 'chmod a+x <script>', too.

#6

Updated by Jose Silva over 8 years ago

Thank you for the guidance, I forgot the #!bin/bash and I was misled by the fact that it was running on the command line, the +x was set.

So, the main issue I was overlooking was that I was feeding .flv and didn't understand the pipe was expecting only mpegts.

Now I modified the script to:

#!/bin/bash
/usr/bin/rtmpdump -r "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" -y "2ch5h264" -W "http://programas.rtp.pt/play/player.swf?v3" -p "http://www.rtp.pt/play/direto/rtp1?mag" --live --timeout 15 2> /home/pi/error.log | avconv -i - -codec copy -bsf:v h264_mp4toannexb,dump_extra -metadata service_provider=PROVIDER -metadata service_name=SERVICE -tune zerolatency -f mpegts -

And got a valid subscription. But this is still a bit "shaky" and I would like to move this to the mux url field to avoid having one script for each stream.
Furthermore, there are some parameters to avconv that I just quickly copied from the example of the wiki "Custom MPEG-TS Input" and I don't know exactly how they work and so there's still some work to do.

But I must confess: the pipe:// works, I was wrong.

Thank you for the lecture. Please feel free to correct the script hereby, for the benefit of future readers, and also my own.

#7

Updated by Jose Silva over 8 years ago

Hello again,

I'm sorry to insist, I think the pipe works, but not completely.

This works:
pipe:///home/pi/bin/rtmptest.sh

/home/pi/bin/rtmptest.sh:
#!/bin/bash
/usr/bin/rtmpdump --rtmp "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" --playpath "2ch5h264" --swfVfy "http://programas.rtp.pt/play/player.swf?v3" --pageUrl "http://www.rtp.pt/play/direto/rtp1?mag" --live | avconv -re -v error -fflags +genpts -i pipe:0 -bsf h264_mp4toannexb -vcodec copy -acodec copy -f mpegts pipe:1

But this doesn't (and should, or not?)
pipe:///usr/bin/rtmpdump --rtmp "rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live" --playpath "2ch5h264" --swfVfy "http://programas.rtp.pt/play/player.swf?v3" --pageUrl "http://www.rtp.pt/play/direto/rtp1?mag" --live | avconv -re -v error -fflags +genpts -i pipe:0 -bsf h264_mp4toannexb -vcodec copy -acodec copy -f mpegts pipe:1

Shows debug:
2016-03-16 15:31:17.967 mpegts: RTP 1 Test in IPTV Test - tuning on IPTV
2016-03-16 15:31:17.976 spawn: Executing "/usr/bin/rtmpdump"
2016-03-16 15:31:17.980 subscription: 02EC: "scan" subscribing to mux "RTP 1 Test", weight: 6, adapter: "IPTV", network: "IPTV Test", service: "Raw PID Subscription"
2016-03-16 15:31:18.000 spawn: 894.114 kB / 8.30 secRTMPDump v2.4
2016-03-16 15:31:18.000 spawn: (c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
2016-03-16 15:31:18.000 spawn: WARNING: Unknown protocol!
2016-03-16 15:31:18.000 spawn: ERROR: RTMP URL: No :// in url!
2016-03-16 15:31:18.000 spawn: WARNING: Couldn't parse the specified url (e)!
2016-03-16 15:31:18.000 spawn: WARNING: You haven't specified an output file (-o filename), using stdout
2016-03-16 15:31:18.001 spawn: ERROR: RTMP_HashSWF: couldn't contact swfurl "http://programas.rtp.pt/play/player.swf?v3" (HTTP error -1)
2016-03-16 15:31:18.001 spawn: ERROR: RTMP URL: No :// in url!
2016-03-16 15:31:18.001 spawn: ERROR: Couldn't parse URL: pipe:0
2016-03-16 15:31:18.002 iptv: stdin pipe unexpectedly closed: No data
2016-03-16 15:31:32.000 mpegts: RTP 1 Test in IPTV Test - scan no data, failed
2016-03-16 15:31:32.000 subscription: 02EC: "scan" unsubscribing

The ERROR: RTMP URL: No :// in url! leads me to think that the paramenters are not being passed (or not correctly) to the spawn rtmpdump. I tried without double-quotes as well.

Or I might be not be using the pipe correctly.

#8

Updated by Jaroslav Kysela over 8 years ago

  • Status changed from New to Invalid

You cannot double pipes. It's shell thing (you run two programs through pipe). TVH allows to run only one program and grab stdout from it. Also " and ' strings is shell thing. You should not use this in pipe:// . All spaces behaves like argument delimiters, but you may use \ escape key for a space inside argument.

#9

Updated by Jose Silva over 8 years ago

Thank you for one more lecture, I've learned a lot from you.

I'll stick to an intermediary solution:

pipe:///home/pi/bin/htsrtmp.sh rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live 2ch5h264 http://programas.rtp.pt/play/player.swf?v3 http://www.rtp.pt/play/direto/rtp1?mag

and a common script for all channels needing this, accepting the specific parameters:
/home/pi/bin/htsrtmp.sh:

#!/bin/bash
/usr/bin/rtmpdump -r "$1" -y "$2" -W "$3" -p "$4" --live --timeout 15 | avconv -re -v error -fflags +genpts -i pipe:0 -bsf h264_mp4toannexb -vcodec copy -acodec copy -f mpegts pipe:1

It's working, thank you again.

#10

Updated by Jose Silva over 8 years ago

Got it!!! No outside script needed.

Here it is, for others benefit:

pipe:///usr/bin/avconv -re -v error -fflags +genpts -rtmp_playpath 2ch5h264 -rtmp_swfverify http://programas.rtp.pt/play/player.swf?v3 -rtmp_pageurl http://www.rtp.pt/play/direto/rtp1?mag -rtmp_live live -i rtmp://rtppullswflivefs.fplive.net/rtppullswflive-live -vcodec copy -acodec copy -bsf h264_mp4toannexb -f mpegts pipe:1

Thank you developers for your wonderful work.

Also available in: Atom PDF