ffmpeg restream rtsp to mjpeg

JpaytonWPD picture JpaytonWPD · Apr 17, 2015 · Viewed 39.7k times · Source

I have a few IP cameras that stream 720 X264 video over rtsp. The streams are really unreliable when viewing on Android. They also fail if more then 2 connections are made.

I have a ubuntu server that I can use to connect and restream as mjpeg or something else. There are tons of different commands out there but they all seem to involve transcoding the video.

How can I simply restream the live rtsp feed as a mjpeg without doing anything to the video itself? Theres no audio so no worries there.

Answer

Rafał picture Rafał · Jul 29, 2015

It seems that recently I did something similar. I have added following section to the /etc/ffserver.conf file:

<Feed monitoring1.ffm>
File /tmp/monitoring1.ffm
FileMaxSize 50M
ACL allow 127.0.0.1
</Feed>

<Stream monitoring1.mjpg>
Feed monitoring1.ffm
Format mpjpeg
VideoCodec mjpeg
VideoFrameRate 22
VideoBufferSize 80
VideoSize 720x264
NoAudio
</Stream>

After that started server with command:

ffserver

and run streaming with command:

ffmpeg -i "rtsp://<ip_camera>:554/user=admin&password=&channel=1&stream=0.sdp" http://localhost:8090/monitoring1.ffm

Tune the ip camera url for your purposes. Now you can access the mjpeg stream by accessing following address with your browser/player:

http://localhost:8090/monitoring1.mjpg

Works fine for me and hope it solves your problem.