I'm trying to perform a/v recording. The video capture works fine, but if I add the audio the video freezes immediately after start. Here the sample code:
try {
Video<MBFImage> video = new VideoCapture(320, 240);
JavaSoundAudioGrabber audio = new JavaSoundAudioGrabber(new AudioFormat(16, 44.1, 2));
VideoDisplay<MBFImage> display = VideoDisplay.createVideoDisplay(video, audio);
}
catch (VideoCaptureException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I've started to debug the audio part and found out that the AudioPlayer exits immediately after start. The reason is that the isStopped() state of JavaSoundAudioGrabber will be set to false only in its run() method, which unfortunately is not called from the AudioPlayer. As far as I understand this causes the video thread to sleep forever as it assumes it is out of sync with the audio stream.
Because I'm completely new to openIMAJ could you please advise me if this is the right way to accomplish my task or am I doing something completely wrong? I couldn't find any such example so far, but may be I've missed something...
Any help will be highly appreciated.
TIA,
Ilko
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have to manually start the grabber in a new thread to use it:
new Thread(audio).start();
(before the VideoDisplay is created). However, looking at the code of the grabber, it appears that this still won't currently work as the time codes of the audio samples are not being correctly set. I'll have to have a deeper look and try and understand what's going on...
Last edit: Jonathon Hare 2015-03-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to perform a/v recording. The video capture works fine, but if I add the audio the video freezes immediately after start. Here the sample code:
I've started to debug the audio part and found out that the AudioPlayer exits immediately after start. The reason is that the isStopped() state of JavaSoundAudioGrabber will be set to false only in its run() method, which unfortunately is not called from the AudioPlayer. As far as I understand this causes the video thread to sleep forever as it assumes it is out of sync with the audio stream.
Because I'm completely new to openIMAJ could you please advise me if this is the right way to accomplish my task or am I doing something completely wrong? I couldn't find any such example so far, but may be I've missed something...
Any help will be highly appreciated.
TIA,
Ilko
You have to manually start the grabber in a new thread to use it:
(before the
VideoDisplay
is created). However, looking at the code of the grabber, it appears that this still won't currently work as the time codes of the audio samples are not being correctly set. I'll have to have a deeper look and try and understand what's going on...Last edit: Jonathon Hare 2015-03-30