FFmpegFrameGrabber grabber = null;
FFmpegFrameRecorder recorder = null;
try {
grabber = new FFmpegFrameGrabber(inFile);
grabber.start();
[...]
recorder = new FFmpegFrameRecorder(outFile, grabber.getAudioChannels());
recorder.setSampleRate(sampleRate <= 0 ? outSampleRate : sampleRate);
recorder.setFormat(outFormat);
recorder.setAudioCodec(outCodec);
if(outBitRate > 0) {
recorder.setAudioBitrate(outBitRate);
}
recorder.start();
Frame frame = null;
while ((frame = grabber.grabSamples()) != null) {
recorder.record(frame);
}
} finally {
try { if(recorder != null) { recorder.stop(); } } catch (Exception ignore) { }
try { if(recorder != null) { recorder.release(); } } catch (Exception ignore) { }
try { if(recorder != null) { recorder.close(); } } catch (Exception ignore) { } // Calling close() method should not have effect since the object has been already stopped and released
recorder = null;
try { if(grabber != null) { grabber.stop(); } } catch (Exception ignore) { }
try { if(grabber != null) { grabber.release(); } } catch (Exception ignore) { }
try { if(grabber != null) { grabber.close(); } } catch (Exception ignore) { } // Calling close() method should not have effect since the object has been already stopped and released
grabber = null;
}
return outFile;
try (PointerScope scope = new PointerScope()) {
grabber = new FFmpegFrameGrabber(inFile);
grabber.start();
[...]
11:00:08,798 INFO [org.hibernate.validator.internal.util.Version] (default task-1) HV000001: Hibernate Validator 6.0.18.Final
11:00:09,496 INFO [stdout] (default task-1) Input file: ENG_P0067.wav - format: AMRNB - samplerate: null - bitrate: null
Input #0, wav, from '/tmp/ENG_P00673120941168953070674.wav':
Duration: 00:00:12.93, bitrate: 64 kb/s
Stream #0:0: Audio: pcm_alaw ([6][0][0][0] / 0x0006), 8000 Hz, 1 channels, s16, 64 kb/s
[libopencore_amrnb @ 0x3a63740] bitrate not supported: use one of 4.75k, 5.15k, 5.90k, 6.70k, 7.40k, 7.95k, 10.20k, 12.20k, using 12.20k
Output #0, amr, to '/tmp/ENG_P00673120941168953070674.wav.amrnb':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Audio: amr_nb, 8000 Hz, mono, s16, 64 kb/s
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fd50266472a, pid=23068, tid=0x00007fd50f214700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libavcodec.so.58+0x1a872a] av_init_packet+0xa
#
# Core dump written. Default location: /opt/wildfly-19.1.0.Final/bin/core or core.23068
#
# An error report file with more information is saved as:
# /opt/wildfly-19.1.0.Final/bin/hs_err_pid23068.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
private static final String FFMPEG = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
[...]
ProcessBuilder pb = new ProcessBuilder(FFMPEG, "-i", inFile.getAbsolutePath(), "-b:a", String.valueOf(bitRate), "-acodec", sOutCodec, outFile);
pb.inheritIO().start().waitFor();