Closed LeoBras closed 8 years ago
You can use extended version of VideoCapture interface to explicitly set needed backend: set apiPreference parameter. Looks like in your case gstreamer backend works fine - cv::CAP_GSTREAMER
.
Ok, but It also means that ffmpeg backend is not working. I tried ffplay and it works fine. Why don't ffmpeg backend works? Am I missing something?
Sorry, my bad. It was a bad FFMPEG compilation I was using. I fixed it and now it works fine.
Thank you all!
@LeoBras I faced with such problem too. My opencv works fine with rtsp stream but with delay (~3-5seconds) . Can you say how you solve this problem?
I solved by that doing many grabs before a retrieve. This way I get to skip some frames, but I get real time image.
Em 25 de dez de 2017 11:50 AM, "vardanaloyan" notifications@github.com escreveu:
@LeoBras https://github.com/leobras I faced with such problem too. My opencv works fine with rtsp stream but with delay (~3-5seconds) . Can you say how you solve this problem?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/opencv/opencv/issues/7330#issuecomment-353870732, or mute the thread https://github.com/notifications/unsubscribe-auth/AS06PxVatmLAihRmTh634J7-Szi0C4rpks5tD6gkgaJpZM4KD-A3 .
@LeoBras I have a doubt that even if I used grab(many, many grabs before retrieve until time limit), it cannot take a real time image. May I request some help? During the compilation I've also set the WITH_FFMPEG to ON via cmake-gui, and it also detected ffmpeg libs I've built. Is there any thing I missed?
I'm working with opencv 3.3.1 in python. with ffmpeg 3.4.1 I've also tried to record a video from the camera in 4000kbps via ffmpeg. :-) I put the screen in front of the screen display, so that I can see the delay between the mp4 and the screen decoding time. Even the ffmpeg would have a 4s delay, which makes me crazy.
Here is output from configuring ffmpeg(./configure --enable-shared --prefix=/usr/local/ffmpeg):
`_install prefix /usr/local/ffmpeg source path . C compiler gcc C library glibc ARCH x86 (generic) big-endian no runtime cpu detection yes standalone assembly yes x86 assembler yasm MMX enabled yes MMXEXT enabled yes 3DNow! enabled yes 3DNow! extended enabled yes SSE enabled yes SSSE3 enabled yes AESNI enabled yes AVX enabled yes AVX2 enabled yes XOP enabled yes FMA3 enabled yes FMA4 enabled yes i686 features enabled yes CMOV is fast yes EBX available yes EBP available yes debug symbols yes strip symbols yes optimize for size no optimizations yes static yes shared yes postprocessing support no network support yes threading support pthreads safe bitstream reader yes texi2html enabled no perl enabled yes pod2man enabled yes makeinfo enabled yes makeinfo supports HTML yes
External libraries: alsa libxcb_shape lzma iconv libxcb_shm xlib libxcb libxcb_xfixes zlib
External libraries providing hardware acceleration: cuda nvenc vaapi cuvid v4l2_m2m vdpau
Libraries: avcodec avformat swresample avdevice avutil swscale avfilter
Programs: ffmpeg ffprobe ffserver
Enabled decoders: aac aura evrc aac_fixed aura2 exr aac_latm avrn ffv1 aasc avrp ffvhuff ac3 avs ffwavesynth ac3_fixed avui fic adpcm_4xm ayuv fits adpcm_adx bethsoftvid flac adpcm_afc bfi flashsv adpcm_aica bink flashsv2 adpcm_ct binkaudio_dct flic adpcm_dtk binkaudio_rdft flv adpcm_ea bintext fmvc adpcm_ea_maxis_xa bitpacked fourxm adpcm_ea_r1 bmp fraps adpcm_ea_r2 bmv_audio frwu adpcm_ea_r3 bmv_video g2m adpcm_ea_xas brender_pix g723_1 adpcm_g722 c93 g729 adpcm_g726 cavs gdv adpcm_g726le ccaption gif adpcm_ima_amv cdgraphics gremlin_dpcm adpcm_ima_apc cdxl gsm adpcm_ima_dat4 cfhd gsm_ms adpcm_ima_dk3 cinepak h261 adpcm_ima_dk4 clearvideo h263 adpcm_ima_ea_eacs cljr h263_v4l2m2m adpcm_ima_ea_sead cllc h263i adpcm_ima_iss comfortnoise h263p adpcm_ima_oki cook h264 adpcm_ima_qt cpia h264_cuvid adpcm_ima_rad cscd h264_v4l2m2m adpcm_ima_smjpeg cyuv h264_vdpau adpcm_ima_wav dca hap adpcm_ima_ws dds hevc adpcm_ms dfa hevc_cuvid adpcm_mtaf dirac hnm4_video adpcm_psx dnxhd hq_hqa adpcm_sbpro_2 dolby_e hqx adpcm_sbpro_3 dpx huffyuv adpcm_sbpro_4 dsd_lsbf iac adpcm_swf dsd_lsbf_planar idcin adpcm_thp dsd_msbf idf adpcm_thp_le dsd_msbf_planar iff_ilbm adpcm_vima dsicinaudio imc adpcm_xa dsicinvideo indeo2 adpcm_yamaha dss_sp indeo3 aic dst indeo4 alac dvaudio indeo5 alias_pix dvbsub interplay_acm als dvdsub interplay_dpcm amrnb dvvideo interplay_video amrwb dxa jacosub amv dxtory jpeg2000 anm dxv jpegls ansi eac3 jv ape eacmv kgv1 apng eamad kmvc ass eatgq lagarith asv1 eatgv loco asv2 eatqi m101 atrac1 eightbps mace3 atrac3 eightsvx_exp mace6 atrac3al eightsvx_fib magicyuv atrac3p escape124 mdec atrac3pal escape130 metasound microdvd pcm_lxf sgi mimic pcm_mulaw sgirle mjpeg pcm_s16be sheervideo mjpeg_cuvid pcm_s16be_planar shorten mjpegb pcm_s16le sipr mlp pcm_s16le_planar smackaud mmvideo pcm_s24be smacker motionpixels pcm_s24daud smc movtext pcm_s24le smvjpeg mp1 pcm_s24le_planar snow mp1float pcm_s32be sol_dpcm mp2 pcm_s32le sonic mp2float pcm_s32le_planar sp5x mp3 pcm_s64be speedhq mp3adu pcm_s64le srgc mp3adufloat pcm_s8 srt mp3float pcm_s8_planar ssa mp3on4 pcm_u16be stl mp3on4float pcm_u16le subrip mpc7 pcm_u24be subviewer mpc8 pcm_u24le subviewer1 mpeg1_cuvid pcm_u32be sunrast mpeg1_v4l2m2m pcm_u32le svq1 mpeg1_vdpau pcm_u8 svq3 mpeg1video pcm_zork tak mpeg2_cuvid pcx targa mpeg2_v4l2m2m pgm targa_y216 mpeg2video pgmyuv tdsc mpeg4 pgssub text mpeg4_cuvid pictor theora mpeg4_v4l2m2m pixlet thp mpeg4_vdpau pjs tiertexseqvideo mpeg_vdpau png tiff mpegvideo ppm tmv mpl2 prores truehd msa1 prores_lgpl truemotion1 mscc psd truemotion2 msmpeg4v1 ptx truemotion2rt msmpeg4v2 qcelp truespeech msmpeg4v3 qdm2 tscc msrle qdmc tscc2 mss1 qdraw tta mss2 qpeg twinvq msvideo1 qtrle txd mszh r10k ulti mts2 r210 utvideo mvc1 ra_144 v210 mvc2 ra_288 v210x mxpeg ralf v308 nellymoser rawvideo v408 nuv realtext v410 on2avc rl2 vb opus roq vble paf_audio roq_dpcm vc1 paf_video rpza vc1_cuvid pam rscc vc1_v4l2m2m pbm rv10 vc1_vdpau pcm_alaw rv20 vc1image pcm_bluray rv30 vcr1 pcm_dvd rv40 vmdaudio pcm_f16le s302m vmdvideo pcm_f24le sami vmnc pcm_f32be sanm vorbis pcm_f32le scpr vp3 pcm_f64be screenpresso vp5 pcm_f64le sdx2_dpcm vp6 vp6a wmav2 xface vp6f wmavoice xl vp7 wmv1 xma1 vp8 wmv2 xma2 vp8_cuvid wmv3 xpm vp8_v4l2m2m wmv3_vdpau xsub vp9 wmv3image xwd vp9_cuvid wnv1 y41p vplayer wrapped_avframe ylc vqa ws_snd1 yop wavpack xan_dpcm yuv4 webp xan_wc3 zero12v webvtt xan_wc4 zerocodec wmalossless xbin zlib wmapro xbm zmbv wmav1
Enabled encoders: a64multi jpeg2000 pgmyuv a64multi5 jpegls png aac ljpeg ppm ac3 mjpeg prores ac3_fixed mjpeg_vaapi prores_aw adpcm_adx mlp prores_ks adpcm_g722 movtext qtrle adpcm_g726 mp2 r10k adpcm_g726le mp2fixed r210 adpcm_ima_qt mpeg1video ra_144 adpcm_ima_wav mpeg2_vaapi rawvideo adpcm_ms mpeg2video roq adpcm_swf mpeg4 roq_dpcm adpcm_yamaha mpeg4_v4l2m2m rv10 alac msmpeg4v2 rv20 alias_pix msmpeg4v3 s302m amv msvideo1 sgi apng nellymoser snow ass nvenc sonic asv1 nvenc_h264 sonic_ls asv2 nvenc_hevc srt avrp opus ssa avui pam subrip ayuv pbm sunrast bmp pcm_alaw svq1 cinepak pcm_f32be targa cljr pcm_f32le text comfortnoise pcm_f64be tiff dca pcm_f64le truehd dnxhd pcm_mulaw tta dpx pcm_s16be utvideo dvbsub pcm_s16be_planar v210 dvdsub pcm_s16le v308 dvvideo pcm_s16le_planar v408 eac3 pcm_s24be v410 ffv1 pcm_s24daud vc2 ffvhuff pcm_s24le vorbis fits pcm_s24le_planar vp8_v4l2m2m flac pcm_s32be vp8_vaapi flashsv pcm_s32le wavpack flashsv2 pcm_s32le_planar webvtt flv pcm_s64be wmav1 g723_1 pcm_s64le wmav2 gif pcm_s8 wmv1 h261 pcm_s8_planar wmv2 h263 pcm_u16be wrapped_avframe h263_v4l2m2m pcm_u16le xbm h263p pcm_u24be xface h264_nvenc pcm_u24le xsub h264_v4l2m2m pcm_u32be xwd h264_vaapi pcm_u32le y41p hevc_nvenc pcm_u8 yuv4 hevc_vaapi pcx zlib huffyuv pgm zmbv
Enabled hwaccels: h263_vaapi mpeg1_cuvid vc1_cuvid h264_cuvid mpeg1_vdpau vc1_vaapi h264_vaapi mpeg2_cuvid vc1_vdpau h264_vdpau mpeg2_vaapi vp8_cuvid hevc_cuvid mpeg2_vdpau vp9_cuvid hevc_vaapi mpeg4_cuvid vp9_vaapi hevc_vdpau mpeg4_vaapi wmv3_vaapi mjpeg_cuvid mpeg4_vdpau wmv3_vdpau
Enabled parsers: aac dvdsub opus aac_latm flac png ac3 g729 pnm adx gsm rv30 bmp h261 rv40 cavsvideo h263 sipr cook h264 tak dca hevc vc1 dirac mjpeg vorbis dnxhd mlp vp3 dpx mpeg4video vp8 dvaudio mpegaudio vp9 dvbsub mpegvideo xma dvd_nav
Enabled demuxers: aa flac lrc aac flic lvf ac3 flv lxf acm fourxm m4v act frm matroska adf fsb mgsts adp g722 microdvd ads g723_1 mjpeg adx g726 mjpeg_2000 aea g726le mlp afc g729 mlv aiff gdv mm aix genh mmf amr gif mov anm gsm mp3 apc gxf mpc ape h261 mpc8 apng h263 mpegps aqtitle h264 mpegts asf hevc mpegtsraw asf_o hls mpegvideo ass hnm mpjpeg ast ico mpl2 au idcin mpsub avi idf msf avr iff msnwc_tcp avs ilbc mtaf bethsoftvid image2 mtv bfi image2_alias_pix musx bfstm image2_brender_pix mv bink image2pipe mvi bintext image_bmp_pipe mxf bit image_dds_pipe mxg bmv image_dpx_pipe nc boa image_exr_pipe nistsphere brstm image_j2k_pipe nsv c93 image_jpeg_pipe nut caf image_jpegls_pipe nuv cavsvideo image_pam_pipe ogg cdg image_pbm_pipe oma cdxl image_pcx_pipe paf cine image_pgm_pipe pcm_alaw concat image_pgmyuv_pipe pcm_f32be data image_pictor_pipe pcm_f32le daud image_png_pipe pcm_f64be dcstr image_ppm_pipe pcm_f64le dfa image_psd_pipe pcm_mulaw dirac image_qdraw_pipe pcm_s16be dnxhd image_sgi_pipe pcm_s16le dsf image_sunrast_pipe pcm_s24be dsicin image_svg_pipe pcm_s24le dss image_tiff_pipe pcm_s32be dts image_webp_pipe pcm_s32le dtshd image_xpm_pipe pcm_s8 dv ingenient pcm_u16be dvbsub ipmovie pcm_u16le dvbtxt ircam pcm_u24be dxa iss pcm_u24le ea iv8 pcm_u32be ea_cdata ivf pcm_u32le eac3 ivr pcm_u8 epaf jacosub pjs ffm jv pmp ffmetadata live_flv pva filmstrip lmlm4 pvf fits loas qcp r3d smush vc1t rawvideo sol vivo realtext sox vmd redspark spdif vobsub rl2 srt voc rm stl vpk roq str vplayer rpl subviewer vqf rsd subviewer1 w64 rso sup wav rtp svag wc3 rtsp swf webm_dash_manifest s337m tak webvtt sami tedcaptions wsaud sap thp wsd sbg threedostr wsvqa scc tiertexseq wtv sdp tmv wv sdr2 truehd wve sds tta xa sdx tty xbin segafilm txd xmv shorten v210 xvag siff v210x xwma sln vag yop smacker vc1 yuv4mpegpipe smjpeg
Enabled muxers: a64 ilbc pcm_s24le ac3 image2 pcm_s32be adts image2pipe pcm_s32le adx ipod pcm_s8 aiff ircam pcm_u16be amr ismv pcm_u16le apng ivf pcm_u24be asf jacosub pcm_u24le asf_stream latm pcm_u32be ass lrc pcm_u32le ast m4v pcm_u8 au matroska psp avi matroska_audio rawvideo avm2 md5 rm bit microdvd roq caf mjpeg rso cavsvideo mkvtimestamp_v2 rtp crc mlp rtp_mpegts dash mmf rtsp data mov sap daud mp2 scc dirac mp3 segment dnxhd mp4 singlejpeg dts mpeg1system smjpeg dv mpeg1vcd smoothstreaming eac3 mpeg1video sox f4v mpeg2dvd spdif ffm mpeg2svcd spx ffmetadata mpeg2video srt fifo mpeg2vob stream_segment filmstrip mpegts sup fits mpjpeg swf flac mxf tee flv mxf_d10 tg2 framecrc mxf_opatom tgp framehash null truehd framemd5 nut tta g722 oga uncodedframecrc g723_1 ogg vc1 g726 ogv vc1t g726le oma voc gif opus w64 gsm pcm_alaw wav gxf pcm_f32be webm h261 pcm_f32le webm_chunk h263 pcm_f64be webm_dash_manifest h264 pcm_f64le webp hash pcm_mulaw webvtt hds pcm_s16be wtv hevc pcm_s16le wv hls pcm_s24be yuv4mpegpipe ico
Enabled protocols: async http rtmpt cache httpproxy rtp concat icecast srtp crypto md5 subfile data mmsh tcp ffrtmphttp mmst tee file pipe udp ftp prompeg udplite gopher rtmp unix hls
Enabled filters: abench blackdetect framestep abitscope blend gblur acompressor bwdif gradfun acopy cellauto haas acrossfade channelmap haldclut acrusher channelsplit haldclutsrc adelay chorus hdcd adrawgraph chromakey headphone aecho ciescope hflip aemphasis codecview highpass aeval color histogram aevalsrc colorbalance hqx afade colorchannelmixer hstack afftfilt colorkey hue afir colorlevels hwdownload aformat colorspace hwmap agate compand hwupload ahistogram compensationdelay hwupload_cuda ainterleave concat hysteresis alimiter convolution idet allpass convolve il allrgb copy inflate allyuv crop interleave aloop crossfeed join alphaextract crystalizer lenscorrection alphamerge curves life amerge datascope limiter ametadata dcshift loop amix dctdnoiz loudnorm amovie deband lowpass anequalizer decimate lumakey anoisesrc deflate lut anull deflicker lut2 anullsink deinterlace_vaapi lut3d anullsrc dejudder lutrgb apad deshake lutyuv aperms despill mandelbrot aphasemeter detelecine maskedclamp aphaser dilation maskedmerge apulsator displace mergeplanes arealtime doubleweave mestimate aresample drawbox metadata areverse drawgraph midequalizer aselect drawgrid minterpolate asendcmd dynaudnorm movie asetnsamples earwax negate asetpts ebur128 nlmeans asetrate edgedetect noformat asettb elbg noise ashowinfo equalizer null asidedata erosion nullsink asplit extractplanes nullsrc astats extrastereo oscilloscope astreamselect fade overlay atadenoise fftfilt pad atempo field palettegen atrim fieldhint paletteuse avectorscope fieldmatch pan avgblur fieldorder perms bandpass firequalizer pixdesctest bandreject flanger pixscope bass floodfill premultiply bbox format prewitt bench fps pseudocolor biquad framepack psnr bitplanenoise framerate qp random showspectrumpic testsrc readeia608 showvolume testsrc2 readvitc showwaves threshold realtime showwavespic thumbnail remap shuffleframes tile removegrain shuffleplanes tlut2 removelogo sidechaincompress tonemap replaygain sidechaingate transpose reverse sidedata treble rgbtestsrc signalstats tremolo roberts silencedetect trim rotate silenceremove unpremultiply scale sine unsharp scale2ref smptebars vectorscope scale_vaapi smptehdbars vflip select sobel vibrato selectivecolor spectrumsynth vignette sendcmd split vmafmotion separatefields ssim volume setdar stereotools volumedetect setfield stereowiden vstack setpts streamselect w3fdif setsar superequalizer waveform settb surround weave showcqt swaprect xbr showfreqs swapuv yadif showinfo tblend yuvtestsrc showpalette telecine zoompan showspectrum
Enabled bsfs: aac_adtstoasc imx_dump_header null chomp mjpeg2jpeg remove_extradata dca_core mjpega_dump_header text2movsub dump_extradata mov2textsub vp9_raw_reorder extract_extradata mp3_header_decompress vp9_superframe h264_mp4toannexb mpeg4_unpack_bframes vp9_superframe_split hevc_mp4toannexb noise
Enabled indevs: alsa lavfi v4l2 fbdev oss xcbgrab
Enabled outdevs: alsa oss v4l2 fbdev_ `
Is there anything missed?
System information (version)
Detailed description
I am trying to make my ONVIF IP Camera work with OpenCV, (now trying rtsp), but I can't get it to work if I compile OpenCV with WITH_FMPEG=ON. If I just turn WITH_FMPEG=OFF it works fine (with a 3~4 second delay, but that's another stuff).
I believe it's a bug because enabling options should not make stuff stop working.
Steps to reproduce
Compile OpenCV with WITH_FFMPEG=ON make and run -> See output ffmpeg. Compile OpenCV with WITH_FFMPEG=OFF make and run -> See output no_ffmpeg.
Outputs are attached. Output_FFMPEG.txt Output_No_FFMPEG.txt
Code: