implement some checks for valid values when opening the output file
This commit is contained in:
parent
df6aaf5dec
commit
b7096b742d
|
@ -38,9 +38,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
int64_t nStartTime,
|
||||
Monitor::Orientation orientation
|
||||
) {
|
||||
|
||||
AVDictionary *pmetadata = NULL;
|
||||
int dsr;
|
||||
|
||||
|
||||
//store inputs in variables local to class
|
||||
filename = filename_in;
|
||||
|
@ -49,10 +47,10 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
keyframeMessage = false;
|
||||
keyframeSkipNumber = 0;
|
||||
|
||||
Info("Opening video storage stream %s format: %d\n", filename, format);
|
||||
Info("Opening video storage stream %s format: %s\n", filename, format);
|
||||
|
||||
//Init everything we need
|
||||
int ret;
|
||||
//Init everything we need
|
||||
av_register_all();
|
||||
|
||||
ret = avformat_alloc_output_context2(&oc, NULL, NULL, filename);
|
||||
|
@ -74,7 +72,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
}
|
||||
}
|
||||
|
||||
dsr = av_dict_set(&pmetadata, "title", "Zoneminder Security Recording", 0);
|
||||
AVDictionary *pmetadata = NULL;
|
||||
int dsr = av_dict_set(&pmetadata, "title", "Zoneminder Security Recording", 0);
|
||||
if (dsr < 0) Warning("%s:%d: title set failed", __FILE__, __LINE__ );
|
||||
|
||||
oc->metadata = pmetadata;
|
||||
|
@ -92,6 +91,23 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
av_make_error_string(ret).c_str());
|
||||
}
|
||||
|
||||
if ( video_st->sample_aspect_ratio.den != video_st->codec->sample_aspect_ratio.den ) {
|
||||
Warning("Fixingample_aspect_ratio.den");
|
||||
video_st->sample_aspect_ratio.den = video_st->codec->sample_aspect_ratio.den;
|
||||
}
|
||||
if ( video_st->sample_aspect_ratio.num != input_st->codec->sample_aspect_ratio.num ) {
|
||||
Warning("Fixingample_aspect_ratio.num");
|
||||
video_st->sample_aspect_ratio.num = input_st->codec->sample_aspect_ratio.num;
|
||||
}
|
||||
if ( video_st->codec->codec_id != input_st->codec->codec_id ) {
|
||||
Warning("Fixing video_st->codec->codec_id");
|
||||
video_st->codec->codec_id = input_st->codec->codec_id;
|
||||
}
|
||||
if ( ! video_st->codec->time_base.num ) {
|
||||
Warning("video_st->codec->time_base.num is not set. Fixing by setting it to 1");
|
||||
video_st->codec->time_base.num = 1;
|
||||
}
|
||||
|
||||
video_st->codec->codec_tag = 0;
|
||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
|
||||
video_st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
|
Loading…
Reference in New Issue