a-schild / jave2

The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project
GNU General Public License v3.0
1.2k stars 245 forks source link

When clipping a video, set the new video width to 1280 and the height to 597, and an error will occur #182

Closed LjunT closed 2 years ago

LjunT commented 2 years ago
   File source = new File(“E:\mntn\inch\upload\mprry\upload_resource\travelImprint\2021\1101\4488001\1635738370857.mp4”);
    AudioAttributes audio = new AudioAttributes();
    audio.setCodec("aac");
    audio.setBitRate(128000);
    audio.setSamplingRate(44100);
    audio.setChannels(2);

    VideoAttributes video = new VideoAttributes();
    video.setCodec("h264");
    video.setBitRate(160000);
    video.setFrameRate(30);
    video.setSize(new VideoSize(1280,597));
    EncodingAttributes attrs = new EncodingAttributes();
    attrs.setOutputFormat("mp4");
    attrs.setAudioAttributes(audio);
    attrs.setVideoAttributes(video);
    String newVideoPath = “E:\mntn\inch\upload\mprry\upload_resource\travelImprint\2021\1101\4488001\VID18.mp4”;
    File target = new File(newVideoPath);
    Encoder encoder = new Encoder();
    try {
        encoder.encode(new MultimediaObject(source), target, attrs);
    } catch (EncoderException e) {
        e.printStackTrace();
    }

The following is the error message log4j:WARN No appenders could be found for logger (ws.schild.jave.FFMPEGExecutor). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" ws.schild.jave.EncoderException: Exit code of ffmpeg encoding run is 1 at ws.schild.jave.Encoder.encode(Encoder.java:582) at ws.schild.jave.Encoder.encode(Encoder.java:357) at com.mp.utils.VideoUtil.catVideo(VideoUtil.java:77) at com.mp.utils.VideoUtil.main(VideoUtil.java:25) Disconnected from the target VM, address: '127.0.0.1:56565', transport: 'socket'

I have tried to set the height to 596 and 598 without any problem. Is this a bug

a-schild commented 2 years ago

mp4 videos need to have even number of pixels in height and width

https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2