mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
ffmpeg: don't use best_effort_timestamp #1352
This commit is contained in:
parent
b93915c2f5
commit
3603a2a661
@ -380,7 +380,7 @@ int ffmpeg_stream(notcurses* nc, ncvisual* ncv, float timescale,
|
|||||||
struct timespec begin; // time we started
|
struct timespec begin; // time we started
|
||||||
clock_gettime(CLOCK_MONOTONIC, &begin);
|
clock_gettime(CLOCK_MONOTONIC, &begin);
|
||||||
uint64_t nsbegin = timespec_to_ns(&begin);
|
uint64_t nsbegin = timespec_to_ns(&begin);
|
||||||
bool usets = false;
|
//bool usets = false;
|
||||||
// each frame has a pkt_duration in milliseconds. keep the aggregate, in case
|
// each frame has a pkt_duration in milliseconds. keep the aggregate, in case
|
||||||
// we don't have PTS available.
|
// we don't have PTS available.
|
||||||
uint64_t sum_duration = 0;
|
uint64_t sum_duration = 0;
|
||||||
@ -390,12 +390,14 @@ int ffmpeg_stream(notcurses* nc, ncvisual* ncv, float timescale,
|
|||||||
int ncerr;
|
int ncerr;
|
||||||
do{
|
do{
|
||||||
// codecctx seems to be off by a factor of 2 regularly. instead, go with
|
// codecctx seems to be off by a factor of 2 regularly. instead, go with
|
||||||
// the time_base from the avformatctx.
|
// the time_base from the avformatctx. except ts isn't properly reset for
|
||||||
|
// all media when we loop =[. we seem to be accurate enough now with the
|
||||||
|
// tbase/ppd. see https://github.com/dankamongmen/notcurses/issues/1352.
|
||||||
double tbase = av_q2d(ncv->details->fmtctx->streams[ncv->details->stream_index]->time_base);
|
double tbase = av_q2d(ncv->details->fmtctx->streams[ncv->details->stream_index]->time_base);
|
||||||
int64_t ts = ncv->details->frame->best_effort_timestamp;
|
/*int64_t ts = ncv->details->frame->best_effort_timestamp;
|
||||||
if(frame == 1 && ts){
|
if(frame == 1 && ts){
|
||||||
usets = true;
|
usets = true;
|
||||||
}
|
}*/
|
||||||
if(activevopts.n){
|
if(activevopts.n){
|
||||||
ncplane_erase(activevopts.n); // new frame could be partially transparent
|
ncplane_erase(activevopts.n); // new frame could be partially transparent
|
||||||
}
|
}
|
||||||
@ -418,15 +420,15 @@ int ffmpeg_stream(notcurses* nc, ncvisual* ncv, float timescale,
|
|||||||
uint64_t duration = ncv->details->frame->pkt_duration * tbase * NANOSECS_IN_SEC;
|
uint64_t duration = ncv->details->frame->pkt_duration * tbase * NANOSECS_IN_SEC;
|
||||||
//fprintf(stderr, "use: %u dur: %ju ts: %ju cctx: %f fctx: %f\n", usets, duration, ts, av_q2d(ncv->details->codecctx->time_base), av_q2d(ncv->details->fmtctx->streams[ncv->details->stream_index]->time_base));
|
//fprintf(stderr, "use: %u dur: %ju ts: %ju cctx: %f fctx: %f\n", usets, duration, ts, av_q2d(ncv->details->codecctx->time_base), av_q2d(ncv->details->fmtctx->streams[ncv->details->stream_index]->time_base));
|
||||||
double schedns = nsbegin;
|
double schedns = nsbegin;
|
||||||
if(usets){
|
/*if(usets){
|
||||||
if(tbase == 0){
|
if(tbase == 0){
|
||||||
tbase = duration;
|
tbase = duration;
|
||||||
}
|
}
|
||||||
schedns += ts * (tbase * timescale) * NANOSECS_IN_SEC;
|
schedns += ts * (tbase * timescale) * NANOSECS_IN_SEC;
|
||||||
}else{
|
}else{*/
|
||||||
sum_duration += (duration * timescale);
|
sum_duration += (duration * timescale);
|
||||||
schedns += sum_duration;
|
schedns += sum_duration;
|
||||||
}
|
//}
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
ns_to_timespec(schedns, &abstime);
|
ns_to_timespec(schedns, &abstime);
|
||||||
int r;
|
int r;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user