Hywel Griffiths
Hywel Griffiths

Reputation: 368

Create mp3 with Xuggler from mp4

I have some Java code to create an mp3 from the audio of an mp4. Its creating the file but there's something wrong as the file can't be run. There's also an error associated with the logger so if there is any information on either I'd be very grateful.

public class VideoToAudio {

public void convertVideoToAudio() {

String inputFilename = "/Users/hywel/Documents/home/pictures/Test.mp4";
String outputFilename = "/Users/hywel/Documents/home/pictures/Audio.mp3";

IMediaReader reader = ToolFactory.makeReader(inputFilename);
IMediaWriter writer = ToolFactory.makeWriter(outputFilename);
int sampleRate = 44100;
int channels = 1;
writer.addAudioStream(0, 0, ICodec.ID.CODEC_ID_MP3, channels, sampleRate);
while (reader.readPacket() == null) ;
}

}

public static void main(String[] args) {

VideoToAudio vta = new VideoToAudio();
VideoToAudio videoToAudio = new VideoToAudio();
vta.convertVideoToAudio();

}

ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2 ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

Upvotes: 0

Views: 100

Answers (1)

Kez
Kez

Reputation: 7

Prior to initialising your Xuggler method, you need to call:

org.apache.log4j.BasicConfigurator.configure();

This should solve your Log4j error.

Upvotes: 1

Related Questions