Merge branch 'master' into storageareas

pull/2562/head
Isaac Connor 2018-10-24 13:45:54 -04:00
commit ed50856d40
1 changed files with 18 additions and 11 deletions

View File

@ -248,18 +248,18 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
// Copy params from instream to ctx // Copy params from instream to ctx
ret = avcodec_parameters_to_context(audio_out_ctx, ret = avcodec_parameters_to_context(audio_out_ctx,
audio_in_stream->codecpar); audio_in_stream->codecpar);
if (ret < 0) { if ( ret < 0 ) {
Error("Unable to copy audio params to ctx %s\n", Error("Unable to copy audio params to ctx %s",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
} }
ret = avcodec_parameters_from_context(audio_out_stream->codecpar, ret = avcodec_parameters_from_context(audio_out_stream->codecpar,
audio_out_ctx); audio_out_ctx);
if (ret < 0) { if ( ret < 0 ) {
Error("Unable to copy audio params to stream %s\n", Error("Unable to copy audio params to stream %s",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
} }
if (!audio_out_ctx->codec_tag) { if ( !audio_out_ctx->codec_tag ) {
audio_out_ctx->codec_tag = av_codec_get_tag( audio_out_ctx->codec_tag = av_codec_get_tag(
oc->oformat->codec_tag, audio_in_ctx->codec_id); oc->oformat->codec_tag, audio_in_ctx->codec_id);
Debug(2, "Setting audio codec tag to %d", Debug(2, "Setting audio codec tag to %d",
@ -271,12 +271,12 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
ret = avcodec_copy_context(audio_out_ctx, audio_in_ctx); ret = avcodec_copy_context(audio_out_ctx, audio_in_ctx);
audio_out_ctx->codec_tag = 0; audio_out_ctx->codec_tag = 0;
#endif #endif
if (ret < 0) { if ( ret < 0 ) {
Error("Unable to copy audio ctx %s\n", Error("Unable to copy audio ctx %s",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
audio_out_stream = NULL; audio_out_stream = NULL;
} else { } else {
if (audio_out_ctx->channels > 1) { if ( audio_out_ctx->channels > 1 ) {
Warning("Audio isn't mono, changing it."); Warning("Audio isn't mono, changing it.");
audio_out_ctx->channels = 1; audio_out_ctx->channels = 1;
} else { } else {
@ -286,7 +286,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
} // end if audio_out_stream } // end if audio_out_stream
} // end if is AAC } // end if is AAC
if (audio_out_stream) { if ( audio_out_stream ) {
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0) #if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
@ -522,8 +522,8 @@ bool VideoStore::setup_resampler() {
// audio_out_ctx = audio_out_stream->codec; // audio_out_ctx = audio_out_stream->codec;
audio_out_ctx = avcodec_alloc_context3(audio_out_codec); audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
if (!audio_out_ctx) { if ( !audio_out_ctx ) {
Error("could not allocate codec ctx for AAC\n"); Error("could not allocate codec ctx for AAC");
audio_out_stream = NULL; audio_out_stream = NULL;
return false; return false;
} }
@ -546,6 +546,13 @@ bool VideoStore::setup_resampler() {
#else #else
audio_out_ctx->refcounted_frames = 1; audio_out_ctx->refcounted_frames = 1;
#endif #endif
if ( ! audio_out_ctx->channel_layout ) {
Debug(3, "Correcting channel layout from (%d) to (%d)",
audio_out_ctx->channel_layout,
av_get_default_channel_layout(audio_out_ctx->channels)
);
audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels);
}
if (audio_out_codec->supported_samplerates) { if (audio_out_codec->supported_samplerates) {
int found = 0; int found = 0;