ffmpeg/avconv에서 오디오 스트림을 기다리기 위해 명명된 파이프를 사용하지 마세요.

ffmpeg/avconv에서 오디오 스트림을 기다리기 위해 명명된 파이프를 사용하지 마세요.

audio_conv및 스트림 에 video대한 두 개의 명명된 파이프가 있습니다 . 즉시 형식으로 변환 하고 싶습니다 . 이러한 파이프의 데이터는 독점 형식을 구문 분석하고 오디오를 변환하는 내 애플리케이션에서 제공됩니다. 그러나 때때로 들어오는 스트림에 오디오가 없어서 초기화 단계에서 쉽게 확인할 수 없습니다. 오디오와 비디오를 모두 전달하면 괜찮지만 오디오가 없으면 해당 파이프가 비어 있고 내가 아는 한 ffmpeg는 비디오 변환을 중지하고 일부 오디오 데이터를 기다립니다.s16leh264webm

내가 사용한 명령은 다음과 같습니다.

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 -

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.

그 후 비디오 스트림이 ffmpeg로 전달되는 것을 볼 수 있지만 얼마 후 예기치 않게 중지됩니다. 그런 다음 killffmpeg 처리 후 다음을 출력합니다.

[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.

입력 데이터가 없으면 ffmpeg에 오디오를 건너뛰도록 지시하는 방법이 있습니까?

답변1

3초가 3,000,000인 마이크로초 단위의 적절한 값과 함께 -analyzeduration 3000000이전 옵션을 사용하세요 .-i

https://ffmpeg.org/ffprobe-all.html#Format-Options

analyzeduration integer (input)
    Specify how many microseconds are analyzed to probe the input. A higher value will enable detecting more accurate information, but will increase latency. It defaults to 5,000,000 microseconds = 5 seconds.

관련 정보