Commit da2ea7c3 authored by Stefano Sabatini's avatar Stefano Sabatini

lavf/flvenc: apply various log fixes/clarifications

Should improve user feedback in case of errors.
parent 1bd6b0c9
...@@ -80,11 +80,11 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc) ...@@ -80,11 +80,11 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
else if (enc->codec_id == AV_CODEC_ID_SPEEX) { else if (enc->codec_id == AV_CODEC_ID_SPEEX) {
if (enc->sample_rate != 16000) { if (enc->sample_rate != 16000) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"flv only supports wideband (16kHz) Speex audio\n"); "FLV only supports wideband (16kHz) Speex audio\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (enc->channels != 1) { if (enc->channels != 1) {
av_log(s, AV_LOG_ERROR, "flv only supports mono Speex audio\n"); av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT; return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
...@@ -108,8 +108,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc) ...@@ -108,8 +108,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
} }
default: default:
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"flv does not support that sample rate, " "FLV does not support sample rate %d, "
"choose from (44100, 22050, 11025).\n"); "choose from (44100, 22050, 11025)\n", enc->sample_rate);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
} }
...@@ -151,7 +151,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc) ...@@ -151,7 +151,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
flags |= enc->codec_tag << 4; flags |= enc->codec_tag << 4;
break; break;
default: default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n"); av_log(s, AV_LOG_ERROR, "Audio codec '%s' not compatible with FLV\n",
avcodec_get_name(enc->codec_id));
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
...@@ -213,7 +214,8 @@ static int flv_write_header(AVFormatContext *s) ...@@ -213,7 +214,8 @@ static int flv_write_header(AVFormatContext *s)
} }
video_enc = enc; video_enc = enc;
if (enc->codec_tag == 0) { if (enc->codec_tag == 0) {
av_log(s, AV_LOG_ERROR, "video codec not compatible with flv\n"); av_log(s, AV_LOG_ERROR, "Video codec '%s' for stream %d is not compatible with FLV\n",
avcodec_get_name(enc->codec_id), i);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
break; break;
...@@ -224,13 +226,15 @@ static int flv_write_header(AVFormatContext *s) ...@@ -224,13 +226,15 @@ static int flv_write_header(AVFormatContext *s)
break; break;
case AVMEDIA_TYPE_DATA: case AVMEDIA_TYPE_DATA:
if (enc->codec_id != AV_CODEC_ID_TEXT) { if (enc->codec_id != AV_CODEC_ID_TEXT) {
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n"); av_log(s, AV_LOG_ERROR, "Data codec '%s' for stream %d is not compatible with FLV\n",
avcodec_get_name(enc->codec_id), i);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
data_enc = enc; data_enc = enc;
break; break;
default: default:
av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n"); av_log(s, AV_LOG_ERROR, "Codec type '%s' for stream %d is not compatible with FLV\n",
av_get_media_type_string(enc->codec_type), i);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */ avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
...@@ -343,7 +347,7 @@ static int flv_write_header(AVFormatContext *s) ...@@ -343,7 +347,7 @@ static int flv_write_header(AVFormatContext *s)
||!strcmp(tag->key, "duration") ||!strcmp(tag->key, "duration")
||!strcmp(tag->key, "onMetaData") ||!strcmp(tag->key, "onMetaData")
){ ){
av_log(s, AV_LOG_DEBUG, "ignoring metadata for %s\n", tag->key); av_log(s, AV_LOG_DEBUG, "Ignoring metadata for %s\n", tag->key);
continue; continue;
} }
put_amf_string(pb, tag->key); put_amf_string(pb, tag->key);
...@@ -460,7 +464,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -460,7 +464,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
flags = enc->codec_tag; flags = enc->codec_tag;
if (flags == 0) { if (flags == 0) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"video codec %s not compatible with flv\n", "Video codec '%s' is not compatible with FLV\n",
avcodec_get_name(enc->codec_id)); avcodec_get_name(enc->codec_id));
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
...@@ -488,7 +492,9 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -488,7 +492,9 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
} else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
"use audio bistream filter 'aac_adtstoasc' to fix it "
"('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
......
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