No video output by WebChimera and wcjs-prebuilt on Ubuntu 16.04 - electron

WebChimera is not supported Linux officially, But I have used that on a Ubuntu 16.04 by upgrading VLC to 2.2.4 and using a pre-built package fount at WebChimera.js v0.2.7 Releases (WebChimera.js_electron_1.4.13_x64_linux.zip)
I have built WebChimera myself on Ubuntu 16.04 and VLC 2.2.2 (official version of VLC on 16.04). Every thing is OK for some videos but for some of videos, I just can hear the audio when playing and there is a black screen (no video output but audio is OK). I don't want to upgrade my VLC to 2.2.4. How can I fix this problem?
On electron v1.6.8, console writes this error:
[h264 # 0x2e3c62ba0880] No start code is found.
[h264 # 0x2e3c62ba0880] Error splitting the input into NAL units.
on older electron versions like v1.4.0 or v1.1.0, this error is written:
[h264 # 0x1262f42c8480] no frame!
or
[h264 # 0x3f08b31d5000] The maximum value for lowres supported by the decoder is 0
sample output of vlc is:
majid#majid-K55VD:~$ vlc --version
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
VLC version 2.2.2 Weatherwax (2.2.2-0-g6259d80)
Compiled by buildd on lgw01-18.buildd (Mar 28 2017 11:23:57)
Compiler: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.
sample output of ffmpeg is:
majid#majid-K55VD:~$ ffmpeg -version
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build- suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
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

Updating VLC to 2.2.4 and upper resolved my problem.

Related

Prepend To Log Output For FFmpeg when using exec_push with nginx-rtmp-module

I currently have Nginx setup with nginx-rtmp-module and I use it to stream into the live application and then do some FFmpeg work on it into our hls application. My goal is to prepend the stream name to all FFmpeg's log output. In the past, I would just use unique log file names to solve this, but with Docker, it is easier to use a single file.
Here is an excerpt from the live application (non-working)
exec_push ffmpeg -i rtmp://127.0.0.1:1935/live/$name -f flv rtmp://127.0.0.1:1935/hls/$name -loglevel repeat+level+debug 2> > (sed -u "s/^/FFMPEG: [${name}] /g" >>/proc/1/fd/1);
When I use an RTMP connection url like:
rtmp://127.0.0.1/live/myTestName
My goal is to generate logs that look like:
FFMPEG: [myTestName] [info] ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers FFMPEG: [myTestName] [info] built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) FFMPEG: [myTestName] [info] configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared FFMPEG: [myTestName] [info] libavutil 56. 31.100 / 56. 31.100 FFMPEG: [myTestName] [info] libavcodec 58. 54.100 / 58. 54.100
Thank you for your help!

Convert RAW images to BMP format

I received a .raw frame format (here is a sample) which contains the raw pixel values of a frame. And I've been told I can convert it to an image (.bmp or .png) using FFMpeg using following command. However, when trying, it doesn't work.
dd bs=16 dumpB4EncodeHLSAfterEncodeBuf1200IP_TS/dumpedYuv/image-1140.raw | ffmpeg -f rawvideo -video_size 2160 2160 -pixel_format nv12 -i - yuv.bmp
What is the problem? Is there any ways to avoid use of dd and purely do it from FFmpeg?
Here is the error:
dd: unrecognized operand ‘frame.raw’
Try 'dd --help' for more information.
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
pipe:: Invalid data found when processing input
And if I use ffmpeg directly:
ffmpeg -video_size 2160x2160 -pixel_format nv12 -i frame.raw yuv.bmp
I will get this error:
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[image2 # 0x5605e52bb4c0] Format image2 detected only with low score of 5, misdetection possible!
Input #0, image2, from 'frame.raw':
Duration: 00:00:00.04, start: 0.000000, bitrate: 1244160 kb/s
Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 2160x2160, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> bmp (native))
Press [q] to stop, [?] for help
[rawvideo # 0x5605e52bea00] Invalid buffer size, packet size 6220800 < expected frame_size 6998400
Error while decoding stream #0:0: Invalid argument
Finishing stream 0:0 without any data written to it.
Output #0, image2, to 'yuv.bmp':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: bmp, bgr24, 2160x2160, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.107.100 bmp
frame= 0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!
Updated Answer
Now that we know the correct size and format, we can do the conversion easily with ImageMagick:
magick -depth 8 -size 1920x1080 rgb:frame.raw result.png
Or, as you wanted, with ffmpeg:
ffmpeg -y -f rawvideo -s 1920x1080 -pix_fmt rgb24 -i frame.raw image.bmp
Original Answer
You raw file is either not NV12 or not 2160x2160. NV12 uses 1.5 bytes per pixel, which would mean you should have
2160 * 2160 * 1.5 = 6,998,400 bytes
but you actually have 6,220,800 so there is something wrong with your information - either the file is incomplete, or it is not that format or it is not that size.
If it was NV12, the first 2160x2160 bytes would be the greyscale (or Luminance/Y) channel, but even if we get the first 2160x2160 bytes as greyscale and ignore any trailing colour information, it is still wrong:
head -c $((2160*2160)) frame.raw | magick -depth 8 -size 2160x2160 gray:- image.bmp
Please check and identify the provenance and characteristics of your raw data.

Play stream via FFplay (FFmpeg) in Docker

It is possible to play a video file via ffplay in Docker?
I have tried to build this docker:
Dockerfile:
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y ffmpeg
After run this docker with a command:
docker run -v /demo:/demo ffmpeg-test bash -c "ffplay -i /demo/test.mp4"
I got ffplay logs without any player window.
What am I missing?
FFplay logs:
ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100

FFMPEG x264 (fourcc=0x21) codec is not working with OpenCV

I'm trying to use mp4 format coding (fourcc=0x21) on OpenCV 3.2 without success. Probably I have a problem with my Ubuntu 18.04 setup but currently I'm running out of ideas how to fix it. First, I recompiled FFMPEG with x264 support. Than, recompiled OpenCV (with contrib and OPENCV_ENABLE_NONFREE=ON, WITH_FFMPEG=ON). It is still not working.
I cannot use fourcc different than 0x21. I mean.. I cannot use another codec.
Example:
>>> import cv2
>>> out = cv2.VideoWriter('output.mp4', 0x21, 20.0, (640,480))
OpenCV: FFMPEG: tag 0x00000021/'!???' is not found (format 'mp4 / (null)')'
However, this is working fine (other fourcc, codec):
>>> out = cv2.VideoWriter('output.mp4',0x31637661 , 20.0, (640,480))
OpenCV compiled with FFMPEG support (version 3.2), cmake config:
Video I/O:
DC1394 1.x: NO
DC1394 2.x: YES (ver 2.2.5)
FFMPEG: YES
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: YES (ver 3.7.0)
FFMPEG build with x264 support:
ffmpeg -version
ffmpeg version N-96891-g60b1f85 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/user/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 56. 42.100 / 56. 42.100
libavcodec 58. 73.102 / 58. 73.102
libavformat 58. 39.101 / 58. 39.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
FFMPEG x264 simple conversion test is working:
ffmpeg -i in.mp4 -vcodec libx264 -f mp4 out.mp4y
ffmpeg version N-96891-g60b1f85 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/user/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 56. 42.100 / 56. 42.100
libavcodec 58. 73.102 / 58. 73.102
libavformat 58. 39.101 / 58. 39.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:00:10.00, start: 0.000000, bitrate: 3826 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x960, 3825 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
Metadata:
handler_name : VideoHandler
File 'out.mp4y' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))

av_interleaved_write_frame(): Connection reset by peer mjpeg : What is wrong with mjpeg stream, ffserver and ffplay?

I'm creating mjpeg stream from image files using ffmpeg and write it to ffserver's feed:
sudo ffmpeg -loop 1 -i fon.jpeg -vcodec mjpeg -f mjpeg http://localhost:8090/feed1.ffm
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 19 2013 23:10:58 with gcc 4.7 (Debian 4.7.2-5)
configuration:
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
Input #0, image2, from 'fon.jpeg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Output #0, mjpeg, to 'http://localhost:8090/feed1.ffm':
Metadata:
encoder : Lavf55.12.100
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> mjpeg)
Press [q] to stop, [?] for help
ffserver is configured as
Port 8090
RTSPPort 8594
BindAddress 0.0.0.0
MaxClients 100
MaxBandwidth 20000
NoDaemon
<Feed feed.ffm>
File /tmp/feed.ffm
FileMaxSize 3M
</Feed>
<Stream test.rtsp>
Feed feed.ffm
Format rtsp
VideoCodec mjpeg
VideoFrameRate 30
VideoBufferSize 80000
VideoBitRate 200
VideoQMin 1
VideoQMax 5
VideoSize 1280x720
PreRoll 1
Noaudio
</Stream>
<Stream test.swf>
Feed feed.ffm
Format swf
VideoCodec flv
VideoFrameRate 30
VideoBufferSize 50000
VideoBitRate 100
VideoQMin 1
VideoQMax 5
VideoSize 1280x720
PreRoll 0
Noaudio
</Stream>
Then I'm trying to retrieve the rtsp stream from the ffserver:
ffplay http://localhost:8090/test.rtsp -loglevel debug
avplay version 0.8.5-6:0.8.5-1, Copyright (c) 2003-2012 the Libav developers
built on Jan 13 2013 12:05:48 with gcc 4.7.2
configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra- version='6:0.8.5-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
avutil configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
avcodec configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
avformat configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
swscale configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
postproc configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.4-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 22. 1 / 51. 22. 1
libavcodec 53. 35. 0 / 53. 35. 0
libavformat 53. 21. 1 / 53. 21. 0
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 2. 15. 0 / 2. 15. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 52. 0. 0 / 52. 0. 0
http://localhost:8090/test.rtsp: Invalid data found when processing input
So, what is wrong in this streaming example, if I have no problem when I substitute streams to the files?
I create a mjpeg file using the same parameters 9i.e. file is an output insteadof stream)
sudo ffmpeg -loop 1 -i fon.jpeg -vcodec mjpeg -f mjpeg test.mjpg
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 19 2013 23:10:58 with gcc 4.7 (Debian 4.7.2-5)
configuration:
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
Input #0, image2, from 'fon.jpeg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Output #0, mjpeg, to 'test.mjpg':
Metadata:
encoder : Lavf55.12.100
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> mjpeg)
Press [q] to stop, [?] for help
frame= 36 fps=0.0 q=0.0 size= 888kB time=00:00:01.36 bitrate=5349.2kbits/sframe= 78 fps= 76 q=0.0 size= 1711kB time=00:00:03.04 bitrate=4609.9kbits/sframe= 120 fps= 78 q=0.0 size= 2533kB time=00:00:04.72 bitrate=4396.9kbits/sframe= 161 fps= 79 q=0.0 size= 3336kB time=00:00:06.36 bitrate=4297.5kbits/sframe= 202 fps= 79 q=0.0 size= 4139kB
time=00:00:08.00 bitrate=4238.8kbits/sframe= 243 fps= 79 q=0.0 size= 4943kB
time=00:00:09.64 bitrate=4200.1kbits/sframe= 282 fps= 79 q=0.0 size= 5706kB
time=00:00:11.20 bitrate=4173.9kbits/sframe= 321 fps= 79 q=0.0 size= 6470kB
time=00:00:12.76 bitrate=4154.0kbits/sframe= 358 fps= 78 q=0.0 size= 7195kB
time=00:00:14.24 bitrate=4139.2kbits/sframe= 397 fps= 68 q=0.0 size= 7959kB
time=00:00:15.80 bitrate=4126.6kbits/s
[1]+ Stopped sudo ffmpeg -loop 1 -i fon.jpeg -vcodec mjpeg -f mjpeg test.mjpg
And then I playback this mjpeg file with ffplay. The play back is correct, I see no errors or exceptions.
ffplay test.mjpg
avplay version 0.8.5-6:0.8.5-1, Copyright (c) 2003-2012 the Libav developers
built on Jan 13 2013 12:05:48 with gcc 4.7.2
[mjpeg # 0x7fc3680008c0] max_analyze_duration reached
[mjpeg # 0x7fc3680008c0] Estimating duration from bitrate, this may be inaccurate
Input #0, mjpeg, from 'test.mjpg':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 1200k tbc
[avsink # 0x7fc360001020] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale # 0x7fc360001700] w:1280 h:720 fmt:yuvj420p -> w:1280 h:720 fmt:yuv420p flags:0x4
27.99 A-V: 0.000 s:0.0 aq= 0KB vq= 0KB sq= 0B f=0/0 0/0
So, what is the configuration issue for ffserver, or may be it is a bug of the ffserver?
UPD. I have realized, that i fed file1.ffm instead of file.ffm; that caused some ffserver problem:
Mon Sep 9 11:43:20 2013 [ffm # 0x2110000]Format ffm probed with size=2048 and score=101
Mon Sep 9 11:43:20 2013 Deleting feed file 'feed1.ffm' as stream counts differ (1 != 2)
Mon Sep 9 11:43:20 2013 [AVIOContext # 0x210d660]Statistics: 4096 bytes read, 0 seeks
Mon Sep 9 11:43:20 2013 [AVIOContext # 0x210a9a0]Statistics: 0 seeks, 1 writeouts
Mon Sep 9 11:43:20 2013 FFserver started.
Mon Sep 9 11:44:18 2013 File '/feed1.ffm' not found
Mon Sep 9 11:44:18 2013 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 404 149
After i set a correct feed, i got another exception on ffmpeg side:
sudo ffmpeg -loop 1 -i fon.jpeg -vcodec mjpeg -f mjpeg http://localhost:8090/feed.ffm
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 19 2013 23:10:58 with gcc 4.7 (Debian 4.7.2-5)
configuration:
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
Input #0, image2, from 'fon.jpeg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Output #0, mjpeg, to 'http://localhost:8090/feed.ffm':
Metadata:
encoder : Lavf55.12.100
Stream #0:0: Video: mjpeg, yuvj420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> mjpeg)
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Connection reset by peer
While ffserver shows no error at all:
sudo ffserver -f /etc/ffserver3.conf
ffserver version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 19 2013 23:10:58 with gcc 4.7 (Debian 4.7.2-5)
configuration:
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
Mon Sep 9 12:08:19 2013 FFserver started.
Mon Sep 9 12:08:40 2013 127.0.0.1 - - [POST] "/feed.ffm HTTP/1.1" 200 4096
Mon Sep 9 12:12:28 2013 127.0.0.1 - - [GET] "/ HTTP/1.1" 200 1847
So, what is the problem now?
the short answer is: you can't do that, at least not in that way. ffserver decides the expected input format by looking at the feed output name. when it sees you sending the data to feed.ffm it assumes ffm data, and so when libavformat/utils.c routine avformat_open_input calls s->iformat->read_header(s), it uses the ffm_read_header routine in libavformat/ffmdec.c:
/* header */
tag = avio_rl32(pb);
if (tag == MKTAG('F', 'F', 'M', '2'))
return ffm2_read_header(s);
if (tag != MKTAG('F', 'F', 'M', '1')) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
here is where it sees the <ff><d8><ff><e0> at the beginning of the JPEG data, sees it is not equal to FFM2 or FFM1, and fails with "Invalid data found when processing input", although that message is never shown.
I can't yet tell you the right way to do it, but at least now you know what is happening.

Resources