/**Estimation of audio frames per second * * @return (double) getSampleRate()) / samples_frame.nb_samples() * if samples_frame.nb_samples() is not zero, otherwise return 0 */ public double getAudioFrameRate() { if (audio_st == null) { return 0.0; } else { if (samples_frame == null || samples_frame.nb_samples() == 0) { try { grabFrame(true, false, false, false); frameGrabbed = true; } catch (Exception e) { return 0.0; } } if (samples_frame != null || samples_frame.nb_samples() != 0) return ((double) getSampleRate()) / samples_frame.nb_samples(); else return 0.0; } }
recorder.setFrameRate(frameGrabber.getFrameRate()); recorder.setSampleFormat(frameGrabber.getSampleFormat()); recorder.setSampleRate(frameGrabber.getSampleRate()); recorder.start(); while (true) {
if (audio_c.channels() != getAudioChannels() || audio_c.sample_fmt() != getSampleFormat() || audio_c.sample_rate() != getSampleRate()) { if (samples_convert_ctx == null || samples_channels != getAudioChannels() || samples_format != getSampleFormat() || samples_rate != getSampleRate()) { samples_convert_ctx = swr_alloc_set_opts(samples_convert_ctx, av_get_default_channel_layout(getAudioChannels()), getSampleFormat(), getSampleRate(), av_get_default_channel_layout(audio_c.channels()), audio_c.sample_fmt(), audio_c.sample_rate(), 0, null); if (samples_convert_ctx == null) { samples_rate = getSampleRate();