Browse code

lavf/flvenc: apply various log fixes/clarifications

Should improve user feedback in case of errors.

Stefano Sabatini authored on 2012/09/06 22:10:21
Showing 1 changed files
... ...
@@ -80,11 +80,11 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
80 80
     else if (enc->codec_id == AV_CODEC_ID_SPEEX) {
81 81
         if (enc->sample_rate != 16000) {
82 82
             av_log(s, AV_LOG_ERROR,
83
-                   "flv only supports wideband (16kHz) Speex audio\n");
83
+                   "FLV only supports wideband (16kHz) Speex audio\n");
84 84
             return AVERROR(EINVAL);
85 85
         }
86 86
         if (enc->channels != 1) {
87
-            av_log(s, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
87
+            av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
88 88
             return AVERROR(EINVAL);
89 89
         }
90 90
         return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
... ...
@@ -108,8 +108,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
108 108
             }
109 109
         default:
110 110
             av_log(s, AV_LOG_ERROR,
111
-                   "flv does not support that sample rate, "
112
-                   "choose from (44100, 22050, 11025).\n");
111
+                   "FLV does not support sample rate %d, "
112
+                   "choose from (44100, 22050, 11025)\n", enc->sample_rate);
113 113
             return AVERROR(EINVAL);
114 114
         }
115 115
     }
... ...
@@ -151,7 +151,8 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
151 151
         flags |= enc->codec_tag << 4;
152 152
         break;
153 153
     default:
154
-        av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
154
+        av_log(s, AV_LOG_ERROR, "Audio codec '%s' not compatible with FLV\n",
155
+               avcodec_get_name(enc->codec_id));
155 156
         return AVERROR(EINVAL);
156 157
     }
157 158
 
... ...
@@ -213,7 +214,8 @@ static int flv_write_header(AVFormatContext *s)
213 213
             }
214 214
             video_enc = enc;
215 215
             if (enc->codec_tag == 0) {
216
-                av_log(s, AV_LOG_ERROR, "video codec not compatible with flv\n");
216
+                av_log(s, AV_LOG_ERROR, "Video codec '%s' for stream %d is not compatible with FLV\n",
217
+                       avcodec_get_name(enc->codec_id), i);
217 218
                 return AVERROR(EINVAL);
218 219
             }
219 220
             break;
... ...
@@ -224,13 +226,15 @@ static int flv_write_header(AVFormatContext *s)
224 224
             break;
225 225
         case AVMEDIA_TYPE_DATA:
226 226
             if (enc->codec_id != AV_CODEC_ID_TEXT) {
227
-                av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
227
+                av_log(s, AV_LOG_ERROR, "Data codec '%s' for stream %d is not compatible with FLV\n",
228
+                       avcodec_get_name(enc->codec_id), i);
228 229
                 return AVERROR_INVALIDDATA;
229 230
             }
230 231
             data_enc = enc;
231 232
             break;
232 233
         default:
233
-            av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
234
+            av_log(s, AV_LOG_ERROR, "Codec type '%s' for stream %d is not compatible with FLV\n",
235
+                   av_get_media_type_string(enc->codec_type), i);
234 236
             return AVERROR(EINVAL);
235 237
         }
236 238
         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 343
             ||!strcmp(tag->key, "duration")
344 344
             ||!strcmp(tag->key, "onMetaData")
345 345
         ){
346
-            av_log(s, AV_LOG_DEBUG, "ignoring metadata for %s\n", tag->key);
346
+            av_log(s, AV_LOG_DEBUG, "Ignoring metadata for %s\n", tag->key);
347 347
             continue;
348 348
         }
349 349
         put_amf_string(pb, tag->key);
... ...
@@ -460,7 +464,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
460 460
         flags = enc->codec_tag;
461 461
         if (flags == 0) {
462 462
             av_log(s, AV_LOG_ERROR,
463
-                   "video codec %s not compatible with flv\n",
463
+                   "Video codec '%s' is not compatible with FLV\n",
464 464
                    avcodec_get_name(enc->codec_id));
465 465
             return AVERROR(EINVAL);
466 466
         }
... ...
@@ -488,7 +492,9 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
488 488
                 return ret;
489 489
     } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
490 490
                (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
491
-        av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n");
491
+        av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
492
+               "use audio bistream filter 'aac_adtstoasc' to fix it "
493
+               "('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
492 494
         return AVERROR_INVALIDDATA;
493 495
     }
494 496