static bool audio_frame(struct ff_frame *frame, void *opaque) { struct ffmpeg_source *s = opaque; struct obs_source_audio audio_data = {0}; uint64_t pts; // Media ended if (frame == NULL) return true; pts = (uint64_t)(frame->pts * 1000000000.0L); int channels = av_frame_get_channels(frame->frame); for(int i = 0; i < channels; i++) audio_data.data[i] = frame->frame->data[i]; audio_data.samples_per_sec = frame->frame->sample_rate; audio_data.frames = frame->frame->nb_samples; audio_data.timestamp = pts; audio_data.format = convert_ffmpeg_sample_format(frame->frame->format); audio_data.speakers = channels; obs_source_output_audio(s->source, &audio_data); return true; }
static bool aac_audio_info(void *data, struct audio_convert_info *info) { struct aac_encoder *enc = data; memset(info, 0, sizeof(struct audio_convert_info)); info->format = convert_ffmpeg_sample_format(enc->context->sample_fmt); return true; }
static void init_sizes(struct aac_encoder *enc, audio_t audio) { const struct audio_output_info *aoi; enum audio_format format; aoi = audio_output_getinfo(audio); format = convert_ffmpeg_sample_format(enc->context->sample_fmt); enc->audio_planes = get_audio_planes(format, aoi->speakers); enc->audio_size = get_audio_size(format, aoi->speakers, 1); }
static void aac_audio_info(void *data, struct audio_convert_info *info) { struct aac_encoder *enc = data; info->format = convert_ffmpeg_sample_format(enc->context->sample_fmt); }
static void enc_audio_info(void *data, struct audio_convert_info *info) { struct enc_encoder *enc = data; info->format = convert_ffmpeg_sample_format(enc->context->sample_fmt); info->samples_per_sec = (uint32_t)enc->context->sample_rate; }