1.计算依据
延迟结果=图像出现时间-音频出现时间+客户端校验值(可正可负)
判断依据:一般延时结果在200ms内属于正常范围
2.获取视频信息
a.mediainfo
cd到视频文件的路径,然后在终端输入如下命令:
mediainfo a.mp4
输出结果:
- General
- Complete name : a.mp4
- Format : MPEG-4
- Format profile : Base Media
- Codec ID : isom (isom/iso2/avc1/mp41)
- File size : 13.1 MiB
- Duration : 19 s 947 ms
- Overall bit rate mode : Variable
- Overall bit rate : 5 491 kb/s
- Writing application : Lavf58.20.100
-
- Video
- ID : 1
- Format : AVC
- Format/Info : Advanced Video Codec
- Format profile : High@L4
- Format settings : CABAC / 4 Ref Frames
- Format settings, CABAC : Yes
- Format settings, Reference frames : 4 frames
- Codec ID : avc1
- Codec ID/Info : Advanced Video Coding
- Duration : 19 s 920 ms
- Bit rate : 5 490 kb/s
- Width : 1 920 pixels
- Height : 1 080 pixels
- Display aspect ratio : 16:9
- Frame rate mode : Constant
- Frame rate : 25.000 FPS
- Color space : YUV
- Chroma subsampling : 4:2:0
- Bit depth : 8 bits
- Scan type : Progressive
- Bits/(Pixel*Frame) : 0.106
- Stream size : 13.0 MiB (100%)
- Writing library : x264 core 155 r2917 0a84d98
- Encoding settings : 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=6 / 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=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
- Language : English
- Codec configuration box : avcC
-
- Audio
- ID : 2
- Format : AAC LC
- Format/Info : Advanced Audio Codec Low Complexity
- Codec ID : mp4a-40-2
- Duration : 19 s 947 ms
- Bit rate mode : Variable
- Bit rate : 2 277 b/s
- Maximum bit rate : 128 kb/s
- Channel(s) : 2 channels
- Channel layout : L R
- Sampling rate : 48.0 kHz
- Frame rate : 46.875 FPS (1024 SPF)
- Compression mode : Lossy
- Stream size : 5.54 KiB (0%)
- Language : English
- Default : Yes
- Alternate group : 1
从输出结果可以看到延迟结果=(19.920-19.947)*1000=27ms,属于正常范围
b.ffprobe
cd到视频文件的路径,然后在终端输入如下命令:
ffprobe -v quiet -print_format json -show_format -show_streams -show_error -show_chapters a.mp4
- {
- "streams": [
- {
- "index": 0,
- "codec_name": "h264",
- "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
- "profile": "High",
- "codec_type": "video",
- "codec_tag_string": "avc1",
- "codec_tag": "0x31637661",
- "width": 1920,
- "height": 1080,
- "coded_width": 1920,
- "coded_height": 1080,
- "closed_captions": 0,
- "film_grain": 0,
- "has_b_frames": 2,
- "pix_fmt": "yuv420p",
- "level": 40,
- "chroma_location": "left",
- "field_order": "progressive",
- "refs": 1,
- "is_avc": "true",
- "nal_length_size": "4",
- "id": "0x1",
- "r_frame_rate": "25/1",
- "avg_frame_rate": "25/1",
- "time_base": "1/12800",
- "start_pts": 0,
- "start_time": "0.000000",
- "duration_ts": 254976,
- "duration": "19.920000",
- "bit_rate": "5489806",
- "bits_per_raw_sample": "8",
- "nb_frames": "498",
- "extradata_size": 43,
- "disposition": {
- "default": 1,
- "dub": 0,
- "original": 0,
- "comment": 0,
- "lyrics": 0,
- "karaoke": 0,
- "forced": 0,
- "hearing_impaired": 0,
- "visual_impaired": 0,
- "clean_effects": 0,
- "attached_pic": 0,
- "timed_thumbnails": 0,
- "captions": 0,
- "descriptions": 0,
- "metadata": 0,
- "dependent": 0,
- "still_image": 0
- },
- "tags": {
- "language": "eng",
- "handler_name": "\u001fMainconcept Video Media Handler",
- "vendor_id": "[0][0][0][0]"
- }
- },
- {
- "index": 1,
- "codec_name": "aac",
- "codec_long_name": "AAC (Advanced Audio Coding)",
- "profile": "LC",
- "codec_type": "audio",
- "codec_tag_string": "mp4a",
- "codec_tag": "0x6134706d",
- "sample_fmt": "fltp",
- "sample_rate": "48000",
- "channels": 2,
- "channel_layout": "stereo",
- "bits_per_sample": 0,
- "id": "0x2",
- "r_frame_rate": "0/0",
- "avg_frame_rate": "0/0",
- "time_base": "1/48000",
- "start_pts": 0,
- "start_time": "0.000000",
- "duration_ts": 956400,
- "duration": "19.925000",
- "bit_rate": "2277",
- "nb_frames": "935",
- "extradata_size": 5,
- "disposition": {
- "default": 1,
- "dub": 0,
- "original": 0,
- "comment": 0,
- "lyrics": 0,
- "karaoke": 0,
- "forced": 0,
- "hearing_impaired": 0,
- "visual_impaired": 0,
- "clean_effects": 0,
- "attached_pic": 0,
- "timed_thumbnails": 0,
- "captions": 0,
- "descriptions": 0,
- "metadata": 0,
- "dependent": 0,
- "still_image": 0
- },
- "tags": {
- "language": "eng",
- "handler_name": "#Mainconcept MP4 Sound Media Handler",
- "vendor_id": "[0][0][0][0]"
- }
- }
- ],
- "chapters": [
-
- ],
- "format": {
- "filename": "a.mp4",
- "nb_streams": 2,
- "nb_programs": 0,
- "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
- "format_long_name": "QuickTime / MOV",
- "start_time": "0.000000",
- "duration": "19.947000",
- "size": "13691488",
- "bit_rate": "5491146",
- "probe_score": 100,
- "tags": {
- "major_brand": "isom",
- "minor_version": "512",
- "compatible_brands": "isomiso2avc1mp41",
- "encoder": "Lavf58.20.100"
- }
- }
- }
从输出结果依然可以看到延迟结果=(19.920-19.947)*1000=27ms,属于正常范围