使用DirectShow.NET的音频同步问题 [英] Audio Sync problems using DirectShow.NET

查看:74
本文介绍了使用DirectShow.NET的音频同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在DirectShow.NET的论坛上对此进行了讨论,这是链接 http://sourceforge.net/projects/directshownet/forums/forum/460697/topic/5194414/index/page/1
,但不幸的是,问题仍然存在...



我有一个应用程序,可以从网络摄像头捕获视频,并从麦克风捕获音频,并将其保存到文件中,出于某种原因,音频和视频永远都不会进入-sync,我尝试了以下操作:
1.从ffdshow编码器开始,更改为AVI Mux-问题仍然存在,音频被延迟,在视频结尾处,图片保持冻结状态,音频继续
2 。从AVI Mux更改为WM ASF Writer-视频在开始时冻结(2秒),其余视频处于同步状态(但前两个秒不可用)
3.创建打印时间戳的SampleGrabber对于音频和视频-看到音频时间放大器是早于500毫秒,但我不知道该怎么办...
4.尝试将ReferenceClock手动设置为捕获过滤器之一(音频/视频),但都不会转换为IReferenceClock
5.创建一个SystemClock并将其设置为ReferenceClock-没有区别
6.在grap上设置SyncUsingStreamOffset(true)-现在时间戳更接近了,但最终结果是相同的
7。尝试将音频和视频保存到两个不同的文件中,并使用VirtualDub来查看它们是否匹配,但是它们仍然不...



哦,我忘了提我也尝试过构建GraphEditPlus中的图形,但问题仍然存在,这里是该图形的链接: http ://www2.picturepush.com/photo/a/8030745/img/8030745.png



当前,我正在测试CapWMV示例的所有更改



请提供任何建议,我无可救药:/



谢谢





更新:



如果我使用virtualDub通过以下方式延迟音频,音频和视频之间似乎存在一个恒定的500ms间隔500ms看起来不错,如何在图形中设置呢?

解决方案

只是想为我的情况添加解决方案,也许是



我试图将网络摄像头的视频与麦克风的音频一起录制,视频为高清(1080p),所以我想保存一个AVI文件编码在MPEG4中,因此我将ffshow-tryous(免费的Mpeg4编码器)与Avi Mux滤镜一起使用,问题是我的某些视频(大部分(:))出现同步问题。



我发现Avi Mux不处理同步,它假定数据在适当的时间到达(写在这里- http://msdn.micros oft.com/en-us/library/dd407208(v=vs.85).aspx ),所以我尝试使用WMAsfWriter来处理同步,并且工作正常(上面提到的2秒冻结只是一个VLC Player出现故障),但在高分辨率下无法正常工作,我无法在自定义配置文件中使用它(滤镜无法连接)。



尝试了Roman的建议,尽管链接非常有趣且很有前途(我真的建议阅读它们-尚不能给帖子+1 ...)它只是没有任何区别:/



我的最终解决方案是放弃MPEG4,而只使用MPEG2,我从Avi Mux切换到了Microsoft MPEG2编码器,效果很好,应该早就考虑了:)



希望这会对其他人有所帮助。



谢谢



伊朗


I have started a thread on this at DirectShow.NET's forum, here is the link http://sourceforge.net/projects/directshownet/forums/forum/460697/topic/5194414/index/page/1 but unfortunately the problem still persists...

I have an application that captures video from a webcam and audio from the microphone and save it to a file, for some reason the audio and video are never in-sync, i tried the following: 1. Started with ffdshow encoder and changed to AVI Mux - problem persists, audio is delayed and at the end of the video the picture remains frozen and the audio continues 2. Changed from AVI Mux to WM ASF Writer - video is frozen at the beginning (2 seconds) and rest of video is in-sync (but the two first seconds are not usable) 3. create SampleGrabber that prints the timestamp for both audio and video - saw that the audio timestamp is 500ms earlier but I have no idea what to do with this fact... 4. tried manually setting the ReferenceClock to one of the capture filters (audio/video) but both won't cast to IReferenceClock 5. Created a SystemClock and set it has the ReferenceClock - made no difference 6. Set SyncUsingStreamOffset(true) on the grap - timestamps are much closer now but the final result is the same 7. Tried saving the audio and video to two different files and used VirtualDub to see if they match, they still dont...

Oh i forgot to mention I also tried building the graph in GraphEditPlus but the problem still remains, here's a link to the graph: http://www2.picturepush.com/photo/a/8030745/img/8030745.png

Currently I am testing all my changes on the CapWMV sample from DirectShow.NET's samples.

Please any advice would be highly appreciated, I am hopeless :/

Thanks,

Eran.

Update:

It seems there's a constant 500ms gap between the audio and video, if I use virtualDub to delay the audio by 500ms it looks fine, how can set this in the graph?

解决方案

Just wanted to add the solution for my situation, maybe it will help someone.

I was trying to record video from a webcam together with audio from a microphone, video is HD (1080p) so I wanted to save an AVI file encoded in MPEG4, so I used ffshow-tryous (free Mpeg4 encoder) together with an Avi Mux Filter, the problem was that some (well most of them :) ) of my videos had sync issues.

What I discovered was that Avi Mux does not handle synchronization, it assumes the data arrives at the appropriate time (written here - http://msdn.microsoft.com/en-us/library/dd407208(v=vs.85).aspx), so I tried using WMAsfWriter which does handle synchronization and it worked fine (The 2 seconds freeze I mentioned above was just a glitch with VLC Player) but it doesn't work good with high resolutions and I had trouble using it with custom profiles (filters won't get connected).

I also tried Roman's suggestion and although the links were very interesting and promising (I really recommend reading them - can't give +1 to a post yet...) it just didn't made any difference :/

My final solution was to give up on MPEG4 and just use MPEG2, I switched from Avi Mux to Microsoft MPEG2 Encoder which works great, should have thought about that long time ago :)

Hopefully this will help someone else.

Thanks,

Eran.

这篇关于使用DirectShow.NET的音频同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆