Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Last active October 21, 2024 03:35
Show Gist options
  • Save peterhellberg/ebfc72147c2009ee720aafe57ce9c141 to your computer and use it in GitHub Desktop.
Save peterhellberg/ebfc72147c2009ee720aafe57ce9c141 to your computer and use it in GitHub Desktop.
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>
@BakytzhanAkzhol
Copy link

BakytzhanAkzhol commented Feb 8, 2019

Hello, I have problem with broadcasting video from webcamera to my server.
It's failed when try to run broadcast to server.

Technical info:

Client-site:Windows 10

Server-site: Ubuntu 16.04

ffserver.conf

HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 500000
CustomLog -
NoDaemon
RTSPPort 7654
RTSPBindAddress 0.0.0.0
<Feed feed1.ffm>               # This is the input feed where FFmpeg will send
   File ./feed1.ffm            # video stream.
   FileMaxSize 1G              # Maximum file size for buffering video
   ACL allow 127.0.0.1         # Allowed IPs
</Feed>

<Stream camera.mjpeg>
	Feed feed1.ffm
	Format webm
	# Audio settings
	AudioCodec vorbis
	AudioBitRate 64             # Audio bitrate

	# Video settings
	VideoCodec libvpx
	VideoSize 640x480          # Video resolution
	VideoFrameRate 30           # Video FPS
	AVOptionVideo flags +global_header  # Parameters passed to encoder
	                                   # (same as ffmpeg command-line parameters)
	AVOptionVideo cpu-used 0
	AVOptionVideo qmin 10
	AVOptionVideo qmax 42
	AVOptionVideo quality good
	AVOptionAudio flags +global_header
	PreRoll 15
	StartSendOnKey
	VideoBitRate 400 
</Stream>

<Stream status.html>
  Format status
  # Only allow local people to get the status
  ACL allow localhost
  ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Redirect index.html>    # Just an URL redirect for index
   # Redirect index.html to the appropriate site
   URL http://XX.XXX.XXX.XXX
</Redirect>

Run code on Windows:

ffmpeg -f dshow -i video="USB2.0 HD UVC WebCam" -video_size 640x480 -rtbufsize 702000k -framerate 30 -pixel_format yuyv422 -f mpegts http://XXX.XXX.XX.XX:8090/feed1.ffm

Error message on Windows:

ffmpeg version N-92730-g978c935f2f Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 42.103 / 58. 42.103
  libavformat    58. 24.101 / 58. 24.101
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, dshow, from 'video=USB2.0 HD UVC WebCam':
  Duration: N/A, start: 5326.566000, bitrate: N/A
    Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg2video (native))
Press [q] to stop, [?] for help
[swscaler @ 06e5a000] deprecated pixel format used, make sure you did set range correctly
Output #0, mpegts, to 'http://95.183.11.180:8090/feed1.ffm':
  Metadata:
    encoder         : Lavf58.24.101
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p, 1280x720, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.42.103 mpeg2video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
av_interleaved_write_frame(): Unknown error
Error writing trailer of http://95.183.11.180:8090/feed1.ffm: Error number -10054 occurred
frame=    3 fps=0.0 q=1.6 Lsize=      46kB time=00:00:00.00 bitrate=34318545.5kbits/s speed=9.07e-05x
video:84kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[http @ 06dd5c00] URL read error:  -10054
Conversion failed!

FFserver log:

Fri Feb  8 03:14:58 2019  - [POST] "/feed1.ffm HTTP/1.1" 200 4096

@lanbin45
Copy link

@BakytzhanAkzhol I've met same error when publishing webcam to ffserver on windows 10. Did you solve this?

@YasirKubarah
Copy link

Is the source code of ffserver still available ?

@peterhellberg
Copy link
Author

@YasirKubarah Yes, in commit 2ca65fc or the 3.4 release branch, as noted on https://trac.ffmpeg.org/wiki/ffserver

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