Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MJPEG stream from Webcam using FFServer and FFMpeg
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 200
MaxClients 100
MaxBandWidth 500000
CustomLog -
<Feed camera.ffm>
File /tmp/camera.ffm
FileMaxSize 200M
</Feed>
<Stream camera.mjpeg>
Feed camera.ffm
Format mpjpeg
VideoFrameRate 15
VideoIntraOnly
VideoBitRate 4096
VideoBufferSize 4096
VideoSize 640x480
VideoQMin 5
VideoQMax 51
NoAudio
Strict -1
</Stream>
@peterhellberg

This comment has been minimized.

Show comment
Hide comment
@peterhellberg

peterhellberg Sep 6, 2017

Starting the server

/usr/local/bin/ffserver -f ffserver.conf

Starting FFMpeg (under macOS)

ffmpeg -f avfoundation -framerate 15 -pixel_format yuyv422 -i "0" http://localhost:8090/camera.ffm

Play in VLC (⌘N – Open Network)

http://localhost:8090/camera.mjpeg
Owner

peterhellberg commented Sep 6, 2017

Starting the server

/usr/local/bin/ffserver -f ffserver.conf

Starting FFMpeg (under macOS)

ffmpeg -f avfoundation -framerate 15 -pixel_format yuyv422 -i "0" http://localhost:8090/camera.ffm

Play in VLC (⌘N – Open Network)

http://localhost:8090/camera.mjpeg
@junjuew

This comment has been minimized.

Show comment
Hide comment
@junjuew

junjuew Dec 14, 2017

Starting ffmpeg under linux:
ffmpeg -f video4linux2 -s 640x480 -r 15 -i /dev/video0 http://localhost:8090/camera.ffm

junjuew commented Dec 14, 2017

Starting ffmpeg under linux:
ffmpeg -f video4linux2 -s 640x480 -r 15 -i /dev/video0 http://localhost:8090/camera.ffm

@khazzz

This comment has been minimized.

Show comment
Hide comment
@khazzz

khazzz Jan 22, 2018

Thank you for posting your ffserver.conf file. May I ask you a question please:

How did you decide to use a value for MaxBandWidth set to 500000? And how does it relate to:
VideoBitRate 4096
VideoBufferSize 4096

As I understand all these values are connected and can be tuned. So why did you choose these particular values?
Thank you in advance!

khazzz commented Jan 22, 2018

Thank you for posting your ffserver.conf file. May I ask you a question please:

How did you decide to use a value for MaxBandWidth set to 500000? And how does it relate to:
VideoBitRate 4096
VideoBufferSize 4096

As I understand all these values are connected and can be tuned. So why did you choose these particular values?
Thank you in advance!

@imnx

This comment has been minimized.

Show comment
Hide comment
@imnx

imnx Mar 26, 2018

How did you decide to use a value for MaxBandWidth set to 500000?

Try this:
man ffmpeg or try man ffserver
... ;)

Pay it forward.

imnx commented Mar 26, 2018

How did you decide to use a value for MaxBandWidth set to 500000?

Try this:
man ffmpeg or try man ffserver
... ;)

Pay it forward.

@imnx

This comment has been minimized.

Show comment
Hide comment
@imnx

imnx Mar 26, 2018

A little bash script that does the job for me, for your consideration...

#!/bin/bash
echo 'HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 200
MaxClients 100
MaxBandWidth 500000
CustomLog -

<Feed camera.ffm>
   File /tmp/camera.ffm
   FileMaxSize 200M
</Feed>

<Stream camera.mpeg>
Feed camera.ffm
Format mpeg
VideoFrameRate 25
#VideoIntraOnly
VideoBitRate 4096
VideoBufferSize 4096
VideoSize hd720
VideoQMin 5
VideoQMax 51
#NoAudio
Strict -1
</Stream>' > ${PWD}/.ffserver.conf
(ffserver -f ${PWD}/.ffserver.conf > /dev/null)&
(ffmpeg -s `1280x720 -f` v4l2 -i /dev/video0 -ac 1 -f alsa -i hw:2,0 http://localhost:8090/camera.ffm)&
(rm ${PWD}/.ffserver.conf)&

Just do a chmod +x script.file and ./script.file .

imnx commented Mar 26, 2018

A little bash script that does the job for me, for your consideration...

#!/bin/bash
echo 'HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 200
MaxClients 100
MaxBandWidth 500000
CustomLog -

<Feed camera.ffm>
   File /tmp/camera.ffm
   FileMaxSize 200M
</Feed>

<Stream camera.mpeg>
Feed camera.ffm
Format mpeg
VideoFrameRate 25
#VideoIntraOnly
VideoBitRate 4096
VideoBufferSize 4096
VideoSize hd720
VideoQMin 5
VideoQMax 51
#NoAudio
Strict -1
</Stream>' > ${PWD}/.ffserver.conf
(ffserver -f ${PWD}/.ffserver.conf > /dev/null)&
(ffmpeg -s `1280x720 -f` v4l2 -i /dev/video0 -ac 1 -f alsa -i hw:2,0 http://localhost:8090/camera.ffm)&
(rm ${PWD}/.ffserver.conf)&

Just do a chmod +x script.file and ./script.file .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment