I am creating a video from png images. Which I can do successfully!
My problem is that Im trying to add a blank audio track to it. I am trying
to do this because if I add the movie file into a video editor, it gives me
an error and will not open- something like invalid audio track or no audio
track available.
NOw I picked up the Quicktime for Java book and looked up audio tracks, and
found a decent example. But I cannot seem to get rid of the audio sound
entirely. Always at the very beginning of the video there is one
millisecond of high volumed static.
Here is what I am doing with the audio stuff... thanks for reading!
----------
//blank audio value - does this work right?
byte[] emptySound = new byte[44100*2];
for (int i=0; i<44100 * 2;i++){
emptySound[i] = (byte) 0x00;
}
...later...
//add audio track
Track trkSoundTrack = movMovie.addTrack(0,0,1);
Media medSoundMedia = new SoundMedia(trkSoundTrack,
movMovie.getTimeScale());//1);
medSoundMedia.beginEdits();
//build sound description
int format = QTUtils.toOSType("NONE");
SoundDescription sdSoundDesc = new SoundDescription(format);
sdSoundDesc.setNumberOfChannels(1);
sdSoundDesc.setSampleSize(16);
sdSoundDesc.setSampleRate(44100);
for (int i=1; i<= iTotalImages; i++) {
//add image to video track and...
//add audio to frame
QTHandle qthHandle = new QTHandle(emptySound);
medSoundMedia.setTimeScale(m_iFramesPerSecond);
medSoundMedia.addSample(qthHandle,
0,
qthHandle.getSize(),
1,
sdSoundDesc,
1, //44100,
sampleFlags);