开发者

Generating silent audio track

开发者 https://www.devze.com 2023-03-13 17:38 出处:网络
I\'m using a simple DirectShow graph to convert some videos to WMV format, which is working fine. I\'m now trying to use a filter based on the Synth Filter sample to supply a silent audio track to the

I'm using a simple DirectShow graph to convert some videos to WMV format, which is working fine. I'm now trying to use a filter based on the Synth Filter sample to supply a silent audio track to the videos and I'm running into some problems.

Essentially, I don't know how to stop the graph when this filter (the synth filter) is connected. I guess because it just provides samples forever until somebody tells it to stop, the usual approach of calling IMediaEvent::WaitForCompletion on the filter graph doesn't work (the graph never stops). What I want it to do of course is stop as soon as the video source filter is finished.

I've tried tracking the position of the graph with IMediaSeeking::GetPositions and then manually stopping the graph when this exceeds the duration of the source file, but the accuracy of the stop time with this approach isn't great.

Can anyone think of a better way to do this? Do I need to have another filter that monitors the output from the video source and also has a 开发者_StackOverflow中文版pointer to the audio source so it can stop it as soon as the video source delivers EndOfStream? Is there no way to accomplish this from purely application-side code?


I've done something not too different myself in the past. I added support for IMediaSeeking to the silence generator filter, and then you need to make sure that you set start and stop times for the conversion (even if it's just 0 and duration), so that the silence generator can generate the right amount of audio and then send EOS.

G

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号