[FFmpeg-user] ffmpeg encode amr to mp3 error

jude judechen1101 at gmail.com
Wed Oct 23 10:53:38 CEST 2013


Hi, all

I am a beginner in ffmpeg. When I use it to convert amr to mp3, there is
exception occurs:
it.sauronsoftware.jave.EncoderException: video:0kB audio:42kB subtitle:0
global headers:0kB muxing overhead 1.083718%
        at it.sauronsoftware.jave.Encoder.encode(Encoder.java:926)
        at it.sauronsoftware.jave.Encoder.encode(Encoder.java:713)

But the encoded mp3 is right. Here is my code:

try {
            File source = new File(sourceName);
            String targetName = sourceName.replace(".amr", ".mp3");
            File target = new File(targetName);
            AudioAttributes audio = new AudioAttributes();
            audio.setCodec("libmp3lame");
            audio.setBitRate(new Integer(128000));
            audio.setChannels(new Integer(2));
            audio.setSamplingRate(new Integer(44100));
            EncodingAttributes attrs = new EncodingAttributes();
            attrs.setFormat("mp3");
            attrs.setDuration(Float.valueOf(30));
            attrs.setAudioAttributes(audio);
            Encoder encoder = new Encoder(new MyFFMPEGExecutableLocator());
            encoder.encode(source, target, attrs);
            log.info("convertAmr2Mp3 success:sourceName=" + sourceName);
        } catch (Exception e) {
            log.error("convertAmr2Mp3 error", e);
        }


More information about the ffmpeg-user mailing list