| 968 | } |
| 969 | |
| 970 | static int flv_init(struct AVFormatContext *s) |
| 971 | { |
| 972 | int i; |
| 973 | int video_ctr = 0, audio_ctr = 0; |
| 974 | FLVContext *flv = s->priv_data; |
| 975 | |
| 976 | flv->last_ts = av_calloc(s->nb_streams, sizeof(*flv->last_ts)); |
| 977 | flv->metadata_pkt_written = av_calloc(s->nb_streams, sizeof(*flv->metadata_pkt_written)); |
| 978 | flv->track_idx_map = av_calloc(s->nb_streams, sizeof(*flv->track_idx_map)); |
| 979 | if (!flv->last_ts || !flv->metadata_pkt_written || !flv->track_idx_map) |
| 980 | return AVERROR(ENOMEM); |
| 981 | |
| 982 | for (i = 0; i < s->nb_streams; i++) { |
| 983 | AVCodecParameters *par = s->streams[i]->codecpar; |
| 984 | |
| 985 | switch (par->codec_type) { |
| 986 | case AVMEDIA_TYPE_VIDEO: |
| 987 | if (video_ctr && |
| 988 | par->codec_id != AV_CODEC_ID_VP8 && |
| 989 | par->codec_id != AV_CODEC_ID_VP9 && |
| 990 | par->codec_id != AV_CODEC_ID_AV1 && |
| 991 | par->codec_id != AV_CODEC_ID_H264 && |
| 992 | par->codec_id != AV_CODEC_ID_HEVC && |
| 993 | par->codec_id != AV_CODEC_ID_VVC) { |
| 994 | av_log(s, AV_LOG_ERROR, "Unsupported multi-track video codec.\n"); |
| 995 | return AVERROR(EINVAL); |
| 996 | } |
| 997 | if (s->streams[i]->avg_frame_rate.den && |
| 998 | s->streams[i]->avg_frame_rate.num) { |
| 999 | flv->framerate = av_q2d(s->streams[i]->avg_frame_rate); |
| 1000 | } |
| 1001 | flv->track_idx_map[i] = video_ctr++; |
| 1002 | if (flv->video_par && flv->flags & FLV_ADD_KEYFRAME_INDEX) { |
| 1003 | av_log(s, AV_LOG_ERROR, |
| 1004 | "at most one video stream is supported in flv with keyframe index\n"); |
| 1005 | return AVERROR(EINVAL); |
| 1006 | } else if (flv->video_par) { |
| 1007 | av_log(s, AV_LOG_WARNING, |
| 1008 | "more than one video stream is not supported by most flv demuxers.\n"); |
| 1009 | } |
| 1010 | if (!flv->video_par) |
| 1011 | flv->video_par = par; |
| 1012 | if (!ff_codec_get_tag(flv_video_codec_ids, par->codec_id)) |
| 1013 | return unsupported_codec(s, "Video", par->codec_id); |
| 1014 | |
| 1015 | if (par->codec_id == AV_CODEC_ID_MPEG4 || |
| 1016 | par->codec_id == AV_CODEC_ID_H263) { |
| 1017 | int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL; |
| 1018 | av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING, |
| 1019 | "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(par->codec_id)); |
| 1020 | |
| 1021 | if (error) { |
| 1022 | av_log(s, AV_LOG_ERROR, |
| 1023 | "use vstrict=-1 / -strict -1 to use it anyway.\n"); |
| 1024 | return AVERROR(EINVAL); |
| 1025 | } |
| 1026 | } else if (par->codec_id == AV_CODEC_ID_VP6) { |
| 1027 | av_log(s, AV_LOG_WARNING, |
nothing calls this directly
no test coverage detected