div-opn / rtsp-to-mjpeg

Simple container to provide access to a RTSP stream via MJPEG.
9 stars 14 forks source link

Need help figuring out how to make it work #1

Closed DavidePieri closed 1 year ago

DavidePieri commented 1 year ago

Hi! I'm so sorry to issue such a stupid problem, but i'm too new in github projects and i don't know how to install this properly. I would need something to translate from RTSP to MJPEG, because i have a Tapo C110 Camera and i need to make it viewable from fluidd / klipper, that is not able to receive RTSP but only MJPEG. I would need help to install this in my machine running Ubuntu. I only managed to clone the files and edited the .sh, but i have no idea how to install it or make it run. Thanks so much!

div-opn commented 1 year ago

Hi DavidePieri. You can get this up and running by using the Dockerfile in this repository. Alternatively you can also try to get it up and running by manually following all the steps outlines in the Dockerfile and run the command in the SH file. Please let me know how you go, and provide me with as much information as you can if you run into issues.

DavidePieri commented 1 year ago

Thanks so much for your reply! I didn't expect such a fast feedback! I think i managed to make the docker image and then run it, but im having some issues i have no idea how to fix, hope you can help me out. The only thing i could have failed is the .sh, i'm showing you exactly what i wrote:

... rtsp://admin:password@192.168.0.65:554//stream1 ...

Im not sure about the stream section, or if i need to write it like:

rtsp://CAMERAUSER=admin CAMERAPASSWORD=password CAMERAIP=192.168.0.65 CAMERAPORT=554 CAMERASTREAM=1

I'm so sorry to bother, but i am incredibly new to this and surely i'm doing something wrong due to my ignorance! Thanks!!

rtsp-to-mjpeg

div-opn commented 1 year ago

Hi DavidePieri.

Before trying to convert the RTSP stream into MPEG, can you verify that the RTSP stream is actually accessible directly? You could even try with VLC for desktop to verify this. Maybe the credentials are wrong, or the address/stream? Can you see if there is a separate log for VLC that is mentioned in the last line of your screenshot? Maybe you can even try to run the vlc command in debug mode, see here: https://wiki.videolan.org/Documentation:Command_line#Getting_help

DavidePieri commented 1 year ago

I have tried with vlc and i confirm it is working fine with this url "rtsp://admin:password@192.168.0.65:554/stream1"

div-opn commented 1 year ago

There seem to be 2 slashes before stream1, e.g. //stream1 not /stream1 - does that make any difference? Can you see if there is a separate log for VLC that is mentioned in the last line of your screenshot? Maybe you can even try to run the vlc command in debug mode, see here: https://wiki.videolan.org/Documentation:Command_line#Getting_help

DavidePieri commented 1 year ago

I was searching how to fix the issues from the picture i sent and i reinstalled vlc completely, but nothing changed so far. I tried the debug mode, hope the red is your favourite color because it is the one that pops the most! Jokes a side, i tried removing the double / by keeping only one, but no improvements so far. To confirm that the rtsp is working i added a screenshot of it running flawlessly

https://user-images.githubusercontent.com/52237426/220298581-4a81dc67-b36e-4f1f-a7af-0a0e7630e112.mp4

Immagine 2023-02-21 100907

div-opn commented 1 year ago

Hi DavidePieri. I just tried to replicate the issue on my end but wasn't able to. I used a publicly available RTSP test stream (https://www.wowza.com/developer/rtsp-stream-test) and transcoded the stream to MJPEG with the command utilised in the SH file:

/usr/bin/vlc --intf dummy rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 --sout '#transcode{vcodec=MJPG,venc=ffmpeg{strict=1}}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8080/}'

I was then able to access the stream via web browser on port 8080 (I am also getting a lot of filtering errors from the VLC command, but it seems to work):

Screenshot 2023-02-22 at 8 10 21 am

Can you potentially run the VLC command with -vvv to increase verbosity? Also, can you test with the public stream above just to see if it works at all for you?

DavidePieri commented 1 year ago

I tried what you said, but im too ignorant to understand how to do it properly, im able to create an .sh file and basically copy pasting what you provided in the last message, but not much more honestly. I don't know how dockerfile works yet, and that could be the issue im figuring. Lets try to find a point in what i've done so maybe you could help me find the problem. I cloned all the provided files in /home/davide/rtsp-to-mjpeg, inside the folder im able to see the dockerfile, the readme.md and the .sh . I edited the .sh file with my informations, then studied how to run a dockerfile, i found out i had to build it before being able to do anything, but i understood that the dockerfile was reading the .sh because while running the docker i was able to see the rtsp://admin:pass@ip... , but once i edited the .sh with different credentials it kept using the old ones even if i changed them, so i guessed i had to build another docker-image. Basically my biggest problem is the fact that after editing the .sh file, i have no idea how to proceed, i've seen many tutorials to figure how it works, but honestly i had no time to watch them and possibly i would only need to understand the necessary procedures i have to follow for this use, cause i wouldn't need it anywhere else (i think). Could you teach me the quick basics or suggest me a guide to start with? Thanks!

div-opn commented 1 year ago

No worries DavidePieri, thank you for clarifying. I would not recommend putting your password and other information into the script which would require you to rebuild the entire image if anything changes, instead you can simply pass on any of your environment variables via docker environment variables. Here is an example:

docker run -it -e CAMERAUSER='' -e CAMERAPASSWORD='' -e CAMERAIP='' -e CAMERAPORT='' -e CAMERASTREAM='' <image>

So maybe try to rebuild an unmodified version of my docker image and then use docker environment variables as outlined above to pass on any credentials. You can also pull it directly from Dockerhub: https://hub.docker.com/r/opndiverseco/rtsp-to-mjpeg

DavidePieri commented 1 year ago

Thanks so much!! I will get back to you as soon as i have cleaned all the mess i made to freshly restart all with these new informations! I had no idea there was a way to modify the .sh from the docker!

div-opn commented 1 year ago

Hi DavidePieri. Good news, I have been able to dig a bit deeper and identified that the latest version of VLC doesn't seem to support RTSP streams, or at least not in the same way it did when I initially created the Dockerfile a few years ago. I have now updated both this repository as well as the Docker Hub (https://hub.docker.com/repository/docker/opndiverseco/rtsp-to-mjpeg/tags?page=1&ordering=last_updated) and I hope that you will be having more success with this updated image. Let me know how you go.

DavidePieri commented 1 year ago

Thanks a lot for your effort! i managed to freshly clone the github files and the docker from your link. I'm now trying to use the command to edit my informations, but i get a syntax error caused from <image> at the end, i tried to run the command without the <> but i received this error: Unable to find image 'image:latest' locally docker: Error response from daemon: pull access denied for image, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

div-opn commented 1 year ago

Hi DavidePieri. The word image merely represents a generic placeholder for whatever the image might be named that you are using (you can also use the image ID if it doesn't have a name). You can get a list of all locally available docker images via the command docker images. I hope this helps.

DavidePieri commented 1 year ago

Hi! I didn't think that i should have selected the docker!😅 Sadly even once i fixed the command i was not able to fix the error i had, but we are getting into something:

1 2

I see i have some audio errors, but i don't really care about the audio at all, if there is any way to exclude the process that make all go wrong. How can i display the output of the transcoded source? Is that just my pc IP + 8080? Thanks!

div-opn commented 1 year ago

Hi DavidePieri. Are you able to share all your steps (docker commands, etc.), not just the output of the command? This will help me understand better what's happening. And yes, once the container is successfully running and transcoding the stream, you can access it on the exposed port 8080. If docker runs on a remote machine, you will also have to publish the ports, so that it's exposed to the local network.

DavidePieri commented 1 year ago

Hi! It is very simple (i guess), the output i showed in the last pictures shared come out from the edited command you sent me: docker run -it -e CAMERAUSER='' -e CAMERAPASSWORD='' -e CAMERAIP='' -e CAMERAPORT='' -e CAMERASTREAM='' <image> For the i just did docker images and copy pasted the only docker image i have, it is the one i downloaded from your link. Thats basically it, i dont know if i have to do anything more to make it work honestly!

div-opn commented 1 year ago

Hi DavidePieri. Thank you for clarifying. It looks like all the environment variables you provided along with the docker command are empty. This means that the VLC transcode command will not connect to any remote device. In order to be successful, you will need to supply your user, password, IP, port, and stream name along with the environment variables, plus the image name that you already found.

DavidePieri commented 1 year ago

I have filled the command with all the informations, i forgot to add them in the last message, it would be something like this: docker run -it -e CAMERAUSER='printer' -e CAMERAPASSWORD='password' -e CAMERAIP='192.168.0.75' -e CAMERAPORT='554' -e CAMERASTREAM='1' dockerimagename

div-opn commented 1 year ago

Hi DavidePieri. That's good to hear. Assuming your RTSP stream address is rtsp://admin:password@192.168.0.65:554//stream1, you would want to run the command with the following environment variables: -e CAMERAUSER='admin' -e CAMERAPASSWORD='password' -e CAMERAIP='192.168.0.65' -e CAMERAPORT='554' -e CAMERASTREAM='stream1'.

DavidePieri commented 1 year ago

Exactly, this is what i have done so far, and the output is the errors you can see in my post.

Hi! I didn't think that i should have selected the docker!😅 Sadly even once i fixed the command i was not able to fix the error i had, but we are getting into something:

1 2

I see i have some audio errors, but i don't really care about the audio at all, if there is any way to exclude the process that make all go wrong. How can i display the output of the transcoded source? Is that just my pc IP + 8080? Thanks!

div-opn commented 1 year ago

Hi DavidePieri. Are you able to advise what happens when you connect to the transcoded stream on port 8080? Also, you stated that you put in CAMERASTREAM='1', however it needs to be CAMERASTREAM='stream1' according to your original URL.

DavidePieri commented 1 year ago

When i try to connect to the computer ip:8080 the browser doesn’t see anything, like it is not working. i will get back to you as soon as possible trying stream1, that could be the solution to the problem🤞

DavidePieri commented 1 year ago

Back to you again, edited the stream1 section, once i sent the command i received nothing as a reply, i was only able to see > and nothing else, even waited few minutes but never had any reply. I tried to change the stream back to just 1 instead of stream1 but i had no reply even if i had issues in the past. The only reason of this new issue is that i am using another pc and not the usual one cause i was not able to. I will get back to you in few hours with hopefully better news. Thanks so much for all your help!

DavidePieri commented 1 year ago

Hi again! I tried with my usual pc and i confirm that nothing has changed, and i started thinking about pulseaudio. I reinstalled it back again and checked its settings at /etc/avahi/avahi-daemon.conf , ive seen people having issues and advising to set use-ipv6=no so i tried, but had the same problems over and over. What version are you running? Mine is pulseaudio 13.99.1. Ive heard even that i have to add a source with working audio, so i enabled it in the Tapo App, but still errors. To confirm my command here it is the one i use:

docker run -it -e CAMERAUSER='davide' -e CAMERAPASSWORD='password' -e CAMERAIP='192.168.0.75' -e CAMERAPORT='554' -e CAMERASTREAM='stream1' opndiverseco/rtsp-to-mjpeg

I tried to delete the opndiverseco/ from the <image> but the promt was not able to find any docker images that way, so i had to keep opndiverseco/rtsp-to-mjpeg in order to make it work. Thanks!

DavidePieri commented 1 year ago

Hi! Just tried with a raspberry pi4 hanging around but the architecture is not supported and i get this error: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested exec /home/streamer/rtsp-to-mjpeg.sh: exec format error I dont really care cause i would use the raspberry as a transcoder. I will try to reinstall vlc again on my main pc, and instead of using snap i will install it by apt

DavidePieri commented 1 year ago

Didn't fix the problem even by installing vlc by apt, what is your vlc version? Mine is VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b5a7)

div-opn commented 1 year ago

Hi DavidePieri.

The initial version was built for ARM, but the current version was built for AMD64 as I currently don't have access to an ARM machine. You can however clone this GIT repository onto your Raspberry PI and build the Dockerfile manually yourself. If you pull the image from Docker, you will receive pre-compiled images that need to match your architecture.

My image is installing the latest version available for its Ubuntu version, e.g. Bionic (18.04) gets VLC 3.0.8. As I mentioned before, newer versions don't seem to work for me with the RTSP to MJPEG transcoding.

I ran the image on a fresh installation of Docker (on AMD64) and it worked out of the box for me. There are a lot of warning messages in the VLC output, however none of them are errors (show-stoppers).