Problem extracting audio from a movie using DirectShow
Posted: Tue Jan 22, 2008 12:58 am
I am currently learning how to use DirectShow natively with PB. I have a project that requires the ability to extract audio from any movie played.
I have been using a trial version of GraphEdit Plus to test the graph, so I have no code to show the problem currently. I figured that I would test the graph first before I try to write the code in PB to make sure that my efforts were not wasted if it doesn't work in GraphEdit Plus.
I tried the supposed method shown on MSDN to build my test graph with very dissapointing results...
Procedure:
1 - I rendered an Mpeg file for test purposes in GraphEdit Plus
The rendered graph contained the following:
VIDEO filters with pin connections:
Testfile.mpeg--->MainConcept Mpeg Demultiplexer-->Mpeg Video Decoder-->Video Renderer
AUDIO filters with pin connections:
Testfile.mpeg--->MainConcept Mpeg Demultiplexer-->Mpeg Audio Decoder-->DirectSound(output)
2 - I edited the graph on the sound part in GraphEdit Plus
The edited portion of the graph now looks like this:
AUDIO filters with pin connections
Testfile.mpeg-->MainConcept Mpeg Demultiplexer-->Mpeg Audio Decoder-->WAV Dest2-->File Writer (test.wav)
GraphEdit Plus seemed to accept all the connections without fail.
According to MSDN, the file writer should write any data pass to it. In this case that data should be wave data. Am I wrong?? The graph appears to run showing the video with no audio which should be sent directly to my file called, "test.wav". This seems to be correct.
The problem arises when trying to open the newly created file in Windows Media Player. The time does not match the original length of the audio from the video file, and the test wave file appears to have no sound upon playback. I must be missing something obviously, but I'm not sure what it is.
I even tried connecting the Mpeg Demux directly to WAV Dest2 and then to the File Writer with no success. Can anyone point me in the right direction?
BTW, I just used an mpeg file for testing purposes, but wish to be able to do this with any supported file type supported by DirectShow such as avi, mpeg, mwv, divx, ect. I understand that the graph will be somewhat different for each, but the the sound file output will be the same (.wav).
I have been using a trial version of GraphEdit Plus to test the graph, so I have no code to show the problem currently. I figured that I would test the graph first before I try to write the code in PB to make sure that my efforts were not wasted if it doesn't work in GraphEdit Plus.
I tried the supposed method shown on MSDN to build my test graph with very dissapointing results...
Procedure:
1 - I rendered an Mpeg file for test purposes in GraphEdit Plus
The rendered graph contained the following:
VIDEO filters with pin connections:
Testfile.mpeg--->MainConcept Mpeg Demultiplexer-->Mpeg Video Decoder-->Video Renderer
AUDIO filters with pin connections:
Testfile.mpeg--->MainConcept Mpeg Demultiplexer-->Mpeg Audio Decoder-->DirectSound(output)
2 - I edited the graph on the sound part in GraphEdit Plus
The edited portion of the graph now looks like this:
AUDIO filters with pin connections
Testfile.mpeg-->MainConcept Mpeg Demultiplexer-->Mpeg Audio Decoder-->WAV Dest2-->File Writer (test.wav)
GraphEdit Plus seemed to accept all the connections without fail.
According to MSDN, the file writer should write any data pass to it. In this case that data should be wave data. Am I wrong?? The graph appears to run showing the video with no audio which should be sent directly to my file called, "test.wav". This seems to be correct.
The problem arises when trying to open the newly created file in Windows Media Player. The time does not match the original length of the audio from the video file, and the test wave file appears to have no sound upon playback. I must be missing something obviously, but I'm not sure what it is.
I even tried connecting the Mpeg Demux directly to WAV Dest2 and then to the File Writer with no success. Can anyone point me in the right direction?
BTW, I just used an mpeg file for testing purposes, but wish to be able to do this with any supported file type supported by DirectShow such as avi, mpeg, mwv, divx, ect. I understand that the graph will be somewhat different for each, but the the sound file output will be the same (.wav).