Revision 9450118b libavformat/utils.c

View differences:

libavformat/utils.c
2158 2158
    int ret, i;
2159 2159
    AVStream *st;
2160 2160

  
2161
    // some sanity checks
2162
    for(i=0;i<s->nb_streams;i++) {
2163
        st = s->streams[i];
2164

  
2165
        switch (st->codec->codec_type) {
2166
        case CODEC_TYPE_AUDIO:
2167
            if(st->codec->sample_rate<=0){
2168
                av_log(s, AV_LOG_ERROR, "sample rate not set\n");
2169
                return -1;
2170
            }
2171
            break;
2172
        case CODEC_TYPE_VIDEO:
2173
            if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too?
2174
                av_log(s, AV_LOG_ERROR, "time base not set\n");
2175
                return -1;
2176
            }
2177
            if(st->codec->width<=0 || st->codec->height<=0){
2178
                av_log(s, AV_LOG_ERROR, "dimensions not set\n");
2179
                return -1;
2180
            }
2181
            break;
2182
        }
2183
    }
2184

  
2161 2185
    ret = s->oformat->write_header(s);
2162 2186
    if (ret < 0)
2163 2187
        return ret;

Also available in: Unified diff