Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input RTMP or UDS Multicast #85

Closed
Letme opened this issue Mar 20, 2019 · 9 comments
Closed

Input RTMP or UDS Multicast #85

Letme opened this issue Mar 20, 2019 · 9 comments
Assignees
Labels

Comments

@Letme
Copy link

Letme commented Mar 20, 2019

I have an enhancement request.

Some background: There is a camera with production PC on premises which streams RTMP or UDS Multicast streams to server (located outside) to which users then connect. Reason for this is that on premises network/internet connection is really poor and could not handle multiple users, while server outside could. I also do not have any influence on the connection, so opening ports and setting up a server is out of the question.

Reading through documentation the most close input seems IP Camera, but also there you enter the IP of the camera (basically location of the stream). That would mean that I need a on premises rtsp server to which restreamer would connect, but that is not possible for above reasons.

Summary for the enhancement request: Provide a port on which restreamer is listening for input video&audio stream in RTMP or UDS Multicast, which is then handled and re-streamed through outputs.

@ioppermann
Copy link
Member

Hi

This is already possible with Restreamer, but it is not officially documented.

Inside the Restreamer Docker container is a RTMP-Server running (nginx-rtmp) that you can use to push streams to. To have access to the RTMP-Server, you have to expose the port 1935 of the Docker container, e.g.

docker run ... -p 1935:1935 ... datarhei/restreamer

This is inheritly dangerous because anyone can now push RTMP streams to your box. In order to protect the RTMP-Server you should define a token, e.g.

docker run ... -p 1935:1935 -e RS_TOKEN=a-secret-only-you-know ... datarhei/restreamer

Now you can push a RTMP-Stream to, e.g. rtmp://[address of your box]/live/external.stream?token=....

Navigate to the Restreamer web interface, e.g. http://[address of your box]:8080/. For the video source you enter the same address you are pushing to, and replace the public address and port with localhost, i.e. rtmp://localhost/live/external.stream?token=....

Now you can forward it to an other RTMP-Server or embed the player in a website.

@ioppermann ioppermann self-assigned this Mar 20, 2019
@Letme
Copy link
Author

Letme commented Mar 20, 2019

Cool. I tried it and it works (benchtesting, but on 2 locations). RPI3 had a load of 0.6 with 2 viewers and myself. I doubt there was any encoding done on it as stream was 2kbps/25fps.

Thanks for the answer.

@ioppermann
Copy link
Member

👍

No, there is no encoding happening. Only audio may get encoded depending on the RS_AUDIO setting.

@cacheman
Copy link

Hi....

I'm sure I'm doing something wrong here. I'm streaming from OBS Studio as per #58 but when I go to http://[address of your box]:8080/ and enter rtmp://localhost/live/external.stream?token=XXXX I just get 'Your video stream wasn't accessible - No video stream detected'.....or 'Your video stream wasn't accessible - Error: ffmpeg exited with code 1'

Would be grateful for any pointers on how to resolve, debug or troubleshoot this.

Thanks in advance.

Cacheman.

image

image

@mmilunovic
Copy link

@cacheman I got exactly the same issue, did you manage to solve it?

@cacheman
Copy link

Hi....

No....and so far no one has replied (apart from you) on this.

I did get into the running docker image with an interactive shell and was able to run the ffprobe and ffmpeg commands that the image is trying to run when you click on 'Start' on the web interface.

The output from ffbrobe shows it does detect video and audio content in the stream:

root@dacdbe4012fc:/restreamer# /usr/local/bin/ffprobe -show_streams -show_format rtmp://localhost/live/external.stream?token=testrtmp
ffprobe version 4.1.3 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --bindir=/usr/local//bin --extra-cflags=-I/usr/local//include --extra-ldflags=-L/usr/local//lib --prefix=/usr/local/ --enable-nonfree --enable-gpl --enable-version3 --enable-libmp3lame --enable-libx264 --enable-openssl --enable-postproc --enable-small --enable-static --disable-debug --disable-doc --disable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, flv, from 'rtmp://localhost/live/external.stream?token=testrtmp':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 1280
    displayHeight   : 720
    fps             : 30
    profile         :
    level           :
  Duration: 00:00:00.00, start: 230.620000, bitrate: N/A
    Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 163 kb/s
    Stream #0:1: Video: h264, yuv420p(progressive), 1280x720, 2560 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc
[STREAM]
index=0
codec_name=aac
codec_long_name=unknown
profile=1
codec_type=audio
codec_time_base=1/44100
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=230620
start_time=230.620000
duration_ts=N/A
duration=N/A
bit_rate=163840
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=h264
codec_long_name=unknown
profile=100
codec_type=video
codec_time_base=1/60
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=1280
height=720
coded_width=1280
coded_height=720
has_b_frames=0
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=31
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/1000
start_pts=233333
start_time=233.333000
duration_ts=N/A
duration=N/A
bit_rate=2560000
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=rtmp://localhost/live/external.stream?token=testrtmp
nb_streams=2
nb_programs=0
format_name=flv
format_long_name=unknown
start_time=230.620000
duration=0.000000
size=N/A
bit_rate=N/A
probe_score=100
TAG:Server=NGINX RTMP (github.com/arut/nginx-rtmp-module)
TAG:displayWidth=1280
TAG:displayHeight=720
TAG:fps=30
TAG:profile=
TAG:level=
[/FORMAT]

.....and ffmpeg seems to be able to take input from the URL you would normally type into the web interface and output it to a HLS stream:

root@dacdbe4012fc:/restreamer# /usr/local/bin/ffmpeg -stats -loglevel quiet -err_detect ignore_err -re -i rtmp://localhost/live/external.stream?token=testrtmp -map_metadata -1 -metadata application=datarhei/Restreamer -f flv -codec:v copy -map 0:1 -vsync 0 -copyts -start_at_zero -codec:a copy -bsf:a aac_adtstoasc -map 0:0 rtmp://127.0.0.1:1935/hls/live.stream?token=testrtmp```

frame=  170 fps= 20 q=-1.0 size=    1945kB time=00:00:08.59 bitrate=1853.8kbits/s speed=   1x

But I can't seem to get any further than that....these are the commands that get started by the web interface when you click 'Start', but something in the web interface doesn't like the output.....and when I run the ffmpeg command manually, I can't figure out how to connect to it from another device to receive the stream.

If you ever manage to solve the problem, please let me know....I'll do likewise.

HTH.

Cacheman

@mmilunovic
Copy link

@cacheman I've abandoned the Restreamer approach, but if I return to it sometime I'll let you know.

@cacheman
Copy link

Hi....

Yeah me too. The other day, I actually did get it to work, but only once. It was rock solid for as long as I left it running (~4 hours). But of course it's not much use if I can't stop it and start it at will....since I stopped it after that 1 successful run, I haven't been able to get it going again.

I suspect there is some interaction between ffmpeg, nginx and possibly ffprobe that is timing out and generating an error. I have noticed that there are plenty of occasions when I ran the ffmpeg manually at the command line in the docker image (see my previous post) in which ffmpeg thinks there is no video in the stream....it only detects audio.

Anyway, I may come back to this if restreamer gets updated at some point in the future.

C ya.

Cacheman

@FilipStadler
Copy link

Well I use nginx proxy manager on a rpi4 this handle ssl with LTE or I can use the cloudflare ssl costum solution.

I do portforward of the tcp 1935 and udp 6000 for another raspberryPI 4 running the restreamer and port 80,443
does the nginx proxy manager handle so stream.domainame.dk do point to maybe 192.168.10.17:8080.
On cloudflare I can turn proxy on/off so its hidden behind cloudflare but I think you need the payed cloudlfare
to get real performance boost else its more passtru but maybe someone have tried the payed setup ?

Another great thing sometimes my ISP change my IP and the need for DDNS is needed - I currently use
my ASUS router DDNS solution and use a cname in the cloudflare DNS - i have two names made in DNS setup where one is points to the ip and another is proxyed by cloudflare and hidden - so I transmit from OBS to the non hidden but users can view the restreamer on https - I have not tried to stream TX to/via proxy at this gives two IP when tries to resolve the name and maybe srt and would not work but I have not tried but my focus was mainly on how it would work from possible vievers.

I have not tried the cloudflare Tunnel solution but it sounds like a nice way to avoid firewall configuration - maybe a way to get one restreamer connect to another restreatmer (almost like a vpn) ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants