Não espere pelo fluxo de áudio com ffmpeg / avconv usando pipes nomeados

4

Eu tenho dois pipes nomeados, audio_conv e video , para s16le e h264 streams, respectivamente. Eu quero convertê-los para webm format on fly. Os dados para esses pipes são provenientes do meu aplicativo, que analisa o formato proprietário e converte o áudio. Mas às vezes não há áudio no fluxo de entrada, e não posso determiná-lo facilmente no estágio de inicialização. Quando eu passo áudio e vídeo, tudo bem, mas quando não há áudio, o canal correspondente está vazio e, como eu entendo, o ffmpeg para de converter vídeo e aguarda alguns dados de áudio.

Comando que uso:

ffmpeg -v debug -probesize 10000 -r 12 -analyzeduration 0 -vsync 0 -async 0 -i video -f s16le -ar 8000 -analyzeduration 0 -channel_layout mono -i audio_conv -f webm - | ffplay -

Do log ffmpeg:

Successfully parsed a group of options.
Opening an input file: video.
[h264 @ 0x23bf460] Format h264 probed with size=2048 and score=51   
[h264 @ 0x23bf460] Before avformat_find_stream_info() pos: 0 bytes read:2910 seeks:0
[h264 @ 0x23bf460] Probe buffer size limit of 10000 bytes reached
[h264 @ 0x23bf460] Stream #0: not enough frames to estimate rate; consider increasing probesize
[h264 @ 0x23bf460] decoding for stream 0 failed
[h264 @ 0x23bf460] After avformat_find_stream_info() pos: 15805 bytes read:17153 seeks:0 frames:1
Input #0, h264, from 'video':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/1200000: Video: h264 (Baseline), 1 reference frame, yuv420p(left), 704x576, 1/50, 25 tbr, 1200k tbn, 50 tbc
Successfully opened the file.
Parsing a group of options: input file audio_conv.
Applying option f (force format) with argument s16le.
Applying option ar (set audio sampling rate (in Hz)) with argument 8000.
Applying option channel_layout (set channel layout) with argument mono.
Successfully parsed a group of options.
Opening an input file: audio_conv.

Depois disso, posso ver que o fluxo de vídeo é passado para o ffmpeg, mas depois de algum tempo ele acidentalmente para. E então, depois de kill 'ffmpeg process, ele produz:

[s16le @ 0x16a8060] Before avformat_find_stream_info() pos: 0 bytes read:0 seeks:0
[s16le @ 0x16a8060] After avformat_find_stream_info() pos: 0 bytes read:0 seeks:0 frames:0
Input #1, s16le, from 'audio_conv':
  Duration: N/A, bitrate: 128 kb/s
    Stream #1:0, 0, 1/8000: Audio: pcm_s16le, 8000 Hz, mono, s16, 128 kb/s
Successfully opened the file.
Parsing a group of options: output file -.
Applying option f (force format) with argument webm.
Successfully parsed a group of options.
Opening an output file: -.
Successfully opened the file.
detected 4 logical cores  0 aq=    0KB vq=    0KB sq=    0B f=0/0   
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'video_size' to value '704x576'
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'time_base' to value '1/12'
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x16cf220] Setting 'frame_rate' to value '12/1'
[graph 0 input from stream 0:0 @ 0x16cf220] w:704 h:576 pixfmt:yuv420p tb:1/12 fr:12/1 sar:0/1 sws_param:flags=2
[force CFR for input from stream 0:0 @ 0x16a95a0] Setting 'expr' to value 'N'
[format @ 0x16a6160] compat: called with args=[yuv420p|yuv422p|yuv440p|yuv444p]
[format @ 0x16a6160] Setting 'pix_fmts' to value 'yuv420p|yuv422p|yuv440p|yuv444p'
[AVFilterGraph @ 0x16cc400] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[graph 0 input from stream 0:0 @ 0x16cf220] TB:0.083333 FRAME_RATE:12.000000 SAMPLE_RATE:nan
[graph 1 input from stream 1:0 @ 0x16aa8c0] Setting 'time_base' to value '1/8000'
[graph 1 input from stream 1:0 @ 0x16aa8c0] Setting 'sample_rate' to value '8000'
[graph 1 input from stream 1:0 @ 0x16aa8c0] Setting 'sample_fmt' to value 's16'
[graph 1 input from stream 1:0 @ 0x16aa8c0] Setting 'channel_layout' to value '0x4'
[graph 1 input from stream 1:0 @ 0x16aa8c0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[audio format for output stream 0:1 @ 0x16aa760] Setting 'sample_fmts' to value 's16|flt'
[audio format for output stream 0:1 @ 0x16aa760] Setting 'sample_rates' to value '48000|24000|16000|12000|8000'
[audio format for output stream 0:1 @ 0x16aa760] Setting 'channel_layouts' to value '0x4|0x3|0x7|0x33|0x37|0x3f|0x70f|0x63f'
[AVFilterGraph @ 0x16ab920] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
[libvpx-vp9 @ 0x16ce760] v1.5.0
[libvpx-vp9 @ 0x16ce760] --prefix=/usr --enable-pic --enable-shared --disable-install-bins --disable-install-srcs --size-limit=16384x16384 --enable-postproc --enable-multi-res-encoding --enable-temporal-denoising --enable-vp9-temporal-denoising --enable-vp9-postproc --target=x86_64-linux-gcc
[libvpx-vp9 @ 0x16ce760] vpx_codec_enc_cfg
[libvpx-vp9 @ 0x16ce760] generic settings
  g_usage:                      0
  g_threads:                    8
  g_profile:                    0
  g_w:                          320
  g_h:                          240
  g_bit_depth:                  8
  g_input_bit_depth:            8
  g_timebase:                   {1/30}
  g_error_resilient:            0
  g_pass:                       0
  g_lag_in_frames:              25
[libvpx-vp9 @ 0x16ce760] rate control settings
  rc_dropframe_thresh:          0
  rc_resize_allowed:            0
  rc_resize_up_thresh:          60
  rc_resize_down_thresh:        30
  rc_end_usage:                 0
  rc_twopass_stats_in:          (nil)(0)
  rc_target_bitrate:            256
[libvpx-vp9 @ 0x16ce760] quantizer settings
  rc_min_quantizer:             0
  rc_max_quantizer:             63
[libvpx-vp9 @ 0x16ce760] bitrate tolerance
  rc_undershoot_pct:            25
  rc_overshoot_pct:             25
[libvpx-vp9 @ 0x16ce760] decoder buffer model
  rc_buf_sz:                    6000
  rc_buf_initial_sz:            4000
  rc_buf_optimal_sz:            5000
[libvpx-vp9 @ 0x16ce760] 2 pass rate control settings
  rc_2pass_vbr_bias_pct:        50
  rc_2pass_vbr_minsection_pct:  0
  rc_2pass_vbr_maxsection_pct:  2000
[libvpx-vp9 @ 0x16ce760] keyframing settings
  kf_mode:                      1
  kf_min_dist:                  0
  kf_max_dist:                  9999
[libvpx-vp9 @ 0x16ce760] 
[libvpx-vp9 @ 0x16ce760] vpx_codec_enc_cfg
[libvpx-vp9 @ 0x16ce760] generic settings
  g_usage:                      0
  g_threads:                    0
  g_profile:                    0
  g_w:                          704
  g_h:                          576
  g_bit_depth:                  8
  g_input_bit_depth:            8
  g_timebase:                   {1/12}
  g_error_resilient:            0
  g_pass:                       0
  g_lag_in_frames:              25
[libvpx-vp9 @ 0x16ce760] rate control settings
  rc_dropframe_thresh:          0
  rc_resize_allowed:            0
  rc_resize_up_thresh:          60
  rc_resize_down_thresh:        30
  rc_end_usage:                 0
  rc_twopass_stats_in:          (nil)(0)
  rc_target_bitrate:            200
[libvpx-vp9 @ 0x16ce760] quantizer settings
  rc_min_quantizer:             0
  rc_max_quantizer:             63
[libvpx-vp9 @ 0x16ce760] bitrate tolerance
  rc_undershoot_pct:            25
  rc_overshoot_pct:             25
[libvpx-vp9 @ 0x16ce760] decoder buffer model
  rc_buf_sz:                    6000
  rc_buf_initial_sz:            4000
  rc_buf_optimal_sz:            5000
[libvpx-vp9 @ 0x16ce760] 2 pass rate control settings
  rc_2pass_vbr_bias_pct:        50
  rc_2pass_vbr_minsection_pct:  0
  rc_2pass_vbr_maxsection_pct:  2000
[libvpx-vp9 @ 0x16ce760] keyframing settings
  kf_mode:                      1
  kf_min_dist:                  0
  kf_max_dist:                  9999
[libvpx-vp9 @ 0x16ce760] 
[libvpx-vp9 @ 0x16ce760] vpx_codec_control
[libvpx-vp9 @ 0x16ce760]   VP8E_SET_CPUUSED:             1
[libvpx-vp9 @ 0x16ce760]   VP8E_SET_ARNR_MAXFRAMES:      0
[libvpx-vp9 @ 0x16ce760]   VP8E_SET_ARNR_STRENGTH:       3
[libvpx-vp9 @ 0x16ce760]   VP8E_SET_ARNR_TYPE:           3
[libvpx-vp9 @ 0x16ce760]   VP8E_SET_STATIC_THRESHOLD:    0
[libvpx-vp9 @ 0x16ce760]   VP9E_SET_COLOR_SPACE:         0
[libvpx-vp9 @ 0x16ce760] Using deadline: 1000000
[libopus @ 0x16cfda0] No bit rate set. Defaulting to 64000 bps.

Existe uma maneira de dizer ao ffmpeg para pular o áudio se não houver dados de entrada?

    
por FunkyCat 12.12.2016 / 07:32

0 respostas