Merge commit 'e767c9e8f2eaa116b61b8b6881b401b54bd320f5'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 4 Mar 2015 19:42:33 +0000 (20:42 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 4 Mar 2015 19:47:14 +0000 (20:47 +0100)
* commit 'e767c9e8f2eaa116b61b8b6881b401b54bd320f5':
  flv: Validate and reject unsupported codecs

Conflicts:
libavformat/flvenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/flvenc.c

@@@ -347,26 -330,8 +358,24 @@@ static int flv_write_header(AVFormatCon
                  return AVERROR(EINVAL);
              }
              flv->video_enc = enc;
-             if (enc->codec_tag == 0) {
-                 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);
-             }
+             if (!ff_codec_get_tag(flv_video_codec_ids, enc->codec_id))
+                 return unsupported_codec(s, "Video", enc->codec_id);
++
 +            if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
 +                enc->codec_id == AV_CODEC_ID_H263) {
 +                int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
 +                av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING,
 +                       "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(enc->codec_id));
 +
 +                if (error) {
 +                    av_log(s, AV_LOG_ERROR,
 +                           "use vstrict=-1 / -strict -1 to use it anyway.\n");
 +                    return AVERROR(EINVAL);
 +                }
 +            } else if (enc->codec_id == AV_CODEC_ID_VP6) {
 +                av_log(s, AV_LOG_WARNING,
 +                       "Muxing VP6 in flv will produce flipped video on playback.\n");
 +            }
              break;
          case AVMEDIA_TYPE_AUDIO:
              if (flv->audio_enc) {
              }
              flv->audio_enc = enc;
              if (get_audio_flags(s, enc) < 0)
-                 return AVERROR_INVALIDDATA;
+                 return unsupported_codec(s, "Audio", enc->codec_id);
 +            if (enc->codec_id == AV_CODEC_ID_PCM_S16BE)
 +                av_log(s, AV_LOG_WARNING,
 +                       "16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
              break;
          case AVMEDIA_TYPE_DATA:
-             if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE) {
-                 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;
-             }
 -            if (enc->codec_id != AV_CODEC_ID_TEXT)
++            if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE)
+                 return unsupported_codec(s, "Data", enc->codec_id);
              flv->data_enc = enc;
              break;
 +        case AVMEDIA_TYPE_SUBTITLE:
 +            if (enc->codec_id != AV_CODEC_ID_TEXT) {
 +                av_log(s, AV_LOG_ERROR, "Subtitle codec '%s' for stream %d is not compatible with FLV\n",
 +                       avcodec_get_name(enc->codec_id), i);
 +                return AVERROR_INVALIDDATA;
 +            }
 +            flv->data_enc = enc;
 +            break;
          default:
 -            av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
 -            return -1;
 +            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);
          }
          avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */