View previous topic :: View next topic |
Author |
Message |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Wed Apr 20, 2005 7:58 am Post subject: Help with video streaming |
|
|
I didn't think this little project would be so hard.
What I'm trying to do:
Using a Sony Web cam that produces a realtime http motion jpeg stream, I want to grab the data at about 1 MB/second off of ethernet, compress it in real time on a local server, down to about 128 kilobit/second and forward the stream to a linux server sitting on the internet (with unlimited bandwidth). The local installation is behind a firewall of a satellite uplink with very limited upstream bandwidth. I want to do this without impacting my friend's network bandwidth greatly.
This will allowing multiple (maybe 40?) users to view the web content coming from the web cam.
What I have working:
Using FFMPEG I can grab the data from the camera and compress it real time to a file on a local linux server.
However I cannot stream to a fifo which is set to forward to the internet server. ffmpeg simply does not like the fifo. ffmpeg can read from a fifo but doesn't seem to want to write to one.
I have Darwin Streaming Server set up on the local box and I figure if I can generate a mov, then it can forward it to a DSS instalation on the internet server without too much trouble, but I can't figure out how to link the streams...
Has anyone done anything like this?
Any advice would be greatly appreciated.
Thanks much.
Raydude _________________ Some day there will only be free software. |
|
Back to top |
|
 |
richardash1981 Tux's lil' helper

Joined: 08 Apr 2005 Posts: 94 Location: England
|
Posted: Wed Apr 20, 2005 3:40 pm Post subject: |
|
|
Quote: | ffmpeg can read from a fifo but doesn't seem to want to write to one |
You may need to explicity set the format (file / stream type) when using a fifo. It may also be easier to use stdout / stdin in a script, and pipe it that way. |
|
Back to top |
|
 |
lbrtuk l33t


Joined: 08 May 2003 Posts: 910
|
Posted: Wed Apr 20, 2005 3:47 pm Post subject: |
|
|
ffmpeg comes with something useful called ffserver.
http://ffmpeg.sourceforge.net/ffserver-doc.html
And read /etc/ffserver.conf for tips on configuring it.
(darwin streaming server would probably be overkill for this) |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Wed Apr 20, 2005 4:19 pm Post subject: |
|
|
Thanks.
I tried doing it this way:
Code: | ffmpeg ... -i http://etc ... - > /tmp/video.mov
|
But that doesn't work either.
Any other ideas?
richardash1981 wrote: | Quote: | ffmpeg can read from a fifo but doesn't seem to want to write to one |
You may need to explicity set the format (file / stream type) when using a fifo. It may also be easier to use stdout / stdin in a script, and pipe it that way. |
_________________ Some day there will only be free software. |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Wed Apr 20, 2005 4:21 pm Post subject: |
|
|
I saw this, but from what I gathered, it couldn't convert the mjpeg to mov and it wants files, not streams.
I'll read the docs in more depth and see what I can come up with. Thanks for the help.
_________________ Some day there will only be free software. |
|
Back to top |
|
 |
lbrtuk l33t


Joined: 08 May 2003 Posts: 910
|
Posted: Wed Apr 20, 2005 4:39 pm Post subject: |
|
|
Shouldn't something like this work?
Code: | ffserver &
ffmpeg -i http://your.web.cam/file -your -codec -options http://localhost:8090/feed1.ffm |
|
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Wed Apr 20, 2005 8:45 pm Post subject: |
|
|
I'll try this tonight, great idea...
Will let you know.
lbrtuk wrote: | Shouldn't something like this work?
Code: | ffserver &
ffmpeg -i http://your.web.cam/file -your -codec -options http://localhost:8090/feed1.ffm |
|
_________________ Some day there will only be free software. |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Thu Apr 21, 2005 4:44 am Post subject: |
|
|
Close but no cigar.
Here's the command I figured out how to get mpeg1 to work with it, managed to stream to a file with this:
Code: | ffmpeg -f mjpeg -r 25 -i "http://user:password@192.168.0.100/image?speed=25" -pix_fmt yuv420p -f yuv4mpegpipe - | ffmpeg -y -f yuv4mpegpipe -r 25 -pix_fmt yuv420p -i - -b 128 -r 25 -f mpeg test4.mpg
|
Worked like a charm.
However, after configuring ffserver and running it I did this:
Code: | ffserver &
ffmpeg -f mjpeg -r 25 -i "http://user:password@192.168.0.100/image?speed=25" -pix_fmt yuv420p -f yuv4mpegpipe - | ffmpeg -y -f yuv4mpegpipe -r 25 -pix_fmt yuv420p -i - -b 128 -r 25 -f mpeg http://192.168.0.15:8090/feed1.ffm
|
And it generated this:
Code: | ffmpeg version 0.4.9-pre1, build 4743, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --prefix=/usr --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-shared-pp --enable-shared --disable-static --disable-mmx --enable-ogg --enable-vorbis --disable-faad --disable-faac --disable-faadbin --disable-altivec --disable-debug --enable-mp3lame --disable-a52 --disable-a52bin --disable-audio-oss --disable-v4l --disable-dv1394 --disable-pthreads --disable-xvid --enable-gpl --enable-pp --disable-optimize
built on Apr 16 2005 00:57:50, gcc: 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110-r1, ssp-3.4.3.20050110-0, pie-8.7.7)
ffmpeg version 0.4.9-pre1, build 4743, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --prefix=/usr --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-shared-pp --enable-shared --disable-static --disable-mmx --enable-ogg --enable-vorbis --disable-faad --disable-faac --disable-faadbin --disable-altivec --disable-debug --enable-mp3lame --disable-a52 --disable-a52bin --disable-audio-oss --disable-v4l --disable-dv1394 --disable-pthreads --disable-xvid --enable-gpl --enable-pp --disable-optimize
built on Apr 16 2005 00:57:50, gcc: 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110-r1, ssp-3.4.3.20050110-0, pie-8.7.7)
Input #0, mjpeg, from 'http://user:password@192.168.0.100/image?speed=25':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: mjpeg, 320x240, 25.00 fps
Output #0, yuv4mpegpipe, to 'pipe:':
Stream #0.0: Video: rawvideo, yuv420p, 320x240, 25.00 fps, q=2-31, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
Input #0, yuv4mpegpipe, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 320x240, 25.00 fps
192.168.0.15 - - [Wed Apr 20 21:37:29 2005] "POST /feed1.ffm HTTP/1.0" 404 149
Output #0, mpeg, to 'http://192.168.0.15:8090/feed1.ffm':
Stream #0.0: Video: mpeg1video, 320x240, 25.00 fps, q=2-31, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Broken pipe
|
Very close. I can almost taste the solution now!
Any ideas?
Thanks again,
Raydude _________________ Some day there will only be free software. |
|
Back to top |
|
 |
lbrtuk l33t


Joined: 08 May 2003 Posts: 910
|
Posted: Thu Apr 21, 2005 3:19 pm Post subject: |
|
|
Why do you have to use this wierd piping thing? Why does
Code: | ffmpeg -i "http://user:password@192.168.0.100/image?speed=25" -f mjpeg -misc -codec -options http://192.168.0.15:8090/feed1.ffm |
not work? |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Thu Apr 21, 2005 5:06 pm Post subject: |
|
|
Good question.
ffmpeg's mpeg codec does not support the YUV422 mjpeg output of the camera directly. I have to convert the mjpeg YUV422 to YUV420 and then compress it to mpeg.
If I try to convert it directly, as below, I get an error something like, "mpeg must be YUV420." Its interesting to note that it doesn't support 15 FPS either, I have to run 25 FPS for ffmpeg to encode mpeg...
lbrtuk wrote: | Why do you have to use this wierd piping thing? Why does
Code: | ffmpeg -i "http://user:password@192.168.0.100/image?speed=25" -f mjpeg -misc -codec -options http://192.168.0.15:8090/feed1.ffm |
not work? |
I just noticed...
What does -misc and -codec do? _________________ Some day there will only be free software. |
|
Back to top |
|
 |
lbrtuk l33t


Joined: 08 May 2003 Posts: 910
|
Posted: Sat Apr 23, 2005 1:48 am Post subject: |
|
|
RayDude wrote: | What does -misc and -codec do? |
Haha. Obviously wasn't as clear as I thought. -miscellaneous -codec -options are just placeholders for whatever your codec options are. My equivalent of -foo -bar -baz.
I'm actually amazed that ffmpeg isn't able to resample it to YUV420 internally, seeing as one of the things ffmpeg's good for is colourspace conversion. In fact, when using gstreamer it's most common to use the ffmpegcolorspace plugin for this sort of thing. Have you tried encoding to mpeg4 instead of mpeg1?
You might actually want to look into starting from scratch and building a gst-launch pipeline with gstreamer as this is getting complicated. |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Sun Apr 24, 2005 7:57 am Post subject: |
|
|
mepg4 totally works... Thanks for that.
I can't get ffmpeg to forward to the server though. It looks like its working but no data is going.
and ffplay even though it will play .mp4 files will not play mpeg 4 when you use -f mp4 because it says that mp4 is unknown...
I started looking into gstreamer. Its probably exactly what I need, its just I was hoping to not have to write code to do this. I'm a hardware geek, C is not my forte.
However, if I can't ffserver to behave, I'll have no other choice.
Thanks for your help and if you think of any other ideas, I'd appreciate them very much,
Raydude
lbrtuk wrote: | RayDude wrote: | What does -misc and -codec do? |
Haha. Obviously wasn't as clear as I thought. -miscellaneous -codec -options are just placeholders for whatever your codec options are. My equivalent of -foo -bar -baz.
I'm actually amazed that ffmpeg isn't able to resample it to YUV420 internally, seeing as one of the things ffmpeg's good for is colourspace conversion. In fact, when using gstreamer it's most common to use the ffmpegcolorspace plugin for this sort of thing. Have you tried encoding to mpeg4 instead of mpeg1?
You might actually want to look into starting from scratch and building a gst-launch pipeline with gstreamer as this is getting complicated. |
_________________ Some day there will only be free software. |
|
Back to top |
|
 |
lbrtuk l33t


Joined: 08 May 2003 Posts: 910
|
Posted: Mon Apr 25, 2005 12:28 am Post subject: |
|
|
Luckily you don't have to write any c code to get a custom gsreamer pipeline going. It comes with a little app called gst-launch that lets you build a pipeline on the commandline.
You should really be able to use any video player to play the stream from the server, eg- mplayer or xine. Or vlc for windows clients. |
|
Back to top |
|
 |
keli Apprentice


Joined: 18 Jul 2003 Posts: 210 Location: TgMures, RO
|
Posted: Mon Jul 17, 2006 11:58 am Post subject: |
|
|
any update on this? I'm trying to achieve something similar, though I have MPEG capable cameras (SONY SNC-RZ25, RZ50) at hand too.
It would be nice if I'd manage to pipe the streams to a Darwin (as I'm planning to use a darwin on the same project for other jobs anyway) _________________ "The future masters of technology will have to be lighthearted and intelligent. The machine easily masters the grim and the dumb."
Marshall McLuhan, 1969 |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Mon Jul 17, 2006 4:29 pm Post subject: |
|
|
keli wrote: | any update on this? I'm trying to achieve something similar, though I have MPEG capable cameras (SONY SNC-RZ25, RZ50) at hand too.
It would be nice if I'd manage to pipe the streams to a Darwin (as I'm planning to use a darwin on the same project for other jobs anyway) |
Use vlc. It works quite well.
And just in case you didn't know vlc can act as a .sdp server.
Raydude _________________ Some day there will only be free software. |
|
Back to top |
|
 |
keli Apprentice


Joined: 18 Jul 2003 Posts: 210 Location: TgMures, RO
|
Posted: Mon Jul 17, 2006 4:49 pm Post subject: |
|
|
good tip, I'll need to look into that. I know VLC, as a media player, and I knew, "in theory" that it could stream, only so far I wasn't too successful with it.
Here's a bonus question, related both to IP cameras and VLC, then
Could I possibly use it to mux two separate (video and audio) streams from an IP camera?
The cam has http://192.168.0.100/mpeg4 for video and http://192.168.0.100/audio for audio streams. Unfortunately, the camera does not offer a possibility with the audio stream embedded in the video ... _________________ "The future masters of technology will have to be lighthearted and intelligent. The machine easily masters the grim and the dumb."
Marshall McLuhan, 1969 |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Mon Jul 17, 2006 5:36 pm Post subject: |
|
|
keli wrote: | good tip, I'll need to look into that. I know VLC, as a media player, and I knew, "in theory" that it could stream, only so far I wasn't too successful with it.
Here's a bonus question, related both to IP cameras and VLC, then
Could I possibly use it to mux two separate (video and audio) streams from an IP camera?
The cam has http://192.168.0.100/mpeg4 for video and http://192.168.0.100/audio for audio streams. Unfortunately, the camera does not offer a possibility with the audio stream embedded in the video ... |
Theoretically yes, you can specify it mux video and audio from different sources. I've never done it though, I've just seen examples of how it would be done.
Raydude _________________ Some day there will only be free software. |
|
Back to top |
|
 |
keli Apprentice


Joined: 18 Jul 2003 Posts: 210 Location: TgMures, RO
|
Posted: Wed Jul 19, 2006 9:39 am Post subject: |
|
|
RayDude wrote: | keli wrote: | any update on this? I'm trying to achieve something similar, though I have MPEG capable cameras (SONY SNC-RZ25, RZ50) at hand too.
It would be nice if I'd manage to pipe the streams to a Darwin (as I'm planning to use a darwin on the same project for other jobs anyway) |
Use vlc. It works quite well.
And just in case you didn't know vlc can act as a .sdp server.
Raydude |
can you please help me out with an example, as I can't get vlc to work as I want myself.
(For starters I would like to get the video feed only to Darwin) _________________ "The future masters of technology will have to be lighthearted and intelligent. The machine easily masters the grim and the dumb."
Marshall McLuhan, 1969 |
|
Back to top |
|
 |
RayDude Advocate


Joined: 29 May 2004 Posts: 2119 Location: San Jose, CA
|
Posted: Wed Jul 19, 2006 4:37 pm Post subject: |
|
|
keli wrote: | RayDude wrote: | keli wrote: | any update on this? I'm trying to achieve something similar, though I have MPEG capable cameras (SONY SNC-RZ25, RZ50) at hand too.
It would be nice if I'd manage to pipe the streams to a Darwin (as I'm planning to use a darwin on the same project for other jobs anyway) |
Use vlc. It works quite well.
And just in case you didn't know vlc can act as a .sdp server.
Raydude |
can you please help me out with an example, as I can't get vlc to work as I want myself.
(For starters I would like to get the video feed only to Darwin) |
This was generated by a friend of mine. I think it grabs data from a network camera and then broadcasts it as an sdp over http.
Code: | vlc 'http://mylogin:password@mysite.org:5251/nphMotionJpeg?Resolution=320x240&Quality=Standard' \
--sout '#transcode{vcodec=mp4v,vb=256,width=176,height=144}:rtp{dst=127.0.0.1,ttl=15,port-video=9990, \
sdp=file://webcam.sdp,name=My Webcam}' --noaudio -vvv |
Note: the port must be higher 1024 (and maybe even higher than 8192, can't remember, I think it has to do with apache running).
To mux in the audio I think you just specify the first url as video in and then create an audio in after it...
I suggest you google vlc, there are some pretty good howtos out there.
Raydude _________________ Some day there will only be free software. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|