/* compute nominal last_duration */
last_duration = vp->pts - is->frame_last_pts;
- if (last_duration > 0 && last_duration < is->max_frame_duration) {
+ if (!isnan(last_duration) && last_duration > 0 && last_duration < is->max_frame_duration) {
/* if duration of the last frame was sane, update last_duration in video state */
is->frame_last_duration = last_duration;
}
is->frame_timer += delay * FFMAX(1, floor((time-is->frame_timer) / delay));
SDL_LockMutex(is->pictq_mutex);
- update_video_pts(is, vp->pts, vp->pos, vp->serial);
+ if (!isnan(vp->pts))
+ update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq_mutex);
if (is->pictq_size > 1) {
vp = &is->pictq[is->pictq_windex];
-#if CONFIG_AVFILTER
vp->sar = src_frame->sample_aspect_ratio;
-#else
- vp->sar = av_guess_sample_aspect_ratio(is->ic, is->video_st, src_frame);
-#endif
/* alloc or resize hardware picture buffer */
if (!vp->bmp || vp->reallocate || !vp->allocated ||
if (got_picture) {
int ret = 1;
+ double dpts = NAN;
if (decoder_reorder_pts == -1) {
frame->pts = av_frame_get_best_effort_timestamp(frame);
frame->pts = frame->pkt_dts;
}
- if (frame->pts == AV_NOPTS_VALUE) {
- frame->pts = 0;
- }
+ if (frame->pts != AV_NOPTS_VALUE)
+ dpts = av_q2d(is->video_st->time_base) * frame->pts;
+
+ frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame);
if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) {
SDL_LockMutex(is->pictq_mutex);
- if (is->frame_last_pts != AV_NOPTS_VALUE && frame->pts) {
+ if (is->frame_last_pts != AV_NOPTS_VALUE && frame->pts != AV_NOPTS_VALUE) {
double clockdiff = get_video_clock(is) - get_master_clock(is);
- double dpts = av_q2d(is->video_st->time_base) * frame->pts;
double ptsdiff = dpts - is->frame_last_pts;
if (!isnan(clockdiff) && fabs(clockdiff) < AV_NOSYNC_THRESHOLD &&
- ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD &&
- clockdiff + ptsdiff - is->frame_last_filter_delay < 0) {
+ !isnan(ptsdiff) && ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD &&
+ clockdiff + ptsdiff - is->frame_last_filter_delay < 0 &&
+ is->videoq.nb_packets) {
is->frame_last_dropped_pos = pkt->pos;
is->frame_last_dropped_pts = dpts;
is->frame_last_dropped_serial = *serial;
last_serial = serial;
}
- frame->sample_aspect_ratio = av_guess_sample_aspect_ratio(is->ic, is->video_st, frame);
ret = av_buffersrc_add_frame(filt_in, frame);
if (ret < 0)
goto the_end;
if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0)
is->frame_last_filter_delay = 0;
- pts = frame->pts * av_q2d(filt_out->inputs[0]->time_base);
+ pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(filt_out->inputs[0]->time_base);
ret = queue_picture(is, frame, pts, av_frame_get_pkt_pos(frame), serial);
av_frame_unref(frame);
}
#else
- pts = frame->pts * av_q2d(is->video_st->time_base);
+ pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(is->video_st->time_base);
ret = queue_picture(is, frame, pts, pkt.pos, serial);
av_frame_unref(frame);
#endif
int out_count = (int64_t)wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate + 256;
int out_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, out_count, is->audio_tgt.fmt, 0);
int len2;
+ if (out_size < 0) {
+ fprintf(stderr, "av_samples_get_buffer_size() failed\n");
+ break;
+ }
if (wanted_nb_samples != is->frame->nb_samples) {
if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate,
wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) {
is->max_frame_duration = (ic->iformat->flags & AVFMT_TS_DISCONT) ? 10.0 : 3600.0;
+ if (!window_title && (t = av_dict_get(ic->metadata, "title", NULL, 0)))
+ window_title = av_asprintf("%s - %s", t->value, input_filename);
+
/* if seeking requested, we execute it */
if (start_time != AV_NOPTS_VALUE) {
int64_t timestamp;
}
av_init_packet(&flush_pkt);
- flush_pkt.data = (char *)(intptr_t)"FLUSH";
+ flush_pkt.data = (uint8_t *)&flush_pkt;
is = stream_open(input_filename, file_iformat);
if (!is) {