Skip to content

Commit

Permalink
- use abs(dts - sample.dts) as min function
Browse files Browse the repository at this point in the history
- fix file_streamer.c created time during ts jump
  • Loading branch information
igorshevach committed Nov 12, 2023
1 parent 51c2da9 commit 4beda2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion transcoder/debug/file_streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void* thread_stream_from_file(void *vargp)
AVStream *in_stream=ifmt_ctx->streams[packet.stream_index];

av_packet_rescale_ts(&packet,in_stream->time_base, standard_timebase);
packet.pos=createTime +packet.dts;
if(jumpOffsetSec != 0 ) {
const auto jumpOffset = jumpOffsetSec * standard_timebase.den;
if(AV_NOPTS_VALUE == jumpAtTimestamp) {
Expand All @@ -124,7 +125,7 @@ void* thread_stream_from_file(void *vargp)
}
packet.pts+=cumulativeDuration;
packet.dts+=cumulativeDuration;
packet.pos=createTime +packet.dts;

if (duration!=-1) {
if (packet.dts>=duration) {
LOGGER(CATEGORY_DEFAULT,AV_LOG_INFO,"Duration exceeded %s>=%s, terminating!",pts2str(packet.dts),pts2str(duration));
Expand Down
8 changes: 6 additions & 2 deletions transcoder/utils/time_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ uint64_t clock_estimator_get_clock(clock_estimator_t *fifo,int64_t dts)
int64_t clock=0;
for (int64_t runner=fifo->framesFifoHead;runner>=fifo->framesFifoTail;runner--) {
clock_estimator_sample_t* sample=&(fifo->samples[runner % TIME_ESTIMATOR_FIFO_SIZE]);
int64_t runnerdistance=llabs(sample->dts);
//LOGGER(CATEGORY_CLOCK_ESTIMATOR,AV_LOG_DEBUG,"runnerdistance %ld distance %ld",runnerdistance,distance);
int64_t runnerdistance=llabs(dts - sample->dts);
LOGGER(CATEGORY_CLOCK_ESTIMATOR,AV_LOG_DEBUG,"runnerdistance %ld distance %ld dts %s cur_dts %s",
runnerdistance,
distance,
pts2str(dts),
pts2str(sample->dts));
if (runnerdistance<distance) {
clock= dts - sample->dts + sample->clock;
distance=runnerdistance;
Expand Down

0 comments on commit 4beda2c

Please sign in to comment.