0

I creating an video file by encoding BufferedImages. How I can add Audio to this video from mp3 file?

IMediaWriter movie = ToolFactory.makeWriter("somefile.mp4");                
movie.addVideoStream(0, 0, ICodec.ID.CODEC_ID_H264, 720, 540);
movie.encodeVideo(0,img, time, TimeUnit.MILLISECONDS);   
movie.close();

When I try concatenate class I get this error:

45694 [Thread-2] WARN com.xuggle.xuggler - Got error: picture is not of the same PixelType as this Coder expected (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1430)
goodm
  • 7,275
  • 6
  • 31
  • 55

1 Answers1

2

Use the example at xuggle

writer.addAudioStream(audioStreamIndex, audioStreamId, channelCount,
      sampleRate);
Puspendu Banerjee
  • 2,631
  • 16
  • 19
  • @goodm Have you gone through the sample at http://code.google.com/p/xuggle/source/browse/trunk/java/xuggle-xuggler/src/com/xuggle/mediatool/demos/ConcatenateAudioAndVideo.java?r=929 – Puspendu Banerjee Jul 18 '12 at 22:21
  • 1
    there is example how to connect two files, I want to create video and during this process add audio. Not load again saved video. – goodm Jul 18 '12 at 22:25
  • @goodm What image type you are using? please pass the code, where you are populating the image[img variable in the snippet]. If you are using BufferedImage then, create the BufferedImage with BufferedImage.TYPE_3BYTE_BGR instead of BufferedImage.TYPE_INT_RGB – Puspendu Banerjee Jul 19 '12 at 13:01
  • I manage to add mp3 file to the video, I'm working right now with how to crop the mp3. – goodm Jul 19 '12 at 13:19
  • grt! If you feel that the whole conversation has helped you, mark it as correct answer. – Puspendu Banerjee Jul 19 '12 at 13:22