ffmpeg can´t handle udp rstp streams

Forum for questions and support relating to the 1.26.x releases only.
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

ffmpeg can´t handle udp rstp streams

Post by Torsten73 »

Edit: After hours of research, i found out, that its an old bug (for several years now!) from ffmpeg. So we arn´t able to use h264 streams ... But read the rest, then you will see.

Its maybe the same problem with other postings, but i wish to specify my problems, don´t know if they difference...

Setup:
- ubuntu 12.04.03 with zm and avconv, both from ubuntu running in a kvm-vm with 4 cores on a quadcore xeon server System, 2gb ram for vm
- upgrade with iconnor ppa, needed to correct the database path in zm.conf for getting it sucksessful.
- 4 MP Cams (3* Level One wcs-0030 1280*800 with h264 or mpeg , 1 * older axis with only 1280*1024 mpeg)
- watching the zm on a second monitor with firefox, on ie i never get a picture (cambozola plugin is not fine, it fills my harddrive till it´s full)

when i configure all cams with mpeg i get a poor frame rate of 15 Frames. only with h256 i will get till 30 frames (in zm shown 25) My system load is nearly full with maximum framrate and when motion is in the picture (no motion detection enabled) it gets first slower and after a few seconds it runs with ultra fast speed... not really working good.

So i tought i should better use h264. But its amazing to get it work. No dokumentation is here, because all the option for ffmpeg are a secret (for me). Together with other secrets i don´t understand.

My unknown things are all from options Menu:
- why i have no picture when switching from jpeg to mpeg, te browser changes to vlc but no video
- video stream format under picture, what shall we use here??? swf or asf ? Or anything else is better?
- ffmpeg options seems to make no difference! same picture alle the time, no quality changes. i used this settings: http://www.zoneminder.com/wiki/index.php/Ffmpeg
- ffmpeg output format ??? no changing anyway i use h264, mpg, avi, etc

I thing with the correct ffmpeg options it would work fine with h264 streams, correct?

I would be happy for every help, i last so many hours with getting better results.

Thanks
Last edited by Torsten73 on Fri Sep 20, 2013 11:52 pm, edited 1 time in total.
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

I also have the same Errors in log like http://www.zoneminder.com/forums/viewto ... 29&t=20733

Code: Select all

Sep 20 18:58:33 ZoneMinder web_php[1122]: ERR [socket_sendto( /tmp/zm/zms-334825s.sock ) failed: Connection refused]
Sep 20 18:58:33 ZoneMinder web_php[28052]: ERR [socket_sendto( /tmp/zm/zms-808614s.sock ) failed: Connection refused]
Sep 20 18:58:33 ZoneMinder web_php[1122]: ERR [socket_sendto( /tmp/zm/zms-240295s.sock ) failed: Connection refused]
Sep 20 18:58:39 ZoneMinder web_php[28038]: ERR [socket_sendto( /tmp/zm/zms-922750s.sock ) failed: Connection refused]
Every Cam gives me this error when switching to mpeg on option WEB_P_STREAM_METHOD
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Magic919 »

Are these files actually there? /tmp/zm/zms-334825s.sock

What are the permissions/ownership like. Can your user that runs Apache access them?
-
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

test.JPG
test.JPG (178.51 KiB) Viewed 18548 times
at this moment i have a live video with mpeg, after i deleted MPEG_LIVE_FORMAT .
the tmp owner is www_data, but the picture quality is still very poor.

apache user should be the same, how can i proove it ? can you join irc?

Edit: ah i know what gets me a picture under ff, i disabled auto detection of browser capability to force using cambozola. And it does it, but the picte problem is still the same like using firefox nativ
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Magic919 »

If you want to check web user you can run ps -ef | grep apache . You'll see the zm processes there too.

I presume you are running 1.26.3. 1.26.x certainly better performance, lower load.

Do you _need_ such a high framerate?
-
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

yes it 1.26.3.

Code: Select all

root@ZoneMinder:/home/torsten# ps -ef | grep apache
root      1061     1  0 19:54 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2178  1061  0 19:56 ?        00:00:01 /usr/sbin/apache2 -k start
www-data  2179  1061  0 19:56 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2181  1061  0 19:56 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2275  1061  0 19:56 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2276  1061  0 19:56 ?        00:00:01 /usr/sbin/apache2 -k start
www-data  8553  1061  0 20:15 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  9705  1061  0 20:18 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  9706  1061  0 20:18 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 11208  1061  0 20:22 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 11209  1061  0 20:22 ?        00:00:00 /usr/sbin/apache2 -k start
root     11560  3213  0 20:23 pts/0    00:00:00 grep --color=auto apache
so thats ok.

10 Fps isnt really much, controlling the frame rate is also very irritating. i set the cams to 10fps, so the web monitor shows this fps also. but inside the options i seemd to be unable to controll it anywhere. I would like to have more fps on 1280*800, because my cams are capable of 25 fps on good light conditions. But this is only for live view. when i record it i thing 10fps are enough. If the system power is enough...
i haven´t recorded anything till now, because i couldn´t get it run without this disturbing picture.
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

i have upgraded ffmpeg with ***//launchpad.***/~jon-severinsson/+archive/ffmpeg?field.series_filter=precise that should be the new enough.

But i also don´t understand the controlling of picture tab. so many option, with no explanation wich helps. what should i enter here for a working h264 stream over ffmpeg?

and i also can´t see in htop that ffmpeg is beeing used. Why not?
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Magic919 »

Is that with ZM stopped? I'd expect to see the ZM processes show up too.
-
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

yes this is with a running zm. But it also the same when i stop zm.

Code: Select all

root@ZoneMinder:/home/torsten# ps -ef | grep zm
www-data 18079     1  1 20:42 ?        00:00:00 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
www-data 18102 18079 52 20:42 ?        00:00:02 /usr/bin/zmc -m 1
www-data 18106 18079 37 20:42 ?        00:00:01 /usr/bin/zmc -m 2
www-data 18111 18079 45 20:42 ?        00:00:02 /usr/bin/zmc -m 3
www-data 18117 18079 28 20:42 ?        00:00:01 /usr/bin/zmc -m 5
www-data 18123 18079 10 20:42 ?        00:00:00 /usr/bin/perl -wT /usr/bin/zmfilter.pl
www-data 18128 18079  6 20:42 ?        00:00:00 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
www-data 18133 18079  7 20:42 ?        00:00:00 /usr/bin/perl -wT /usr/bin/zmwatch.pl
root     18169  3213  0 20:42 pts/0    00:00:00 grep --color=auto zm
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

how can i see wich command is used for ffmpeg? is that with ps also possible ? i can see ist activ, but not more. Its maybe interesting if it uses my parameter from webif.
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

how crazy is that? i changed path_ffmpeg from /usr/bin/ffmpeg to /usr/bin/ffmpeggg restartet zm, but i still have a video???? i believe my path_ffmpeg isn´t used, therefor i can give ffmpeg options like i want, nothing will change ...
picture_options.JPG
picture_options.JPG (116.89 KiB) Viewed 18543 times
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

next i noticed is, that if i leave mpeg_live_format empty i get the video with mpeg but i don´t know what is used for showing it.
If i set any option in it like asf or mkv vlc will start in the live web window but showing only a black screen and with this error for 4 cam activ:

Code: Select all

Sep 20 21:28:44 ZoneMinder web_php[1473]: ERR [socket_sendto( /tmp/zm/zms-163349s.sock ) failed: Connection refused]
Sep 20 21:28:46 ZoneMinder web_php[20354]: ERR [socket_sendto( /tmp/zm/zms-042643s.sock ) failed: Connection refused]
Sep 20 21:28:47 ZoneMinder web_php[1473]: ERR [socket_sendto( /tmp/zm/zms-739615s.sock ) failed: Connection refused]
Sep 20 21:28:47 ZoneMinder web_php[20354]: ERR [socket_sendto( /tmp/zm/zms-095248s.sock ) failed: Connection refused]
Sep 20 21:28:47 ZoneMinder web_php[1473]: ERR [socket_sendto( /tmp/zm/zms-163349s.sock ) failed: Connection refused]

Code: Select all

root@ZoneMinder:/home/torsten# ls -l /tmp/zm/zms-163349s.sock
srwxr-xr-x 1 www-data www-data 0 Sep 20 21:28 /tmp/zm/zms-163349s.sock
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

hmm, ffmpeg seems to be unable to decode the stream?

Code: Select all

root@ZoneMinder:/home/torsten# ffmpeg -i rtsp://192.168.115.202:554/channel1 /home/torsten/test.avi
ffmpeg version 0.10.8-7:0.10.8-1~precise1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep  5 2013 14:56:20 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.8-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --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-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  avcodec     configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.8-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --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-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libvo-amrwbenc
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[h264 @ 0xd0eb80] P sub_mb_type 12 out of range at 36 11
[h264 @ 0xd0eb80] error while decoding MB 36 11
[h264 @ 0xd0eb80] concealing 3133 DC, 3133 AC, 3133 MV errors
[h264 @ 0xd0eb80] out of range intra chroma pred mode at 70 11
[h264 @ 0xd0eb80] error while decoding MB 70 11
[h264 @ 0xd0eb80] concealing 3099 DC, 3099 AC, 3099 MV errors
[h264 @ 0xd0eb80] concealing 3091 DC, 3091 AC, 3091 MV errors
[h264 @ 0xd0eb80] concealing 3086 DC, 3086 AC, 3086 MV errors
[h264 @ 0xd0eb80] concealing 3094 DC, 3094 AC, 3094 MV errors
[h264 @ 0xd0eb80] concealing 3099 DC, 3099 AC, 3099 MV errors
[rtsp @ 0xd06680] Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://192.168.115.202:554/channel1':
  Metadata:
    title           : Session streamed by stream
    comment         : 1
  Duration: N/A, start: 0.039889, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuvj420p, 1280x800, 5 fps, 20 tbr, 90k tbn, 10 tbc
Incompatible pixel format 'yuvj420p' for codec 'mpeg4', auto-selecting format 'yuv420p'
[buffer @ 0xd10460] w:1280 h:800 pixfmt:yuvj420p tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 0xd155e0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0xd049a0] w:1280 h:800 fmt:yuvj420p -> w:1280 h:800 fmt:yuv420p flags:0x4
Output #0, avi, to '/home/torsten/test.avi':
  Metadata:
    INAM            : Session streamed by stream
    ICMT            : 1
    ISFT            : Lavf53.32.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x800, q=2-31, 200 kb/s, 20 tbn, 20 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
Press [q] to stop, [?] for help
[h264 @ 0x1082400] P sub_mb_type 12 out of range at 36 11
[h264 @ 0x1082400] error while decoding MB 36 11
[h264 @ 0x1082400] concealing 3133 DC, 3133 AC, 3133 MV errors
[h264 @ 0x1082a20] out of range intra chroma pred mode at 70 11
[h264 @ 0x1082a20] error while decoding MB 70 11
[h264 @ 0x1082a20] concealing 3099 DC, 3099 AC, 3099 MV errors
[h264 @ 0x1083060] corrupted macroblock 77 11 (total_coeff=-1)
[h264 @ 0x1083060] error while decoding MB 77 11
[h264 @ 0x1083060] concealing 3092 DC, 3092 AC, 3092 MV errors
[h264 @ 0x10836a0] Invalid level prefix
[h264 @ 0x10836a0] error while decoding MB 2 12
[h264 @ 0x10836a0] concealing 3087 DC, 3087 AC, 3087 MV errors
[h264 @ 0x10815c0] concealing 3094 DC, 3094 AC, 3094 MV errors
[h264 @ 0x1082400] concealing 3099 DC, 3099 AC, 3099 MV errors
[mpeg4 @ 0xd0fe40] Error, Invalid timestamp=0, last=0
Video encoding failed
Torsten73
Posts: 26
Joined: Thu Sep 19, 2013 9:45 pm

Re: couldn´t get ffmpeg get working for Firefox, got no vide

Post by Torsten73 »

i have found the reason. Short form: ffmpeg has problems with udp stream over rtsp.
https://trac.ffmpeg.***/ticket/285

I found no way to force ffmpeg to connect over tcp, wich would be a soulution.

Maybe someone has an idea, but the problem is old and therefor i will better forget to try it anymore. Spend the hole evening for research.
pok
Posts: 9
Joined: Tue Feb 14, 2012 1:29 pm

Re: ffmpeg can´t handle udp rstp streams

Post by pok »

>i have found the reason. Short form: ffmpeg has problems with udp stream over rtsp.
problem with fragmented packets... patch from warmcat (url see in messages, as new user i can`t post it) solved this problem...

but it`s so old...

I offer my patch (on current version - 1.26.3) see attached file
Attachments
master2rtsp.zip
recive rtsp stream
(3.71 KiB) Downloaded 596 times
Locked