die 2 de 3 gravações ffmpeg (freebsd)

0

Eu preciso escrever 1h de captura do udp para o fluxo de HTTP para o arquivo de alguns fluxos todos os streams escrevem para um disco rígido, RAM 8Gb

script bash:

#!/bin/sh
ffmpeg -y -i http://192.168.1.36:7781/udp/232.0.3.12:1234  -c:a copy -ab 320k -loglevel verbose  -vcodec libx264 -vf scale=320:240  -b 400k -t 3620 /data/A/stageA-$(date +"%H-day-%d").mkv

Mas depois de 2-5 minutos, 2 dos 3 processos morrem.

Nenhum dado de log gerado ou não consigo encontrá-lo quando uso >> logfile criou arquivo de tamanho zero.

Começa assim:

ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
  configuration: --prefix=/usr/local --mandir=/usr/local/man --datadir=/usr/local/share/ffmpeg --pkgconfigdir=/usr/local/libdata/pkgconfig --enable-shared --enable-pic --enable-gpl --enable-postproc --enable-avfilter --enable-avresample --enable-pthreads --cc=cc --disable-alsa --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libass --disable-libbs2b --disable-libcaca --disable-libcdio --disable-libcelt --disable-chromaprint --disable-libdc1394 --disable-debug --disable-htmlpages --disable-libdrm --disable-libfdk-aac --enable-ffserver --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --disable-libfribidi --disable-libgme --disable-libgsm --enable-iconv --disable-libilbc --disable-jack --disable-libkvazaar --disable-ladspa --disable-libmp3lame --disable-libbluray --disable-librsvg --disable-libxml2 --enable-mmx --disable-libmodplug --disable-openal --disable-opencl --enable-libopencv --disable-opengl --disable-libopenh264 --disable-libopenjpeg --enable-optimizations --disable-libopus --disable-libpulse --enable-runtime-cpudetect --disable-librubberband --disable-sdl2 --enable-libsmbclient --disable-libsnappy --disable-sndio --disable-libsoxr --disable-libspeex --enable-sse --disable-libssh --disable-libtesseract --enable-libtheora --disable-libtwolame --enable-libv4l2 --enable-vaapi --enable-vdpau --disable-libvidstab --enable-libvorbis --disable-libvo-amrwbenc --enable-libvpx --disable-libwavpack --disable-libwebp --enable-libx264 --enable-libx265 --disable-libxcb --enable-libxvid --disable-outdev=xv --disable-libzimg --disable-libzmq --disable-libzvbi --disable-gcrypt --enable-gmp --disable-librtmp --enable-gnutls --disable-openssl --enable-version3 --disable-nonfree --disable-libmysofa
  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

O qual começa a capturar com sucesso, mas , depois de algum tempo todos os processos morrem (exceto um) com a mensagem do console:

[mpegts @ 0x81744f000] max_analyze_duration 5000000 reached at 5016000 microseconds st:1
Input #0, mpegts, from 'http://192.168.1.36:7781/udp/232.0.3.12:1234':
  Duration: N/A, start: 69081.872900, bitrate: 3692 kb/s
  Program 2088
    Metadata:
      service_name    : ?stageA SD
      service_provider: ?DVB
    Stream #0:0[0x23]: Video: mpeg2video (Main), 1 reference frame ([2][0][0][0] / 0x0002), yuv420p(tv, top first, left), 720x576 [SAR 64:45 DAR 16:9], 3500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x24]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
Please use -b:a or -b:v, -b is ambiguous
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[Parsed_scale_0 @ 0x81743e920] w:320 h:240 flags:'bicubic' interl:0
[graph 0 input from stream 0:0 @ 0x81743e9c0] w:720 h:576 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
[Parsed_scale_0 @ 0x81743e920] w:720 h:576 fmt:yuv420p sar:64/45 -> w:320 h:240 fmt:yuv420p sar:4/3 flags:0x4
[libx264 @ 0x817418d00] using SAR=4/3
[libx264 @ 0x817418d00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x817418d00] profile High, level 1.3
[libx264 @ 0x817418d00] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to '/data/A/stageA-10-1-day-27.mkv':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264), 1 reference frame (H264 / 0x34363248), yuv420p(left), 320x240 [SAR 4:3 DAR 16:9], q=-1--1, 400 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/400000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 320 kb/s

    [http @ 0x81743e240] Stream ends prematurely at 141887172, should be 18446744073709551615.02x


    [mpegts @ 0x81744f000] PES packet size mismatch
    [mpeg2video @ 0x817417900] invalid cbp -1 at 15 10
    [mpeg2video @ 0x817417900] Warning MVs not available
    [mpeg2video @ 0x817417900] concealing 1170 DC, 1170 AC, 1170 MV errors in P frame
    http://192.168.1.36:7781/udp/232.0.3.12:1234: Input/output error


    No more output streams to write to, finishing.
    frame= 6304 fps= 25 q=24.0 Lsize=   19010kB time=00:04:12.48 bitrate= 616.8kbits/s speed=   1x
    video:12980kB audio:5912kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.627106%
    Input file #0 (http://192.168.1.36:7781/udp/232.0.3.12:1234:
      Input stream #0:0 (video): 6304 packets read (109239851 bytes); 6304 frames decoded;
      Input stream #0:1 (audio): 10511 packets read (6053930 bytes);
      Total: 16815 packets (115293781 bytes) demuxed
    Output file #0 (/data/A/stageA-10-1-day-27.mkv):
      Output stream #0:0 (video): 6304 frames encoded; 6304 packets muxed (13291122 bytes);
      Output stream #0:1 (audio): 10511 packets muxed (6053930 bytes);
      Total: 16815 packets (19345052 bytes) muxed
    [libx264 @ 0x817418d00] frame I:45    Avg QP:16.15  size: 17155
    [libx264 @ 0x817418d00] frame P:1685  Avg QP:18.85  size:  4913
    [libx264 @ 0x817418d00] frame B:4574  Avg QP:22.07  size:   927
    [libx264 @ 0x817418d00] consecutive B-frames:  2.1%  2.2%  3.5% 92.1%
    [libx264 @ 0x817418d00] mb I  I16..4:  4.6% 59.8% 35.6%
    [libx264 @ 0x817418d00] mb P  I16..4:  0.6%  5.7%  2.4%  P16..4: 34.7% 31.7% 20.5%  0.0%  0.0%    skip: 4.4%
    [libx264 @ 0x817418d00] mb B  I16..4:  0.1%  0.3%  0.2%  B16..8: 44.5%  9.7%  2.6%  direct: 3.5%  skip:39.2%  L0:37.5% L1:45.5% BI:17.0%
    [libx264 @ 0x817418d00] final ratefactor: 18.42
    [libx264 @ 0x817418d00] 8x8 transform intra:63.3% inter:65.0%
    [libx264 @ 0x817418d00] coded y,uvDC,uvAC intra: 89.4% 92.5% 77.6% inter: 27.4% 27.8% 6.0%
    [libx264 @ 0x817418d00] i16 v,h,dc,p: 33% 25%  4% 38%
    [libx264 @ 0x817418d00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 19% 12%  5%  8% 10%  8%  9%  8%
    [libx264 @ 0x817418d00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 20% 10%  6%  9% 10%  8%  8%  7%
    [libx264 @ 0x817418d00] i8c dc,h,v,p: 48% 18% 24% 10%
    [libx264 @ 0x817418d00] Weighted P-Frames: Y:5.9% UV:1.5%
    [libx264 @ 0x817418d00] ref P L0: 54.2% 19.5% 17.9%  7.9%  0.5%
    [libx264 @ 0x817418d00] ref B L0: 88.3%  9.2%  2.4%
    [libx264 @ 0x817418d00] ref B L1: 94.4%  5.6%
    [libx264 @ 0x817418d00] kb/s:421.38

Alguém pode aconselhar o que estou fazendo de errado aqui ou sugerir o que eu posso tentar resolver?

    
por Andrii 27.09.2018 / 09:51

1 resposta

0

Com as mensagens de erro

[http @ 0x81743e240] Stream ends prematurely (…)

e

http://192.168.1.36:7781/udp/232.0.3.12:1234: Input/output error

parece óbvio que a rede ou servidor não é confiável.

Você pode dizer a ffmpeg para continuar tentando, ajustando seu comando dessa maneira (com base no link ):

ffmpeg -y -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 1 -i http://192.168.1.36:7781/udp/232.0.3.12:1234 -c:a copy -loglevel verbose -c:v libx264 -vf scale=320:240 -crf 23 -t 3620 /data/A/stageA-$(date +"%H-day-%d").mkv

Ou, como seu fluxo de entrada é um fluxo de transporte MPEG, sugiro transferir os dados com uma ferramenta especializada para essa tarefa e depois converter o vídeo em uma segunda etapa. Para a transferência, wget e curl vêm à mente. Você pode tentar algo como

wget --tries=999 -O stream.ts http://192.168.1.36:7781/udp/232.0.3.12:1234

ou

while sleep 1
do
    curl -sS http://192.168.1.36:7781/udp/232.0.3.12:1234 >> stream.ts
done

(com base no link , link e link ).

    
por 27.09.2018 / 10:27