Can't get ffmpeg to stream webcam [closed] - ffmpeg

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
I have a rapsberry with ffmpeg installed and a microsoft hd3000 cam installed
I run the following command:
ffserver -f /etc/ffserver.conf & ffmpeg -framerate 21 -re -f video4linux2 -i /dev/video0 -f alsa -i sysdefault:CARD=HD3000 http://localhost:8090/feed1.ffm
and i get the following:
/etc/ffserver.conf:164: Setting default value for video bit rate tolerance = 16000. Use NoDefaults to disable it.
/etc/ffserver.conf:164: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
/etc/ffserver.conf:164: Setting default value for video max rate = 6229744. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for audio sample rate = 22050. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for audio channel count = 1. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video bit rate tolerance = 64000. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
/etc/ffserver.conf:219: Setting default value for video max rate = 6369328. Use NoDefaults to disable it.
bind(port 8090): Address already in use
Wed Nov 29 13:17:49 2017 Could not start server
[video4linux2,v4l2 # 0x1a35630] The driver changed the time per frame from 1/21 to 1/10
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 12116.079136, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'sysdefault:CARD=HD3000':
Duration: N/A, start: 1511961469.424072, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[tcp # 0x1a44160] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
Wed Nov 29 13:17:49 2017 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
[tcp # 0x1a63ca0] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
[mpeg1video # 0x1a6ecb0] bitrate tolerance 21333 too small for bitrate 64000, overriding
[mpeg1video # 0x1a6ecb0] MPEG-1/2 does not support 3/1 fps
Stream mapping:
Stream #1:0 -> #0:0 (pcm_s16le (native) -> mp2 (native))
Stream #0:0 -> #0:1 (rawvideo (native) -> mpeg1video (native))
Stream #1:0 -> #0:2 (pcm_s16le (native) -> wmav2 (native))
Stream #0:0 -> #0:3 (rawvideo (native) -> msmpeg4v3 (msmpeg4))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
Wed Nov 29 13:17:49 2017 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 0
[2]+ Exit 1 ffserver -f /etc/ffserver.conf
I use the default /etc/ffserver.conf.
I can't seem to figur out what is the problem.

MPEG-1/2 does not support 3/1 fps
This is the error that is causing the failure. Although you set a frame rate of 21 it appears the webcam is changing it.
From the ffmpeg side you have two options:
Use a different encoder other than mpeg1video/mpeg2video that can support arbitrary frame rates, or
If you want to keep using mpeg1video see the -r and/or -vsync options to properly deal with the output frame rate.
Note that ffserver is being planned for removal soon from FFmpeg. You may want to find an alternative.

Related

Extract frames from video with ffmpeg - header problem?

I want to convert .AVI files coming from a camera-trap to individuals frames, ideally using ffmpeg. Up to now I am not succeeding.
The most simple thing I tried, to try to locate the problem, is this (I want all frames and my test file is test.avi):
ffmpeg -i test.avi output_%04d.png
It fails with the following console message:
[avi # 0x559fb596f8c0] unknown stream type 73647578
[avi # 0x559fb596f8c0] Something went wrong during header parsing, tag [0][0]id has size 338702712, I will ignore it and try to continue anyway.
[mjpeg # 0x559fb59709e0] No JPEG data found in image
Last message repeated 100 times
[avi # 0x559fb596f8c0] decoding for stream 0 failed
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 0 (Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 1 (Video: none (JUNK / 0x4B4E554A), none, 11025x22050): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, avi, from 'test.avi':
Duration: 00:00:10.50, start: 0.000000, bitrate: 28129 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
Decoder (codec none) not found for input stream #0:1
The actual video duration is 10s (when read using vlc for instance, and this is indeed the length of video programmed on the camera-trap. ffmpeg says the duration is 10.50s, and says there is a problem with header parsing (see above).
I have no idea how to sort this, despite having looked at more than many ffmpeg 'convert video to frames' post. Any hint would be appreciated, thanks.
If you look at the error message, you will see that the file has 2 video streams.
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
and ffmpeg is trying to read for the second one:
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
You can use -map 0:0 to select the first stream.

ffmpeg codec conversion; can't configure encoder

I am simply trying to convert a vp9 webm I have into a vp8 webm. this is the command I'm using.
ffmpeg -i in.webm -c:v vp8 out.webm
the vp8 encoder returns a strange error
Input #0, matroska,webm, from 'in.webm':
Metadata:
encoder : google
Duration: 00:02:34.60, start: 0.000000, bitrate: 404 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/unknown/unknown), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> vp8 (vp8_v4l2m2m))
Press [q] to stop, [?] for help
[vp8_v4l2m2m # 0x56195db9f9f0] Could not find a valid device
[vp8_v4l2m2m # 0x56195db9f9f0] can't configure encoder
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
In case I get any questions about whether I have the right encoders and decoders installed here is the output of ffmpeg -codecs | grep "vp[8-9]":
DEV.L. vp8 On2 VP8 (decoders: vp8 vp8_v4l2m2m vp8_cuvid ) (encoders: vp8_v4l2m2m )
D.V.L. vp9 Google VP9 (decoders: vp9 vp9_v4l2m2m vp9_cuvid )
Your ffmpeg build has a Video4Linux wrapper available for a hardware VP8 encoder, but no actual hardware VP8 encoder available.
For software encoding of VP8/VP9, you'll need libvpx enabled and linked. You can get a static git binary from https://johnvansickle.com/ffmpeg/

FFMPEG hevc_nvenc "No NVENC capable devices found" with NVidia GTX950M

I get the error "No NVENC capable devices found" when trying a simple encoding like this, even skipping audio to make sure it's not an audio problem:
ffmpeg.exe -i input.mp4 -c:v hevc_nvenc -an out.mp4
I also tried with more details, like setting the pixel format, the preset, the rate-control, the format.
On the documentation page there:
https://trac.ffmpeg.org/wiki/HWAccelIntro
it says that if we get this error we should check for the pixel format. The video has yuv420p here and even specifying the format results in the same error.
i also checked the NVidia supported cards and it says GeForce, but no details about the models:
https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder
I tried h264_nvenc and it works perfectly however, the problem is only with hevc_nvenc
Has anyone encountered this problem?
Complete console output:
[h264 # 0000000002534560] Reinit context to 1280x544, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
creation_time : 2014-05-23T13:04:15.000000Z
Duration: 01:54:03.95, start: 0.000000, bitrate: 3193 kb/s
Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1280x544 [SAR 1:1 DAR 40:17], 2750 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2014-05-23T11:25:27.000000Z
Stream #0:1(spa): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 439 kb/s (default)
Metadata:
creation_time : 2014-05-23T12:56:43.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
[h264 # 000000000260ea40] Reinit context to 1280x544, pix_fmt: yuv420p
[graph 0 input from stream 0:0 # 0000000003857ec0] w:1280 h:544 pixfmt:yuv420p tb:1/24000 fr:24000/1001 sar:1/1 sws_param:flags=2
[hevc_nvenc # 00000000038574e0] Loaded Nvenc version 8.0
[hevc_nvenc # 00000000038574e0] Nvenc initialized successfully
[hevc_nvenc # 00000000038574e0] 1 CUDA capable devices found
[hevc_nvenc # 00000000038574e0] [ GPU #0 - < GeForce GTX 950M > has Compute SM 5.0 ]
[hevc_nvenc # 00000000038574e0] Codec not supported
[hevc_nvenc # 00000000038574e0] No NVENC capable devices found
[hevc_nvenc # 00000000038574e0] Nvenc unloaded
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
950M doesn't support h265 codec indeed.
From nvidia nvenc page or the detailed support matrix, we can learn that h265/hevc is supported only from 2nd generation maxwell GPU.
Also check the maxwell wiki page and list of NVIDIA GPU. You can see that 950M's code name is GM107 which is a 1st generation maxwell architecture, that means no h265 support. Sorry, you have to fall back to h264.

Ffmpeg didn't burn srt subtitle on mkv properly

`ffmpeg version:git-fc6de70 (2013-07-18) with libass and fontconfig support.
command line:ffmpeg.exe -i test.mkv -vf subtitles=test.srt out.mkv
and i got this error.:
Metadata:
encoder : Lavf55.12.102
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x5
76 [SAR 1:1 DAR 20:9], q=-1--1, 1k tbn, 23.98 tbc (default)
Stream #0:1: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo
, fltp (default)
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libvorbis)
Press [q] to stop, [?] for help
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. A
ssuming 384x288
http://tinypic.com/r/2ag52so/5
The message you get:
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. Assuming 384x288
means that your ssa or srt file doesn't specify the PlayResX and Y values. So the VFilter assume a display resolution of 384x288, thats why your subtitles looks so small on a 1280x576 video.
A workaround for your issue is:
convert SRT to SSA/ASS
ffmpeg -i file.srt file.ass
edit your SSA/ASS file to set the correct value. For SSA the format is describe here and it's easy to set PlayRes X and Y.
[Script Info]
; This is a Sub Station Alpha v4 script.
....
ScriptType: v4.00
Collisions: Normal
PlayResX: 1280
PlayResY: 576
PlayDepth: 0
....
And finally, launch your command again using the ass file.
Burning subntitles with FFmpeg is tricky due to canvas size with pictured-based subtitles and charset encoding with text files (srt or ssa).
I guess I managed to handle it for almost all cases in DVDx 4.1 Free Encoder version (Beta 1.0):
http://www.labdv.com/dvdx/4.1/docs/burn-subtitles-in-video.php

HD FLV video playing slow

I have a few videos which I have captured from a Live Streaming Media Server and they are in FLV Format. Now, the problem is, though the videos are captured completely but when I play them in VLC Media Player, they play very slowly, almost frame by frame like a slideshow.
Here are the details of the Video codec, audio codec, bitrate and other details of the video which I got using ffmpeg:
[flv # 0051e9a0] Invalid keyframes object, skipping.
[flv # 0051e9a0] Keyframe index parsing failed
Input #0, flv, from 'tofix.flv':
Metadata:
audiodelay : 0
audiosize : 6607344
canSeekToEnd : false
datasize : 271773993
hasAudio : true
hasCuePoints : false
hasKeyframes : true
hasMetadata : true
hasVideo : true
lastkeyframetimestamp: 424
lasttimestamp : 425
metadatacreator : inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/fl
vtool2
videosize : 265143027
Duration: 00:07:04.62, start: 0.000000, bitrate: 1903 kb/s
Stream #0:0: Video: flv1, yuv420p, 960x540, 5112 kb/s, 29.97 tbr, 1k tbn, 1k
tbc
Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16, 112 kb/s
At least one output file must be specified
The bit rate is 1903 kbps and the codec is flv1.
I also captured some other videos from the server which are in h.264 codec with a bit rate of 563 kbps and they play properly.
Is there a way I can play these high definition FLV files in my media player smoothly?
It would be great if this is possible.
I have tried converting the FLV video to AVI using ffmpeg, however, the issue still remains.
Your container says 1 fps [1 tbn] so it is playing at 1 fps. Remux them with 29.97 and also fix your capture mechanism.
Question is more fit for Stack overflow.

Resources