avformat_write_header -22

av_dump_format

输出以下信息

Input #0, rtsp, from 'rtsp://admin:[email protected]/media/video':
  Metadata:
    title           : VCP IPC Realtime stream
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
    Stream #0:2: Data: none
Output #0, mp4, to 'aaa.mp4':
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, q=2-31
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

注意音频流信息:pcm_alaw
如果输出文件 MP4 由于不支持pcm_alaw音频格式就会报
avformat_write_header 的时候
-22
错误
需要吧摄像头音频流改成acc
以下为正确

Input #0, rtsp, from 'rtsp://admin:[email protected]/media/video':
  Metadata:
    title           : VCP IPC Realtime stream
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
    Stream #0:2: Data: none
Output #0, mp4, to 'aaa.mp4':
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, q=2-31
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp

你可能感兴趣的:(avformat_write_header -22)