private int VIDEO_WIDTH = 712;
private int VIDEO_HEIGHT = 429;
private IMediaWriter writer;
private IMediaReader reader;
private File outputFile;
public ConvertVideo(File inputFile, File outputFile) {
System.out.println("inside ConvertVideo");
this.outputFile = outputFile;
reader = ToolFactory.makeReader(inputFile.getAbsolutePath());
reader.addListener(this);
}
private IVideoResampler videoResampler = null;
private IAudioResampler audioResampler = null;
@Override
public void onAddStream(IAddStreamEvent event) {
int streamIndex = event.getStreamIndex();
IStreamCoder streamCoder = event.getSource().getContainer().getStream(streamIndex).getStreamCoder();
if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
writer.addAudioStream(streamIndex, streamIndex, 2, 44100);
} else if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
streamCoder.setWidth(VIDEO_WIDTH);
streamCoder.setHeight(VIDEO_HEIGHT);
writer.addVideoStream(streamIndex, streamIndex, VIDEO_WIDTH, VIDEO_HEIGHT);
}
super.onAddStream(event);
}
@Override
public void onVideoPicture(IVideoPictureEvent event) {
IVideoPicture pic = event.getPicture();
if (videoResampler == null) {
videoResampler = IVideoResampler.make(VIDEO_WIDTH, VIDEO_HEIGHT,
pic.getPixelType(), pic.getWidth(), pic.getHeight(),
pic.getPixelType());
}
IVideoPicture out = IVideoPicture.make(pic.getPixelType(), VIDEO_WIDTH,
VIDEO_HEIGHT);
videoResampler.resample(out, pic);
IVideoPictureEvent asc = new VideoPictureEvent(event.getSource(), out,
event.getStreamIndex());
super.onVideoPicture(asc);
out.delete();
}
@Override
public void onAudioSamples(IAudioSamplesEvent event) {
IAudioSamples samples = event.getAudioSamples();
if (audioResampler == null) {
audioResampler = IAudioResampler.make(2, samples.getChannels(),
44100, samples.getSampleRate());
}
if (event.getAudioSamples().getNumSamples() > 0) {
IAudioSamples out = IAudioSamples.make(samples.getNumSamples(),
samples.getChannels());
audioResampler.resample(out, samples, samples.getNumSamples());
AudioSamplesEvent asc = new AudioSamplesEvent(event.getSource(),
out, event.getStreamIndex());
super.onAudioSamples(asc);
out.delete();
}
}
@Override
public void run() {
writer = ToolFactory.makeWriter(outputFile.getAbsolutePath(), reader);
this.addListener(writer);
while (reader.readPacket() == null) {
}
}
public static void main(String[] args) {
try {
File file = new File("D:\\sample.mp4");
file.createNewFile();
ConvertVideo obj = new ConvertVideo(new File("D:\\Kids25.avi"),file);
obj.run();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Error is Given to me is :
nside ConvertVideo
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Net-BeanProjects/Zoopem/web/WEB-INF/lib/logback-classic.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Net-BeanProjects/Zoopem/web/WEB-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
2013-07-17 15:44:35,426 [main] ERROR org.ffmpeg - [msmpeg4 @ 0x23f1a0] ext header missing, 16 left
2013-07-17 15:44:36,364 [main] ERROR org.ffmpeg - [msmpeg4 @ 0x23f1a0] ext header missing, 16 left
2013-07-17 15:44:39,386 [main] ERROR org.ffmpeg - [msmpeg4 @ 0x23f1a0] ext header missing, 16 left
2013-07-17 15:44:40,382 [main] ERROR org.ffmpeg - [msmpeg4 @ 0x23f1a0] ext header missing, 16 left
2013-07-17 15:44:44,368 [main] ERROR org.ffmpeg - [msmpeg4 @ 0x23f1a0] ext header missing, 16 left
2013-07-17 15:44:45,804 [main] ERROR org.ffmpeg - [mp3 @ 0x23fb80] incomplete frame
java.lang.RuntimeException: error -1 decoding audio
at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:549)
at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469)
at com.imperialems.eventplanning.servlet.network.ConvertVideo.run(ConvertVideo.java:94)
at com.imperialems.eventplanning.servlet.network.ConvertVideo.main(ConvertVideo.java:108)
BUILD SUCCESSFUL (total time: 17 seconds)
Can you specify the exact jar files to be used for executing xuggler code on windows 8??
Remove all jar add only 3 jar mention bellow.
slf4j.jar
log4j- 1. 2. 16. jar
Xuggler-xuggler 5. 4. jar 34mb size.
@Mr.Bapusaheb
Can you specify the exact jar files to be used for executing xuggler code on windows 8??
--
You received this message because you are subscribed to a topic in the Google Groups "xuggler-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xuggler-users/9pqji4hDwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xuggler-user...@googlegroups.com.
To post to this group, send email to xuggle...@googlegroups.com.
Visit this group at https://groups.google.com/group/xuggler-users.
For more options, visit https://groups.google.com/d/optout.
What is the exact error shown.
Sir,
Thanks a lot for your reply but it isn't working in netbeans.Can you please suggest me something more that needs to be done to make it happen??
--
You received this message because you are subscribed to a topic in the Google Groups "xuggler-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xuggler-users/9pqji4hDwdU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xuggler-user...@googlegroups.com.
To post to this group, send email to xuggle...@googlegroups.com.
Visit this group at https://groups.google.com/group/xuggler-users.
For more options, visit https://groups.google.com/d/optout.