Add a default timebase if the codec timebase is invalid. Also fix crash when we can't open the .mp4
parent
1419f20dcc
commit
51f0e7e5c8
|
@ -127,7 +127,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
||||||
|
|
||||||
#else
|
#else
|
||||||
video_out_stream =
|
video_out_stream =
|
||||||
avformat_new_stream(oc,(AVCodec *)(video_in_ctx->codec));
|
avformat_new_stream(oc, NULL);
|
||||||
|
//(AVCodec *)(video_in_ctx->codec));
|
||||||
//avformat_new_stream(oc,(const AVCodec *)(video_in_ctx->codec));
|
//avformat_new_stream(oc,(const AVCodec *)(video_in_ctx->codec));
|
||||||
if ( !video_out_stream ) {
|
if ( !video_out_stream ) {
|
||||||
Fatal("Unable to create video out stream\n");
|
Fatal("Unable to create video out stream\n");
|
||||||
|
@ -158,6 +159,9 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
||||||
|
|
||||||
// Just copy them from the in, no reason to choose different
|
// Just copy them from the in, no reason to choose different
|
||||||
video_out_ctx->time_base = video_in_ctx->time_base;
|
video_out_ctx->time_base = video_in_ctx->time_base;
|
||||||
|
if ( ! (video_out_ctx->time_base.num && video_out_ctx->time_base.den) ) {
|
||||||
|
video_out_ctx->time_base = AV_TIME_BASE_Q;
|
||||||
|
}
|
||||||
video_out_stream->time_base = video_in_stream->time_base;
|
video_out_stream->time_base = video_in_stream->time_base;
|
||||||
|
|
||||||
Debug(3,
|
Debug(3,
|
||||||
|
@ -339,6 +343,9 @@ bool VideoStore::open() {
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
Error("Error occurred when writing out file header to %s: %s\n",
|
Error("Error occurred when writing out file header to %s: %s\n",
|
||||||
filename, av_make_error_string(ret).c_str());
|
filename, av_make_error_string(ret).c_str());
|
||||||
|
/* free the stream */
|
||||||
|
avio_closep(&oc->pb);
|
||||||
|
//avformat_free_context(oc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -412,7 +419,7 @@ VideoStore::~VideoStore() {
|
||||||
if (int rc = av_write_trailer(oc)) {
|
if (int rc = av_write_trailer(oc)) {
|
||||||
Error("Error writing trailer %s", av_err2str(rc));
|
Error("Error writing trailer %s", av_err2str(rc));
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "Sucess Writing trailer");
|
Debug(3, "Success Writing trailer");
|
||||||
}
|
}
|
||||||
|
|
||||||
// When will we not be using a file ?
|
// When will we not be using a file ?
|
||||||
|
@ -426,7 +433,7 @@ VideoStore::~VideoStore() {
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "Not closing avio because we are not writing to a file.");
|
Debug(3, "Not closing avio because we are not writing to a file.");
|
||||||
}
|
}
|
||||||
}
|
} // end if ( oc->pb )
|
||||||
// I wonder if we should be closing the file first.
|
// I wonder if we should be closing the file first.
|
||||||
// I also wonder if we really need to be doing all the ctx
|
// I also wonder if we really need to be doing all the ctx
|
||||||
// allocation/de-allocation constantly, or whether we can just re-use it.
|
// allocation/de-allocation constantly, or whether we can just re-use it.
|
||||||
|
|
Loading…
Reference in New Issue