Capture RTSP stream from IP camera

Hello to everyone who read this!

I met an unpleasant problem. I bought a new router to have such ability to install OpenWRT and run ffmpeg to capture RTSP stream from my chinese IP-camera to USB HDD attached to my router. This camera can give H264 or MJPEG stream.

Now I've installed OpenWRT and ffmpeg, ran the command

ffmpeg -i "rtsp://user:password@192.168.1.103:554/unicast" -r 30 -vcodec copy -acodec copy -t 30 "/mnt/usb/NVR/1.mkv"

and got these errors:
with using MJPEG

Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono

with using H264

Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono

I really don't care what the method to use to capture RTSP stream. Please help me to find any working method.

Compile your own version of ffmpeg (which will include firmware)?
You can either use FFMPEG in the package tree or modify the pull request to support rtsp.

1 Like

Thank you very much for your reply! I already began to think the forum is dead.
Could you kindly give me some explanation about using FFMPEG in the package tree or modifying the pull request? What is the package tree? Does FFMPEG from the link above compiled with h264 support? How to install it? This is my first experience with OpenWRT and *.ipk files.

You need to setup buildroot (see wiki) and add the pull request to your local repo.

Adding the patch/pull request (including pulling (downloading) the source for OpenWrt):

git clone https://github.com/openwrt/openwrt
cd openwrt
./scripts/feeds update -a
cd feeds/packages
wget https://github.com/openwrt/packages/pull/9475.patch
git am 9475.patch
rm 9475.patch
cd ../../
./scripts/feeds update -i
./scripts/feeds install -a
make menuconfig  --> Do changes --> Save config
make -j4 or whatever you prefer
2 Likes

Hello. Today got sometime spent to understand how to do what you said.
At this moment I don't know what I need to do at the point "Do changes" in your "make menuconfig --> Do changes --> Save config". What kind of changes I have to do to make it work on my router?
I thought it is difficult, but now I feel it is more difficult then I thought.

OK, I read wiki. Now I'll specify the question. Is it enough to choose Target System, Subtarget, Target Profile and choose ffmpeg packet from Multimedia section? Using this way will I get the same installation files as the original (which I already installed) plus ffmpeg that can capture RTSP?

As long as you haven't touched anything else that should provide you with the same binaries as previous builds. Do note that you need to select the ffmpeg4 package.

1 Like

I can't find ffmpeg4. If I don't apply the patch I can see only ffmpeg package in Multimedia section and if I apply the patch I see the same ffmpeg in Multimedia section. Where should I search the ffmpeg4 package?
I found ffmpeg4 in /openwrt/package/feeds/packages/ filesystem path.
And one more moment. After

git am 9475.patch
rm 9475.patch

you forgot to write

cd ../../

right?

Yes, sorry about that :slight_smile:
You'll find it in the multimedia section in menuconfig

I'm sorry, I don't know what I'm doing wrong, but there is no ffmpeg4 package in multimedia section.
OK, I've checked ffmpeg package and saved this configuration. In ~/openwrt/.config file lines

CONFIG_PACKAGE_ffmpeg=y
CONFIG_PACKAGE_libffmpeg-full=y

became uncommented. But there is no ffmpeg4 even commented line. Is it OK if I replace ffmpeg with ffmpeg4 in the ~/openwrt/.config file?

Use make menuconfig
Multimedia --> ffmpeg4

I've made a video of the process. But at this time I decided to change OS and used Debian 9 instead of openSUSE 15.1.
There is no ffmpeg4 package in Multimedia.
Please tell me what I'm doing wrong.

OpenWRT building

Ahh, you don't have patented enabled.

make menuconfig --> Global build settings --> Compile with support for patented functionality

It'll show up once that's enabled (in Multimedia)

2 Likes

Did it work?

Yes, I successfully compiled images. And now I'm looking for the method to flash it to my router. The system didn't allow me to flash sysupgrade image via WebUI. It said something about incompatibility.

What router is it?

My router is NetGear R6230

Hmm... that should upgrade fine as far as I know given that you've selected the the correct model. Perhaps using sysupgrade (prompt) might provide more useful information why it doesn't accept your image. Unfortunately I can't help you much more than that regarding flashing your device.

1 Like

In case, you are shure about correct model chosen, you can do from cli:
cd /tmp
download yourimage.bin #using wget, scp ...
sysupgrade -n -v -F yourimage.bin

to force the upgrade.
Settings not saved because of -n ; saving the settings might be too risky between mayor system upgrades.

Use "-F" at your own risk, though.
I have to use it especially when downgrading the firmware, usually, when image from up-to-date-sources does not work, so to use stable version of openwrt.

1 Like

Thank you for getting envolved. I've used -F and -n key and flashed selfcompiled openwrt-ramips-mt7621-netgear_r6220-squashfs-sysupgrade.bin. Now I have a brick. And after using nmrpflash a have a such result:

  1. Router is starting up
  2. I can get IP-address over DHCP
  3. I can ping the router - 192.168.1.1
  4. When I open a web-page of the router, typing 192.168.1.1 in my browser it redirects me to the http://192.168.1.1/cgi-bin/luci URL with page contenting an error message " 404 Not Found"

But with nmrpflash I restored original NetGear's firmware :grin: