There has been some discussion on the forum how to use FFmpeg to convert the RSTP IP Camera feed to MP4.
Recently, I tried doing the same with my Reolink cameras and I used the same command that has worked fine with my previous IP camera:
ffmpeg -i rtsp://xxx:xxx@192.168.1.57:554/h264Preview_01_main -r 10 -t 60 -vcodec copy -acodec copy -y
But what I found is that the top half of the image is good, but the bottom half is just garbage.
I am not sure if something is missing from my setup, but I don't know how to tell.
@BartButenaers, @kevinGodell I am adding you specifically, since I know you are interested in this topic. I hope you don't mind.
And one more info for those visiting this discussion later. Initially I had issues installing ffmpeg on my rapsberry pi. I have raspbian jessie and it is (was) not possible to install ffmpeg using apt-get install as it appears that is missing from this distro. This is why I used avconv instead which appears to be a copy of ffmpeg. But I did manage to install ffmpeg using Post 7 from user Strontium on this discussion: https://www.raspberrypi.org/forums/viewtopic.php?t=170094. I hope my issues above are not the result of this installation method.
Can you include the full ffmpeg command? What version of ffmpeg? Is the green when outputting jpegs or streaming mp4?
If you are playing the mp4 content and the screen is partially green, just accept it because it is an overpriced cam that does the same thing to me most of the time. I hate to publicly bash that brand, but my super cheap generic chinese $20 ip cams perform way better than the $50 reolink that I got from amazn.
If it is a jpeg issue, then you probably need to pass the jpeg buffer through pipe2jpeg to collect all the pieces befores outputting a complete jpeg.
I had to build ffmpeg on my RaspberryPi 3B, it took a while but it works now very well. All this is discussed in this topic, maybe helps. Also seems you have installed and use a very old version of ffmpeg
I think I understand now. Do you constantly re-connect to the cam since the ffmpeg process only runs for 60 seconds and terminated? That particular ip cam craps out if it gets constant new connections. Atleast mine does.
Hi @kevinGodell, sorry for the off topic comment but would you be kind enough to throw a link or two to these cheap cameras you speak of. Cheers. (might be useful to others too)
Unfortunately, the specific items I purchased 3 years ago are no longer listed. The good news is that similar products are even cheaper now. I paid about 26 usd at the time, and they are now about 20.
The cams that worked best for me all seemed to built upon the same internal components and firmware with an interface that looked like this
One cam that just caught my eye is here. Features that I look for are onvif standards, ip66 for outside, poe support for power from a poe switch, and usually 1080p h264 is fine for me.
No this was one time only. I was just using this flow to save a 1 minute clip when somebody rings the bell at the gate. I was not using this to continuously record the video. So hopefully not and issue with the constant reconnection.
I also have the misfortune of owning two Reolink RLC-420 5MP cameras and they (among a few other models) have issues with their RTSP stream and mostly only work on the Reolink app. It likely does not help in this situation but I just recently learned the cameras also support RTMP streams and can do that without the issues you described.
On my Android phone and tablet for example I use tinyCam PRO which has handled every other camera I got (5 of different brand and model) but the Reolink cameras I have to view in snapshot mode as the app does not support RTMP and the RTSP stream smears after few seconds of streaming.
Kevin, thank a lot. This transport option has fixed the issue. The mp4 file is now clear and I tested it on my RLC-522, RLC-410 and E1 Zoom and all work fine. How did you figure this out?
For those looking at this discussion in the future, this is the full command that works for my Reolink cameras. The below command will create a 1 minute long (-t 60) video of the live stream:
It might not be a coincidence then that the only software outside of Reolink's own app where I've got the RTSP stream working has been Shinobi (NVR software) in which Kevin has been involved. It did support RTMP also but for some reason RTSP worked better on the Raspberry docker image I've been testing it with.
This might actually solve the final piece in my quest to setup a light weight Node-RED based NVR solution using object detection (YOLOV4 inference running on a Jetson Nano). Awesome!
@kevinGodell we've been so lucky to have you appear on the forum out of the blue! There's been so many threads with people being more or less clueless with ffmpeg .
(Being a specialist in off topic ) here are the links of the PTZ (pan tilt zoom) camera I have which are of the same type (Chinese manufacturer xiongmai technology) as @kevinGodell
So simple setup of the first camera, really easy, thats very clever!
The second camera is so amazingly impressive!!! How can they pack all those features into that little device, unbelievable. I really like the auto-tracking feature, the picture quality, the very fast ptz, object detection, two way audio, wow, I now got appetite to upgrade everything I have, what a solution with YOLO object analyze and detection running in my Jetson Nano that could be!!!
I agree this is very cool. This is probably going to be the next norm, object detection. A custom model training would be great, so my camera would be able to tell if it is the UPS, DPD, or other delivery trucks are at my front door. Or the postman who comes in motorbike
Nice to see the issue is resolved, but in case it's of use to anyone searching, here is my bodged script (worked for years, so never cleaned it up), with stream key removed, of how I both save a feed locally and stream to YouTube live - this is with old Geovision BL2410 cam, but just got a new Annke (Hikvision's cheap brand) 4k camera which will be replacing it - probably through Shinobi with HLS to YT instead.
Worth noting the Geovision provides no audio stream, which was my early problems and this injects a fake aac stream. May be required on some cams.
The exiftool part moved the files into a dated sub-directory every time the stream restarts (or is killed by a daily crontab job) - again primitive, but works.