Merge pull request #152 from Mr-DaveDev/ffmpeg-fixes

Timelapse fps and regression fixes
This commit is contained in:
Mr-Dave
2016-09-04 07:59:48 -06:00
committed by GitHub
2 changed files with 12 additions and 10 deletions

View File

@@ -796,14 +796,14 @@ static void event_ffmpeg_timelapse(struct context *cnt,
MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be appended to file");
cnt->ffmpeg_timelapse =
ffmpeg_open(codec_mpg,cnt->timelapsefilename, y, u, v
,cnt->imgs.width, cnt->imgs.height, 24
,cnt->imgs.width, cnt->imgs.height, cnt->conf.frame_limit
,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_APPEND);
} else {
MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using mpeg4 codec.");
MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be trigger new files");
cnt->ffmpeg_timelapse =
ffmpeg_open(codec_mpeg ,cnt->timelapsefilename, y, u, v
,cnt->imgs.width, cnt->imgs.height, 1
,cnt->imgs.width, cnt->imgs.height, cnt->conf.frame_limit
,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_NEW);
}

View File

@@ -421,10 +421,11 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename,
ffmpeg->video_st->time_base.num = 1;
ffmpeg->video_st->time_base.den = 1000;
if (strcmp(ffmpeg_video_codec, "swf") == 0) {
if ((strcmp(ffmpeg_video_codec, "swf") == 0) ||
(ffmpeg->tlapse != TIMELAPSE_NONE) ) {
ffmpeg->video_st->time_base.num = 1;
ffmpeg->video_st->time_base.den = rate;
if (rate > 50){
if ((rate > 50) && (strcmp(ffmpeg_video_codec, "swf") == 0)){
MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s The FPS could be too high for the SWF container. Consider other choices.");
}
}
@@ -671,18 +672,19 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){
my_packet_unref(pkt);
return -2;
}
}
if (ffmpeg->tlapse == TIMELAPSE_APPEND) {
retcd = timelapse_append(ffmpeg, pkt);
} else if (ffmpeg->tlapse == TIMELAPSE_NEW) {
retcd = av_write_frame(ffmpeg->oc, &pkt);
} else {
pts_interval = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec) + 10000;
pkt.pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base);
if (pkt.pts < 1) pkt.pts = 1;
pkt.dts = pkt.pts;
// MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d interval %d",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den,pts_interval);
}
if (ffmpeg->tlapse == TIMELAPSE_APPEND) {
retcd = timelapse_append(ffmpeg, pkt);
} else {
retcd = av_write_frame(ffmpeg->oc, &pkt);
}
// MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d interval %d",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den,pts_interval);
my_packet_unref(pkt);
if (retcd != 0) {