简体   繁体   English

Android录制和结果有音频视频同步问题

[英]Android Recording and the result has Audio Video sync issue

I am trying to solve a A/V sync problem. 我正在尝试解决A / V同步问题。 The Video will got 1 sec delay than Audio. 视频将比音频延迟1秒。 (See my note below please) (请参阅下面的注释)

From Android Media Framework part, Could I just delay the audio timestamp to let it sync with video, where should i start? 从Android Media Framework部分,我可以延迟音频时间戳让它与视频同步,我应该从哪里开始? Is it AudioSource? 是AudioSource吗? MPEG4Writer? MPEG4Writer? MediaCodecSource? MediaCodecSource?

Please help!! 请帮忙!!

[The Case is]: If there is a 5 sec video. [案例是]:如果有5秒的视频。 The current situation: 目前的情况:

Video part on 0-1 sec will freeze, 1-5 sec stays normal. 0-1秒的视频部分将冻结,1-5秒保持正常。 The video frame starts from 1.00s is actually frame from the 0.00s. 视频帧从1.00开始实际上是0.00s的帧。

Audio part stays normal in whole scene. 音频部分在整个场景中保持正常。 So Video part will be 1 sec delay with Audio part. 因此视频部分将与音频部分延迟1秒。

Video part on 1.00s actually match with Audio part on 0.00s. 1.00s上的视频部分实际上与0.00s的音频部分匹配。

[Failed Try] [尝试失败]

I try if I just move the StartTimeUs on Video Part on MPEG4Writer, the A/V will sync, but in the end on file, there will be 1.00s with Video freeze, and normal audio. 我尝试如果我只是在MPEG4Writer上的视频部件上移动StartTimeUs,A / V将同步,但在文件的最后,将有1.00s的视频冻结和普通音频。

[MyThought] [我的想法]

If I can pause Audio 1 sec, which will move Audio 0.00s to 1.00s, it will sync. 如果我可以暂停音频1秒,这将音频0.00s移动到1.00秒,它将同步。 But I don't know the code i can change for this method. 但我不知道我可以为这种方法改变的代码。 Please help! 请帮忙!

我的笔记

I am starting with the assumption that you are using a MediaCodec encoder and feeding the output into an MediaMuxer to produce a video file. 我开始假设您正在使用MediaCodec编码器并将输出馈送到MediaMuxer以生成视频文件。

It sounds like this might be related to a similar issue I faced in this question . 听起来这可能与我在这个问题中遇到的类似问题有关 I believe that an audio MediaCodec encoder will essentially ignore any timestamps you throw at it; 我相信音频MediaCodec编码器基本上会忽略你抛出的任何时间戳; so I don't think that changing the audio timestamps will solve your problem. 所以我认为改变音频时间戳不会解决你的问题。 However, it sounds like you could solve the problem by correcting the video frame timestamps to be at an earlier time (as synchronized with the audio) after the frame leaves the encoder but before it reaches the muxer. 但是,听起来你可以通过在帧离开编码器之后但在它到达复用器之前将视频帧时间戳更正为更早的时间(与音频同步)来解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM