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

RTMP Support #885

Open
clik86 opened this issue May 24, 2018 · 14 comments
Open

RTMP Support #885

clik86 opened this issue May 24, 2018 · 14 comments

Comments

@clik86
Copy link

clik86 commented May 24, 2018

I see previous issues (like #188) on this topic but now motion supports rtmp input stream. I test it with one of my camera. It works on motion alone but the motion eye interface refuse url starting with rtmp scheme.
I look at the code to see how it works but you seam to test the connection before being able to add it and i'm not an RTMP protocol expert so I can't help you.

@ccrisan
Copy link
Collaborator

ccrisan commented May 29, 2018

@clik86 can you give me an example of such an URL?

@neur0maniak
Copy link

I too would like to see this feature implemented.

It should be trivial to set up a VM for testing.
At least in ubuntu, it should be enough to:
sudo apt install nginx libnginx-mod-rtmp
and then add to the bottom of: /etc/nginx/nginx.conf

rtmp {
        server {
                listen 1935;
                chunk_size 4096;
		notify_method get;
                application live {
                        live on;
                        record off;
                }
        }
}

restart nginx sudo systemctl restart nginx

send a stream for it to relay:
ffmpeg -f v4l2 -i /dev/video0 -c:v h264_omx -an -f flv rtmp://xxx.xxx.xxx.xxx/live/mycam
and the URL to view it will be:
rtmp://xxx.xxx.xxx.xxx/live/mycam
where xxx.xxx.xxx.xxx is the ip/fqdn of the nginx server.

@epruesse
Copy link

@ccrisan +1 for me.

This is helpful for ReoLink cams which suffer from "smearing" when viewed via RTSP. See https://forums.zoneminder.com/viewtopic.php?p=108502#p108502

ReoLink URLs are constructed as follows:

rtmp://​{{IP}}​/bcs/channel0_​{{STREAM}}​.bcs?channel=0&stream=0&user=​{{USER}}&password=​{{PASS}}

rtsp://{{USER}}:{{PASS}}​@​{{IP}}​:554//h264Preview_01_{{STREAM}}

where STREAM is usually main (for full res stream).

Manually editing the netcam_url works, so this should be easy. It's supported as of motion >4.1.0, although the resolution drop-down disappears and the width has to be added manually.

@CMDR-Sloma
Copy link

@ccrisan +1 from me as well

If rtmp works, then this would be perfect as my Reolink cameras in motion eye suffer from low frame rate and smearing. While VLC with rtsp works flawlessly with high resolution and high frame rate motioneye has really sub par performance despite being run on an Intel NUC.

@Kanga-Who
Copy link

Any update on support for the RTMP streams? I have just purchased a Reolink RLC-410-5mp camera and can confirm that in Motioneye smears the RTSP badly, and makes motion capture impossible.

The camera operates flawlessly in VLC, so unsure of the issue.

@jasaw
Copy link
Contributor

jasaw commented Jul 22, 2019

Is the RTMP supported in motion software? Can you guys please run motion without motionEye?

Stop motionEye:

systemctl stop motioneye  # for systemd 
/etc/init.d/motioneye stop  # for sysvinit

Run motion in the foreground:

cd /etc/motioneye
motion -c motion.conf -d 6 -n

Check whether RTMP works. If it doesn't, follow this guide and report it to motion developers.

@bwachter
Copy link

bwachter commented Aug 13, 2019

Works with this:

netcam_url rtmp://cam1.cameras/bcs/channel0_sub.bcs?channel=0&stream=1&user=motion&password=

netcam_userpass needed to be empty, I guess the basic auth doesn't work with rtmp.

[-1372602752:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file motion.conf
[-1372602752:motion] [NTC] [ALL] config_camera: Processing camera config file camera-1.conf
[-1372602752:motion] [NTC] [ALL] motion_startup: Motion 4.1.1 Started
[-1372602752:motion] [NTC] [ALL] motion_startup: Logging to syslog
[-1372602752:motion] [NTC] [ALL] motion_startup: Using default log type (ALL)
[-1372602752:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[-1372602752:motion] [NTC] [ENC] ffmpeg_global_init: ffmpeg libavcodec version 57.107.100 libavformat version 57.83.100
[0:motion] [NTC] [ALL] main: Camera ID: 1 is from camera-1.conf
[0:motion] [NTC] [ALL] main: Camera ID: 1 Camera Name: Garage Service: rtmp:
[0:motion] [NTC] [ALL] main: Stream port 8081
[0:motion] [NTC] [ALL] main: Waiting for threads to finish, pid: 16861
[1:ml1:Garage] [NTC] [ALL] motion_init: Camera 1 started: motion detection Enabled
[1:ml1:Garage] [NTC] [VID] vid_start: Opening Netcam RTSP
[0:wc0] [NTC] [STR] http_bindsock: listening on 127.0.0.1 port 7999
[0:wc0] [NTC] [STR] httpd_run: Started motion-httpd server on port 7999 (auth Disabled)
[1:ml1:Garage] [NTC] [NET] netcam_rtsp_connect: Normal resolution: Camera (Garage) connected
[1:ml1:Garage] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[3:nc3:Garage] [NTC] [NET] netcam_rtsp_handler: Normal resolution: Camera handler thread [3] started
[1:ml1:Garage] [NTC] [STR] http_bindsock: listening on any IPv4 address port 8081
[1:ml1:Garage] [NTC] [ALL] motion_init: Started motion-stream server on port 8081 (auth Disabled)
[1:ml1:Garage] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 21 items
[3:nc3:Garage] [NTC] [NET] netcam_rtsp_connect: Normal resolution: Camera (Garage) connected
[1:ml1:Garage] [NTC] [ENC] ffmpeg_set_codec: Low fps. Encoding 4 frames into a 10 frames container.
[1:ml1:Garage] [NTC] [EVT] event_newfile: File of type 8 saved to: /srv/camstor1/Garage/2019-08-13/19-48-25.mp4
[1:ml1:Garage] [NTC] [ALL] motion_detected: Motion detected - starting event 1
curl: (7) Failed to connect to 127.0.0.1 port 8765: Connection refused

With the rtmp URL manually configured this also worked with motion 4.1 and motioneye 0.4.0. With motion 4.2 the web preview in motioneye is broken (but capture still working), motion 4.2.2 contains a fix for that.

Also highres stream for capture works by just adding '
netcam_highres rtmp://[...]' to the extra motion options.

@thd99
Copy link

thd99 commented Oct 14, 2019

+1, yes please. As mentioned above, with Reolink cameras this should solve smearing issues.

Another example url is: rtmp://x.x.x.x/bcs/channel0_main.bcs?channel=0&stream=0&user=user&password=password.

Haven't tried with motion but works for me with ffmpeg (I'm on 4.1.4-1~deb10u1).

@mcd1992
Copy link
Contributor

mcd1992 commented Oct 19, 2019

Seems to be working for me as well, need to do more testing though. Should be a simple enough fix to just remove the 'rtmp not supported' code? Will make a PR if so.

@1989gironimo
Copy link

Isn't RTMP supported since several versions? (Or why is this ticket still open?)

@starbasessd
Copy link

It may be that not very many people have reported testing it and it's working. The only ones I've seen have been Reolink users. Hopefully other users of rtmp can report positive or negative...

@CMDR-Sloma
Copy link

I have Reolink RLC-410 5MP and it doesn't work in Motioneye Addon in Home Assistant but the same link works in Frigate which is weird.

@starbasessd
Copy link

Please test as below:

Is the RTMP supported in motion software? Can you guys please run motion without motionEye?

Stop motionEye:

systemctl stop motioneye  # for systemd 
/etc/init.d/motioneye stop  # for sysvinit

Run motion in the foreground:

cd /etc/motioneye
motion -c motion.conf -d 6 -n

Check whether RTMP works. If it doesn't, follow this guide and report it to motion developers.

Also, can you test in a straight motionEyeOS or motionEye on another OS (like Debian or Raspberry Pi OS, instructions here: https://github.com/ccrisan/motioneye/wiki/Installation)
without Home Assistant involved, please? (Use another SD Card or USB stick)
(motionEyeOS dev20201026 supports USB Boot by changing 1 item in cmdline.txt before first boot: change /dev/mmcblk0p2 to /dev/sda2)

@starbasessd
Copy link

Is the URL you use:
rtmp://admin:admin@ip_address:1935/bcs/channel0_main.bcs?token=[TOKEN]&channel=0&stream=0
What if you try:
rtmp://ip_address:1935/bcs/channel0_main.bcs?token=[TOKEN]&channel=0&stream=0
and put the username and password in the appropriate boxes?

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

No branches or pull requests