Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ip camera and ffmpeg

7 views
Skip to first unread message

Mike Scott

unread,
Jan 25, 2021, 10:05:45 AM1/25/21
to
Hi all. I'm trying to get ffmpeg to read from an IP camera. Command line
presumably something like

ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
/dev/video10

However, the camera has a login page before allowing access from a
browser, and I can't figure out how to get ffmpeg to provide the
necessary auth info. I've tried various disparate ideas from the web
without success.

There's an 'authorization: basic yadayada' html header when used from a
browser. But ffmpeg?

The camera is an ipc-20c from maginon, presumably a rebranded thingy
from China, so I imagine the software would be common to a number of
cameras.

Any pointers would be welcome please. Thanks.



--
Mike Scott
Harlow, England

The Natural Philosopher

unread,
Jan 25, 2021, 10:20:54 AM1/25/21
to
On 25/01/2021 15:05, Mike Scott wrote:
> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command line
> presumably something like
>
> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
> /dev/video10
>
> However, the camera has a login page  before allowing access from a
> browser, and I can't figure out how to get ffmpeg to provide the
> necessary auth info. I've tried various disparate ideas from the web
> without success.
>
> There's an 'authorization: basic yadayada' html header when used from a
> browser. But ffmpeg?
>

you want to use something like wget....| ffmpeg... or curl

those take auth.



> The camera is an ipc-20c from maginon, presumably a rebranded thingy
> from China, so I imagine the software would be common to a number of
> cameras.
>
> Any pointers would be welcome please. Thanks.
>
>
>


--
WOKE is an acronym... Without Originality, Knowledge or Education.

The Natural Philosopher

unread,
Jan 25, 2021, 10:26:36 AM1/25/21
to
On 25/01/2021 15:20, The Natural Philosopher wrote:
> On 25/01/2021 15:05, Mike Scott wrote:
>> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command
>> line presumably something like
>>
>> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
>> /dev/video10
>>
>> However, the camera has a login page  before allowing access from a
>> browser, and I can't figure out how to get ffmpeg to provide the
>> necessary auth info. I've tried various disparate ideas from the web
>> without success.
>>
>> There's an 'authorization: basic yadayada' html header when used from
>> a browser. But ffmpeg?
>>
>
> you want to use something like wget....| ffmpeg... or curl
>
> those take auth.
>
>

curl --user "USERNAME:PASSWORD" http://camera1.XXXXX | ffmpeg blathere...


>
>> The camera is an ipc-20c from maginon, presumably a rebranded thingy
>> from China, so I imagine the software would be common to a number of
>> cameras.
>>
>> Any pointers would be welcome please. Thanks.
>>
>>
>>
>
>


--
You can get much farther with a kind word and a gun than you can with a
kind word alone.

Al Capone


Andy Burns

unread,
Jan 25, 2021, 11:10:30 AM1/25/21
to
Mike Scott wrote:

> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command line
> presumably something like
>
> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
> /dev/video10


Often IP cameras use rtsp instead of http, the format of URLs varies per
manufacturer, something like

<rtsp://username:password@ip_address:port_number/codec/channel/main_or_sub/av_stream>

if you search for RTSP and the make/model of your camera you should get
clues.

Mike Scott

unread,
Jan 25, 2021, 11:27:38 AM1/25/21
to
On 25/01/2021 15:26, The Natural Philosopher wrote:
> On 25/01/2021 15:20, The Natural Philosopher wrote:
>> On 25/01/2021 15:05, Mike Scott wrote:
>>> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command
>>> line presumably something like
>>>
>>> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
>>> /dev/video10
>>>
>>> However, the camera has a login page  before allowing access from a
>>> browser, and I can't figure out how to get ffmpeg to provide the
>>> necessary auth info. I've tried various disparate ideas from the web
>>> without success.
>>>
>>> There's an 'authorization: basic yadayada' html header when used from
>>> a browser. But ffmpeg?
>>>
>>
>> you want to use something like wget....| ffmpeg... or curl
>>
>> those take auth.
>>
>>
>
> curl --user "USERNAME:PASSWORD" http://camera1.XXXXX | ffmpeg blathere...


Thanks for the comment. Unfortunately it's not going to give up quite so
easily:
mike@spock ~ $ curl --user "USER:PWD" http://camera1.XXXXX
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="Stylesheet" type="text/css" href="/res/styles.css" />
<link rel="Stylesheet" type="text/css" href="/res/specific.css" />
<script type="text/javascript">
window.location = "/desktop/index.htm" + window.location.search;
</script>
</head>
<body>
<div style="text-align: center">
Diese Seite erfordert JavaScript.<br />
This page requires JavaScript.
</div>
</body>
</html>
mike@spock ~ $

I get the same result for a junky username.

Mike Scott

unread,
Jan 25, 2021, 11:28:46 AM1/25/21
to
On 25/01/2021 16:10, Andy Burns wrote:
> Mike Scott wrote:
>
>> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command
>> line presumably something like
>>
>> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
>> /dev/video10
>
>
> Often IP cameras use rtsp instead of http, the format of URLs varies per
> manufacturer, something like
>
> <rtsp://username:password@ip_address:port_number/codec/channel/main_or_sub/av_stream>

Thanks for the thought, but this one seems to be strictly html. I get a
connection refused with rtsp.

The Natural Philosopher

unread,
Jan 25, 2021, 11:47:17 AM1/25/21
to
try telnet and ftp. you never know



--
Climate Change: Socialism wearing a lab coat.

Andreas Kohlbach

unread,
Jan 25, 2021, 12:59:42 PM1/25/21
to
Looks like a Captive Portal at http://camera1.XXXXX/desktop/index.htm

Does the source HTML of this show a form to enter a password? Something
like

<form...
<input name="password">

among other things?

You then can fabricate a string and have wget or curl send it to the
cam. I usually use the text browser lynx though.

lynx -post_data ...
--
Andreas

PGP fingerprint 952B0A9F12C2FD6C9F7E68DAA9C2EA89D1A370E0

Tauno Voipio

unread,
Jan 25, 2021, 2:34:49 PM1/25/21
to
It seems that the username/password handling is well hidden inside
the index page activated by the Javascript clip.

It seems to me that the fastest way to get to the bottom of the
mess is to capture the HTTP traffic and connect with a browser.
The captured traffic may contain plenty of page fetches, but it
probably leads to the URL doing the real thing.

--

-TV

chovy

unread,
Jan 25, 2021, 5:11:43 PM1/25/21
to
You can pass the header with ffmpeg. just make sure you put it BEFORE
the input.

I think it's -A "Authorization: Bearer <token>" but I'm not sure.

--
- chovy

Andreas Kohlbach

unread,
Jan 25, 2021, 5:45:26 PM1/25/21
to
I might even provide you with a proper string to send to the cam.

He can use netcat to capture the traffic.

Load the page in a web browser, fill out id and password but NOT sent it
yet. Go to the browser's proxy settings and set it to 127.0.0.1:10000
(port 10000 as example). On a text console (after installing netcat if
not done already) type

netcat -lp 7000 > test.txt

Now go to the browser and send the login form. The browser will stall or
return an error. It's supposed to do this.

Back to the console press CTRL-c to get back to the prompt. Now
"test.txt" should contain the data you sent from the browser but being
captured by netcat.

If it did not use HTTPS you might see the ID and password and can go from
there.

Mike Scott

unread,
Jan 26, 2021, 7:30:21 AM1/26/21
to
On 25/01/2021 15:26, The Natural Philosopher wrote:
> On 25/01/2021 15:20, The Natural Philosopher wrote:
>> On 25/01/2021 15:05, Mike Scott wrote:
>>> Hi all. I'm trying to get ffmpeg to read from an IP camera. Command
>>> line presumably something like
>>>
>>> ffmpeg -f mjpeg -i http://camera1.XXXXX -pix_fmt yuv420p -f v4l2
>>> /dev/video10
>>>
>>> However, the camera has a login page  before allowing access from a
>>> browser, and I can't figure out how to get ffmpeg to provide the
>>> necessary auth info. I've tried various disparate ideas from the web
>>> without success.
>>>
>>> There's an 'authorization: basic yadayada' html header when used from
>>> a browser. But ffmpeg?
>>>
>>
>> you want to use something like wget....| ffmpeg... or curl
>>
>> those take auth.
>>
>>
>
> curl --user "USERNAME:PASSWORD" http://camera1.XXXXX | ffmpeg blathere...


Finally sorted.

The 'curl' was key - thanks - but I also needed a different url. Turns
out there's snapshot.cgi and a videostream.cgi. I got the former from
wireshark, and the latter by googling the former, which turned up a
useful page about foscam cameras.

So I ended up with
curl --user 'user:pwd' http://camera1/videostream.cgi | ffmpeg -f mjpeg
-i - -pix_fmt yuv420p -f v4l2 /dev/video10


Which feeds happily into OBS (although not cheese, which ignores the
loopback device).

Incidently, the camera's root account was not what you'd call exactly
secure. I had a pretty good root around, but couldn't find the cgi
scripts; lots of html and js, but no cgi. Odd.


Thanks all for help offered.

Tauno Voipio

unread,
Jan 26, 2021, 8:49:20 AM1/26/21
to
The cgi's may be hard-coded into the web server in the camera. They
will be a departure from a normal web file serving, anyway.

--

-TV


The Natural Philosopher

unread,
Jan 27, 2021, 6:02:26 AM1/27/21
to
Well top marks for digging in to the data stream

I'll remember that. may need it one day...

--
There is something fascinating about science. One gets such wholesale
returns of conjecture out of such a trifling investment of fact.

Mark Twain
0 new messages