Commit d864bae9 authored by Jan Gerber's avatar Jan Gerber
Browse files

some audio decoders set sample_rate to 0 in avcodec_open now

parent 77148c63
...@@ -934,6 +934,7 @@ void ff2theora_output(ff2theora this) { ...@@ -934,6 +934,7 @@ void ff2theora_output(ff2theora this) {
astream = this->context->streams[this->audio_index]; astream = this->context->streams[this->audio_index];
aenc = this->context->streams[this->audio_index]->codec; aenc = this->context->streams[this->audio_index]->codec;
acodec = avcodec_find_decoder (aenc->codec_id); acodec = avcodec_find_decoder (aenc->codec_id);
int sample_rate = aenc->sample_rate;
if (this->channels < 1) { if (this->channels < 1) {
this->channels = aenc->channels; this->channels = aenc->channels;
} }
...@@ -949,19 +950,19 @@ void ff2theora_output(ff2theora this) { ...@@ -949,19 +950,19 @@ void ff2theora_output(ff2theora this) {
} }
if (acodec != NULL && avcodec_open (aenc, acodec) >= 0) { if (acodec != NULL && avcodec_open (aenc, acodec) >= 0) {
if (this->sample_rate != aenc->sample_rate if (this->sample_rate != sample_rate
|| this->channels != aenc->channels || this->channels != aenc->channels
|| aenc->sample_fmt != SAMPLE_FMT_S16) { || aenc->sample_fmt != SAMPLE_FMT_S16) {
// values take from libavcodec/resample.c // values take from libavcodec/resample.c
this->audio_resample_ctx = av_audio_resample_init(this->channels, aenc->channels, this->audio_resample_ctx = av_audio_resample_init(this->channels, aenc->channels,
this->sample_rate, aenc->sample_rate, this->sample_rate, sample_rate,
SAMPLE_FMT_S16, aenc->sample_fmt, SAMPLE_FMT_S16, aenc->sample_fmt,
16, 10, 0, 0.8); 16, 10, 0, 0.8);
if (!this->audio_resample_ctx) { if (!this->audio_resample_ctx) {
this->channels = aenc->channels; this->channels = aenc->channels;
} }
if (!info.frontend && this->sample_rate!=aenc->sample_rate) if (!info.frontend && this->sample_rate!=sample_rate)
fprintf(stderr, " Resample: %dHz => %dHz\n",aenc->sample_rate,this->sample_rate); fprintf(stderr, " Resample: %dHz => %dHz\n", sample_rate,this->sample_rate);
if (!info.frontend && this->channels!=aenc->channels) if (!info.frontend && this->channels!=aenc->channels)
fprintf(stderr, " Channels: %d => %d\n",aenc->channels,this->channels); fprintf(stderr, " Channels: %d => %d\n",aenc->channels,this->channels);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment