ffmpeg stop

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
ZioTibia81
Posts: 6
Joined: Thu Oct 26, 2017 12:44 pm

ffmpeg stop

Post by ZioTibia81 » Thu Oct 25, 2018 8:11 pm

Hi!
I have an unnamed hisilicon based ip camera.
If I use ffmpeg with rtsp tcp and H264 passthrough video writer, zmc restart every one minute:

Code: Select all

10/25/18 21:31:22.816600 zmc_m3[2840].DB1-zm_videostore.cpp/743 [duration calc: pts(5508000) - last_pts( 5497200) = (10800)]
10/25/18 21:31:22.900824 zmc_m3[2840].INF-zm_ffmpeg_camera.cpp/710 [Unable to read packet from stream 0: error -541478725 "End of file".]
10/25/18 21:31:22.956312 zmc_m3[2840].INF-zm_monitor.cpp/2387 [Return from Capture (-1), signal loss]
10/25/18 21:31:22.979284 zmc_m3[2840].INF-zmc.cpp/311 [Failed to capture image from monitor 3 CAM3 (1/1)]
10/25/18 21:31:23.001260 zmc_m3[2840].DB1-zm_videostore.cpp/414 [Flushing interleaved queues]
10/25/18 21:31:23.001713 zmc_m3[2840].DB1-zm_videostore.cpp/417 [Writing trailer]
10/25/18 21:31:23.004897 zmc_m3[2840].INF-zm_ffmpeg_camera.cpp/163 [Priming capture from rtsp://admin:1111@192.168.26.112/1]
10/25/18 21:31:23.031649 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/344 [Calling avformat_open_input for rtsp://admin:1111@192.168.26.112/1]
10/25/18 21:31:23.256783 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/376 [Opened input]
10/25/18 21:31:23.256872 zmc_m3[2840].INF-zm_ffmpeg_camera.cpp/378 [Stream open rtsp://admin:1111@192.168.26.112/1, parsing streams...]
10/25/18 21:31:26.436465 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/503 [Failed to find decoder (h264_mmal)]
10/25/18 21:31:26.436589 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/514 [Video Found decoder h264]
10/25/18 21:31:26.436617 zmc_m3[2840].DB1-zm_ffmpeg.cpp/267 [Dumping stream index i(1) index(0)]
10/25/18 21:31:26.436643 zmc_m3[2840].DB1-zm_ffmpeg.cpp/272 [    Stream #0:1]
10/25/18 21:31:26.436664 zmc_m3[2840].DB1-zm_ffmpeg.cpp/280 [, frames:28, timebase: 1/90000]
10/25/18 21:31:26.436709 zmc_m3[2840].DB1-zm_ffmpeg.cpp/282 [: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2560x1440]
10/25/18 21:31:26.436733 zmc_m3[2840].DB1-zm_ffmpeg.cpp/227 [18 fps, ]
10/25/18 21:31:26.436765 zmc_m3[2840].DB1-zm_ffmpeg.cpp/229 [90k stream tb numerator , ]
10/25/18 21:31:26.436815 zmc_m3[2840].DB1-zm_ffmpeg.cpp/227 [36 codec time base:]
10/25/18 21:31:26.436840 zmc_m3[2840].DB1-zm_ffmpeg.cpp/337 [
10/25/18 21:31:26.436861 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/521 [Calling avcodec_open2]
10/25/18 21:31:26.437094 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/544 [HWACCEL not in use]
10/25/18 21:31:26.437223 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/556 [Audio Found decoder]
10/25/18 21:31:26.437257 zmc_m3[2840].DB1-zm_ffmpeg.cpp/267 [Dumping stream index i(0) index(0)]
10/25/18 21:31:26.437279 zmc_m3[2840].DB1-zm_ffmpeg.cpp/272 [    Stream #0:0]
10/25/18 21:31:26.437300 zmc_m3[2840].DB1-zm_ffmpeg.cpp/280 [, frames:78, timebase: 1/8000]
10/25/18 21:31:26.437337 zmc_m3[2840].DB1-zm_ffmpeg.cpp/282 [: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s]
10/25/18 21:31:26.437359 zmc_m3[2840].DB1-zm_ffmpeg.cpp/337 [
10/25/18 21:31:26.437379 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/563 [Calling avcodec_open2]
10/25/18 21:31:26.437423 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/600 [Calling sws_isSupportedInput]
10/25/18 21:31:26.439835 zmc_m3[2840].INF-zm_videostore.cpp/54 [Opening video storage stream /media/cache-zm/events/3/2018-10-25/135128/135128-video.mp4 format: mp4]
10/25/18 21:31:26.492194 zmc_m3[2840].DB1-zm_ffmpeg.cpp/261 [Dumping codec_context codec_type(0) codec_id(28) width(2560) height(1440)  timebase(0/1) format(yuvj420p)]
10/25/18 21:31:26.492305 zmc_m3[2840].DB1-zm_ffmpeg.cpp/244 [Dumping codecpar codec_type(0) codec_id(28) codec_tag(828601953) width(2560) height(1440) bit_rate(0) format(12 = yuvj420p)]
10/25/18 21:31:26.496900 zmc_m3[2840].DB1-zm_ffmpeg.cpp/267 [Dumping stream index i(0) index(0)]
10/25/18 21:31:26.496961 zmc_m3[2840].DB1-zm_ffmpeg.cpp/272 [    Stream #0:0]
10/25/18 21:31:26.496971 zmc_m3[2840].DB1-zm_ffmpeg.cpp/280 [, frames:0, timebase: 1/90000]
10/25/18 21:31:26.496991 zmc_m3[2840].DB1-zm_ffmpeg.cpp/282 [: Unknown: none]
10/25/18 21:31:26.496999 zmc_m3[2840].DB1-zm_ffmpeg.cpp/337 [
10/25/18 21:31:26.740108 zmc_m3[2840].INF-zm_ffmpeg_camera.cpp/825 [Deleting videoStore instance]
10/25/18 21:31:26.759211 zmc_m3[2840].DB1-zm_videostore.cpp/414 [Flushing interleaved queues]
10/25/18 21:31:26.759306 zmc_m3[2840].DB1-zm_videostore.cpp/417 [Writing trailer]
10/25/18 21:31:26.918688 zmc_m3[2840].INF-zm_videostore.cpp/54 [Opening video storage stream /media/cache-zm/events/3/2018-10-25/135129/135129-video.mp4 format: mp4]
10/25/18 21:31:26.951384 zmc_m3[2840].DB1-zm_ffmpeg.cpp/261 [Dumping codec_context codec_type(0) codec_id(28) width(2560) height(1440)  timebase(0/1) format(yuvj420p)]
10/25/18 21:31:26.951465 zmc_m3[2840].DB1-zm_ffmpeg.cpp/244 [Dumping codecpar codec_type(0) codec_id(28) codec_tag(828601953) width(2560) height(1440) bit_rate(0) format(12 = yuvj420p)]
10/25/18 21:31:26.951571 zmc_m3[2840].DB1-zm_ffmpeg.cpp/267 [Dumping stream index i(0) index(0)]
10/25/18 21:31:26.951585 zmc_m3[2840].DB1-zm_ffmpeg.cpp/272 [    Stream #0:0]
10/25/18 21:31:26.951595 zmc_m3[2840].DB1-zm_ffmpeg.cpp/280 [, frames:0, timebase: 1/90000]
10/25/18 21:31:26.951612 zmc_m3[2840].DB1-zm_ffmpeg.cpp/282 [: Unknown: none]
10/25/18 21:31:26.951622 zmc_m3[2840].DB1-zm_ffmpeg.cpp/337 [
10/25/18 21:31:27.355872 zmc_m3[2840].DB1-zm_videostore.cpp/743 [duration calc: pts(68400) - last_pts( 57600) = (10800)]
Using UDP transport zmd don't restart but I get only partial frames and low fps.

LibVLC, UDP transport and X264 encode video writer work better but I lose some frames.
No problems watching stream from camera webpage in windows using ocx player.

Nocifer
Posts: 37
Joined: Mon Oct 01, 2018 4:05 pm

Re: ffmpeg stop

Post by Nocifer » Fri Oct 26, 2018 9:35 am

This is the second time I've seen this particular error reported ("zm_ffmpeg_camera.cpp/710 [Unable to read packet from stream 0: error -541478725 "End of file".]"). Everything points to ffmpeg, but whether it's something to do with ffmpeg itself, or how ZM utilizes ffmpeg to do its own thing, or even how the camera itself utilizes it to serve its video stream (read: what video codec it uses), I really wouldn't know. Seems though as if ZM is having trouble with the decoder:

Code: Select all

10/25/18 21:31:22.900824 zmc_m3[2840].INF-zm_ffmpeg_camera.cpp/710 [Unable to read packet from stream 0: error -541478725 "End of file".]

...

10/25/18 21:31:26.436465 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/503 [Failed to find decoder (h264_mmal)]
10/25/18 21:31:26.436589 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/514 [Video Found decoder h264]

...

10/25/18 21:31:26.436664 zmc_m3[2840].DB1-zm_ffmpeg.cpp/280 [, frames:28, timebase: 1/90000]
10/25/18 21:31:26.436709 zmc_m3[2840].DB1-zm_ffmpeg.cpp/282 [: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2560x1440]
10/25/18 21:31:26.436733 zmc_m3[2840].DB1-zm_ffmpeg.cpp/227 [18 fps, ]
10/25/18 21:31:26.436765 zmc_m3[2840].DB1-zm_ffmpeg.cpp/229 [90k stream tb numerator , ]
10/25/18 21:31:26.436815 zmc_m3[2840].DB1-zm_ffmpeg.cpp/227 [36 codec time base:]
10/25/18 21:31:26.436840 zmc_m3[2840].DB1-zm_ffmpeg.cpp/337 [
10/25/18 21:31:26.436861 zmc_m3[2840].DB1-zm_ffmpeg_camera.cpp/521 [Calling avcodec_open2]

...

10/25/18 21:31:26.492194 zmc_m3[2840].DB1-zm_ffmpeg.cpp/261 [Dumping codec_context codec_type(0) codec_id(28) width(2560) height(1440)  timebase(0/1) format(yuvj420p)]
10/25/18 21:31:26.492305 zmc_m3[2840].DB1-zm_ffmpeg.cpp/244 [Dumping codecpar codec_type(0) codec_id(28) codec_tag(828601953) width(2560) height(1440) bit_rate(0) format(12 = yuvj420p)]
What distro are you running ZM on?

EDIT: Scratch that, this is the third report (that I know of) with the exact same problem - "Failed to find decoder". What happens if you only change H264 Camera Passthrough to X264 Encode without changing anything else (i.e. use it with RTSP and ffmpeg, not UDP and libvlc)?

ZioTibia81
Posts: 6
Joined: Thu Oct 26, 2017 12:44 pm

Re: ffmpeg stop

Post by ZioTibia81 » Fri Oct 26, 2018 9:48 am

Hi!
I'm running ZM 1.32.2 (iconnor PPA) on Ubuntu 18.04.1 LTS

ZioTibia81
Posts: 6
Joined: Thu Oct 26, 2017 12:44 pm

Re: ffmpeg stop

Post by ZioTibia81 » Fri Oct 26, 2018 11:02 am

Another test using ffmpeg from commandline.
I get no errors. The strage thing is that:

stream is 18 fps, ffmpeg report 9 fps.
during this test ffmpeg take 1% of cpu, zmc 30%

Code: Select all

administrator@argo:/media/cache-zm/$ ffmpeg -i rtsp://admin:1111@192.168.26.112/1 -c copy -flags +global_header -an -f segment -segment_time 600 -segment_format_options movflags=+faststart -reset_timestamps 1 test%d.mp4
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 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
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packet
[rtsp @ 0x55806ae8ea00] RTP: missed 184 packets
[h264 @ 0x55806ae939a0] error while decoding MB 68 21, bytestream -6
[h264 @ 0x55806ae939a0] concealing 11021 DC, 11021 AC, 11021 MV errors in I frame
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packet
[rtsp @ 0x55806ae8ea00] RTP: missed 96 packets
[h264 @ 0x55806ae939a0] left block unavailable for requested intra mode
[h264 @ 0x55806ae939a0] error while decoding MB 0 24, bytestream 87669
[h264 @ 0x55806ae939a0] concealing 10609 DC, 10609 AC, 10609 MV errors in I frame
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, rtsp, from 'rtsp://admin:1111@192.168.26.112/1':
  Metadata:
    title           : SDP Descrption
    comment         : SDP Description
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
    Stream #0:1: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2560x1440, 18 fps, 18 tbr, 90k tbn, 36 tbc
[segment @ 0x55806aef2e80] Opening 'test0.mp4' for writing
Output #0, segment, to 'test%d.mp4':
  Metadata:
    title           : SDP Descrption
    comment         : SDP Description
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2560x1440, q=2-31, 18 fps, 18 tbr, 18432 tbn, 18 tbc
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[segment @ 0x55806aef2e80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x55806aef2e80] Non-monotonous DTS in output stream 0:0; previous: 1844293, current: 1844272; changing to 1844294. This may result in incorrect timestamps in the output file.
[mp4 @ 0x55806aef2240] Starting second pass: moving the moov atom to the beginning of the file
[segment @ 0x55806aef2e80] Opening 'test1.mp4' for writing
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=   1x
[rtsp @ 0x55806ae8ea00] RTP: missed 25 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packet
[rtsp @ 0x55806ae8ea00] RTP: missed 1160 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=1.01x
[rtsp @ 0x55806ae8ea00] RTP: missed 143 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=   1x
[rtsp @ 0x55806ae8ea00] RTP: missed 1 packets
[mp4 @ 0x55806aef2240] Starting second pass: moving the moov atom to the beginning of the file
frame= 5751 fps=9.0 q=-1.0 Lsize=N/A time=00:10:41.65 bitrate=N/A speed=   1x
video:389396kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

Nocifer
Posts: 37
Joined: Mon Oct 01, 2018 4:05 pm

Re: ffmpeg stop

Post by Nocifer » Fri Oct 26, 2018 11:25 am

So leaving everything else the same and changing H264 passthrough to X264 encoding worked, with only the fps count dropping? Then yes, it's a problem with ffmpeg and ZM's interaction with it, either due to a corner-case that is not properly handled within ZM (very possible, since writing directly to mp4 is a very recent and also very complicated feature) or due to some weird incompatibility with your camera's choice of codec (in theory very far-fetched, in practice... well, not that unusual, especially when we're talking about unnamed Chinese cameras :P).

Unfortunately, my knowledge about ffmpeg and its internal workings just about ends at this point. This will require a real ZM developer to look into it.

EDIT: Scratch the first line, I just realized you ran ffmpeg though the terminal. So yes, this seems like an issue that requires proper dev attention. By the way, the RTSP connection seems a bit messed up.

Code: Select all

[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=   1x
[rtsp @ 0x55806ae8ea00] RTP: missed 25 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packet
[rtsp @ 0x55806ae8ea00] RTP: missed 1160 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=1.01x
[rtsp @ 0x55806ae8ea00] RTP: missed 143 packets
[rtsp @ 0x55806ae8ea00] max delay reached. need to consume packetspeed=   1x
[rtsp @ 0x55806ae8ea00] RTP: missed 1 packets
That seems like one too many packets lost.

ZioTibia81
Posts: 6
Joined: Thu Oct 26, 2017 12:44 pm

Re: ffmpeg stop

Post by ZioTibia81 » Fri Oct 26, 2018 11:47 am

Hi,
leaving everything else the same and changing H264 passthrough to X264 I have the same problem: zmc stop unexpectedly.

I ran ffmpeg using terminal and there are no issues except low fps. I used ffmpeg option to create a new file every 600 seconds. RTP errors that you see are while ffmpeg is switching to the new file. During normal stream operations I have only these warn:

Code: Select all

[segment @ 0x55806aef2e80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[segment @ 0x55806aef2e80] Non-monotonous DTS in output stream 0:0; previous: 1844293, current: 1844272; changing to 1844294. This may result in incorrect timestamps in the output file.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests