aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-08-14 16:19:20 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-08-14 16:19:20 +0000
commit9450118bc799796ebb23338fe50fc60c3fabe566 (patch)
tree6500c1bcea0253b3791c605b4698c2b6159aef87 /libavformat
parentbf4e3bd2d0263169ebf5d88972ae319ecb0d7a1e (diff)
downloadffmpeg-9450118bc799796ebb23338fe50fc60c3fabe566.tar.gz
a few checks, seems i forgot to commit this
Originally committed as revision 4523 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f2091f7684..0940f652c4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2158,6 +2158,30 @@ int av_write_header(AVFormatContext *s)
int ret, i;
AVStream *st;
+ // some sanity checks
+ for(i=0;i<s->nb_streams;i++) {
+ st = s->streams[i];
+
+ switch (st->codec->codec_type) {
+ case CODEC_TYPE_AUDIO:
+ if(st->codec->sample_rate<=0){
+ av_log(s, AV_LOG_ERROR, "sample rate not set\n");
+ return -1;
+ }
+ break;
+ case CODEC_TYPE_VIDEO:
+ if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too?
+ av_log(s, AV_LOG_ERROR, "time base not set\n");
+ return -1;
+ }
+ if(st->codec->width<=0 || st->codec->height<=0){
+ av_log(s, AV_LOG_ERROR, "dimensions not set\n");
+ return -1;
+ }
+ break;
+ }
+ }
+
ret = s->oformat->write_header(s);
if (ret < 0)
return ret;