音视频同步测试方法

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,属于正常范围

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
javacv是一个便于应用的开源计算机视觉Java工具包,它提供了许多实用的工具和方法,尤其是在音视频处理方面,具备很多独特的优势。但是,有时糟糕的声音和视频同步是很常见的问题。这是因为音频和视频是不同的数据类型,需要不同的处理方法。 造成声音和视频不同步的原因可能有很多,如硬件性能差、软件代码问题等。调整音频和视频同步方法非常简单,只需要尝试做以下几点: 1. 检查视频的帧率。视频的帧率与音频的采样率不同,因此需要检查视频帧率参数,确保其值适当。 2. 调整视频和音频的延迟参数。由于视频和音频的数据流在传递过程中可能存在延迟,所以需要使用相关的方法来调整延迟时间,以实现它们的同步。 3. 调整码率和格式。有时视频和音频在进行编码时可能存在不兼容的问题,因此需要更改编码码率和格式参数来配合视频和音频的输入和输出流。 4. 更新软件版本并进行适当的测试。有时视频和音频不同步的问题可能与软件版本相关,因此可以更新相应的软件版本,或者进行测试以更好地确定问题的根源。 综上所述,如果出现声音和视频不同步的问题,我们可以通过以上几种方法进行调整和解决。同时,对于javacv的应用,我们需要注意哪些参数和方法对于不同类型的视频和音频更有效,并正确定义它们的参数设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值