Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


[solved] webcam ffserver mjpeg firefox does not work

Discussions about problems encountered using ffserver.
Forum rules
FFmpeg is in a state of perpetual development and we do not currently have the person power to backport fixes to official releases. As such, if you wish to query or report a bug, you must try with the latest development branch revision of FFmpeg to confirm the issue still exists. The latest FFmpeg can be downloaded from here: http://www.ffmpeg.org/download.html

[solved] webcam ffserver mjpeg firefox does not work

Postby pauledd » Wed Jun 29, 2016 10:20 am

Hi there
I am trying to get my webcam streamed to firefox as mjpeg stream, since "motion" can do this perfectly and I just wondering why ffmpeg/ffserver cant do this...

If I start ffserver and feed it with ffmpeg and I go to the url (Newly registered users do not have permission to post links :roll: ) with firefox it will open
the download dialog to download "test.mjpeg".

My commands are:
ffserver -f ffserver.conf:
Code: Select all
ffserver version 2.8.7 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --enable-version3 --enable-nonfree --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --enable-network --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl --enable-vaapi --disable-vdpau --enable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --enable-libv4l2 --enable-libpulse --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libfdk-aac --enable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disable-libmodplug --disable-libopus --disable-libquvi --enable-librtmp --disable-libssh --disable-libschroedinger --disable-libspeex --disable-libvorbis --enable-libvpx --enable-libzvbi --disable-libbs2b --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --enable-libfreetype --disable-libsoxr --enable-pthreads --enable-libvo-aacenc --disable-libvo-amrwbenc --enable-libmp3lame --enable-libaacplus --disable-libfaac --disable-libsnappy --enable-libtheora --enable-libtwolame --disable-libwavpack --enable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --enable-x11grab --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=host
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Wed Jun 29 12:07:50 2016 FFserver started.
Wed Jun 29 12:07:56 2016 127.0.0.1 - - [GET] "(Newly registered users do not have permission to post links  :roll:  )" 200 4175
Wed Jun 29 12:08:01 2016 127.0.0.1 - - [GET] "(Newly registered users do not have permission to post links  :roll:  )" 200 1773
Wed Jun 29 12:08:03 2016 127.0.0.1 - - [GET] "(Newly registered users do not have permission to post links  :roll:  )" 200 1776
Wed Jun 29 12:09:01 2016 127.0.0.1 - - [GET] "(Newly registered users do not have permission to post links  :roll:  )" 200 2052931


ffmpeg -f v4l2 -input_format mjpeg -video_size 640x480 -i /dev/video0 -ss 00:00:10 (Newly registered users do not have permission to post links :roll: ):

Code: Select all
ffmpeg version 2.8.7 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --enable-version3 --enable-nonfree --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --enable-network --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl --enable-vaapi --disable-vdpau --enable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --enable-libv4l2 --enable-libpulse --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libfdk-aac --enable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disable-libmodplug --disable-libopus --disable-libquvi --enable-librtmp --disable-libssh --disable-libschroedinger --disable-libspeex --disable-libvorbis --enable-libvpx --enable-libzvbi --disable-libbs2b --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --enable-libfreetype --disable-libsoxr --enable-pthreads --enable-libvo-aacenc --disable-libvo-amrwbenc --enable-libmp3lame --enable-libaacplus --disable-libfaac --disable-libsnappy --enable-libtheora --enable-libtwolame --disable-libwavpack --enable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --enable-x11grab --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=host
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mjpeg @ 0x72daa0] Changeing bps to 8
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 11871.029087, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480, -5 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Output #0, ffm, to '(Newly registered users do not have permission to post links  :roll:  )':
  Metadata:
    creation_time   : 2016-06-29 12:10:31
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mjpeg, yuvj422p(pc), 640x480, q=10-42, 200 kb/s, 30 fps, 1000k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.60.100 mjpeg
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame=   63 fps=5.2 q=24.8 Lsize=     692kB time=00:00:02.13 bitrate=2657.3kbits/s   
video:681kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.652443%

ffserver.conf:
Code: Select all
HTTPPort 8090                      # Port to bind the server to
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 10
MaxClients 10
MaxBandwidth 10000
CustomLog -
NoDefaults

<Feed feed1.ffm>               # This is the input feed where FFmpeg will send
   File ./feed1.ffm            # video stream.
   FileMaxSize 70M              # Maximum file size for buffering video
   ACL allow 127.0.0.1
</Feed>

#<Stream test.webm>
<Stream test.mjpeg>
Feed feed1.ffm
#Format webm
Format mjpeg
NoAudio
#VideoCodec libvpx
VideoCodec mjpeg
VideoSize 640x480
VideoFrameRate 30
AVOptionVideo flags +global_header +strict_mime_boundary
#AVOptionVideo cpu-used 0
#AVOption 'strict_mime_boundary'
AVOptionVideo qmin 10
AVOptionVideo qmax 42
#AVOptionVideo quality good
AVOptionAudio flags +global_header
PreRoll 10
StartSendOnKey
VideoBitRate 200
</Stream>

<Stream status.html>            # Server status URL
   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 (Newly registered users do not have permission to post links  :roll:  )
</Redirect>


anyone ideas?
Last edited by pauledd on Sun Jul 03, 2016 5:21 am, edited 1 time in total.
pauledd
 
Posts: 4
Joined: Wed Jun 29, 2016 9:49 am

Re: webcam ffserver mjpeg firefox does not work

Postby pauledd » Wed Jun 29, 2016 10:36 am

I made a small progress. I wrote this html file and opened in firefox. Now it shows the first frame of the webcam stream
but firefox keeps "loading" and the video is frozen.

Code: Select all
<html>
<head>
</head>
<body>
<img src="http://localhost:8090/test.mjpeg" />
</body>

</html>
pauledd
 
Posts: 4
Joined: Wed Jun 29, 2016 9:49 am

Re: webcam ffserver mjpeg firefox does not work

Postby pauledd » Sat Jul 02, 2016 7:22 pm

I gave up, I use now vlc:

Code: Select all
cvlc -vvv --no-audio v4l2:///dev/video0 --screen-fps 5 --sout "#transcode{vcodec=MJPG,vb=800}:standard{access=http,mux=mpjpeg,dst=:18223/}" --sout-http-mime="multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a"


Then opening brower to http://localhost/18223 and it works
pauledd
 
Posts: 4
Joined: Wed Jun 29, 2016 9:49 am

Re: webcam ffserver mjpeg firefox does not work

Postby pauledd » Sun Jul 03, 2016 5:20 am

After reaching abyss of despair I decided to search ffmpeg source code for:
Code: Select all
multipart/x-mixed-replace

and found it in "libavformat/mpjpeg.c"

So there must be a way to get this thing work and as I go through the code I noticed this lines:
Code: Select all
AVOutputFormat ff_mpjpeg_muxer = {
    .name              = "mpjpeg",


I everytime used the wrong format! In ffserver.conf it has to be "mpjpeg" and not "mjpeg".
After changing this I can watch my stream in firefox at http://localhost:8090/test.mjpeg :roll:
pauledd
 
Posts: 4
Joined: Wed Jun 29, 2016 9:49 am


Return to ffserver

Who is online

Users browsing this forum: No registered users and 1 guest