ffmpeg-cli-wrapper icon indicating copy to clipboard operation
ffmpeg-cli-wrapper copied to clipboard

Invalid data found when processing input [mp3float @ 0000000002e68940] Header missing

Open sarvesh opened this issue 7 years ago • 2 comments
trafficstars

Hi All, Thanks for the great snippet. I really liked it. This is exactly what am looking for. But however am facing the issues with conversion from .wav to .mp3 Please find below the code snippet am using to convert

To Reproduce

public class Test {

    public  static void main(String[] args) throws Exception {

        FFmpeg ffmpeg = new FFmpeg("C:\\ffmpeg-20180824-d0b48a9-win64-static\\bin\\ffmpeg.exe");
        FFprobe ffprobe = new FFprobe("C:\\ffmpeg-20180824-d0b48a9-win64-static\\bin\\ffprobe.exe");
        FFmpegProbeResult in = ffprobe.probe("C:\\atmospace_jungle.wav"); //The audio file size 912KB. So i want the generated mp3 file should be half the size. Therefore the size is defined as size=500000(500KB)
        long size = 500000L;
        FFmpegBuilder builder = new FFmpegBuilder().setInput(in).setFormat("mp3").addOutput("audio.mp3").setTargetSize(size)
                .setAudioCodec("aac")
                .setAudioChannels(1)
                .setAudioSampleRate(48000)
                .setAudioBitRate(32768)
                .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL)
                .done();
        FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
        executor.createJob(builder).run();
    }
}

Expected behavior A clear and concise description of what you expected to happen.

Version (if applicable):

  • OS Windows 7 64 bit
  • Java Version 1.7

Additional context Add any other context about the problem here.

sarvesh avatar Aug 24 '18 19:08 sarvesh

The setInput(in).setFormat("mp3") line is forcing the input to be read as MP3. Move the setFormat after the addOutput.

Also you must likely don't need the setAudioCodec("aac") line, that would be seeing a different audio codec (and not using MP3).

bramp avatar Aug 25 '18 05:08 bramp

I made the changes as suggested. But now ffProbe is failing with the below exception

image

And the sample code

FFmpeg ffmpeg = new FFmpeg("C:\Users\snallami\Downloads\ffmpeg-20180824-d0b48a9-win64-static\bin\ffmpeg.exe"); FFprobe ffprobe = new FFprobe("C:\Users\snallami\Downloads\ffmpeg-20180824-d0b48a9-win64-static\bin\ffprobe.exe"); FFmpegProbeResult in = ffprobe.probe("C:\atmospace_jungle.wav"); //The audio file size 912KB. So i want the generated mp3 file should be half the size. Therefore the size is defined as size=500000(500KB) long size = 500000L; FFmpegBuilder builder = new FFmpegBuilder().setInput(in).addOutput("audio.mp3").setFormat("mp3").setTargetSize(size) .setAudioChannels(1) .setAudioSampleRate(48000) .setAudioBitRate(32768) .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) .done(); FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe); executor.createJob(builder).run();

sarvesh avatar Aug 28 '18 03:08 sarvesh