I am working on a player that needs to be able to seek frame-acurrate. My approach is to seek use av_seek_frame and then decode more packets until I reach the pts I am looking for. This works more or less for frames that are not flushed from cache.
Optimally I would like to be able to seek also into the last frames/packets that are flushed from the cache (like in line 290 in the demuxing example (https://ffmpeg.org/doxygen/trunk/demuxing_8c_source.html#l00290 <https://ffmpeg.org/doxygen/trunk/demuxing_8c_source.html#l00290>)). The problem here is that the pts of these last decoded packets seems to be -9223372036854775808. So they themselves do not give me a timestamp I can work on after seeking. Is there any way of fixing that? Cheers, Peter PS Output of a slightly modified demuxing_decoding.c example, where I inserted prints to check the dts and pts of the video file: /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) { AVPacket orig_pkt = pkt; do { ret = decode_packet(&got_frame, 0); if (ret < 0) break; pkt.data += ret; pkt.size -= ret; printf("packet dts: '%d' \n", pkt.dts); printf("packet pts: '%d' \n", pkt.pts); } while (pkt.size > 0); av_free_packet(&orig_pkt); } /* flush cached frames */ pkt.data = NULL; pkt.size = 0; do { decode_packet(&got_frame, 1); printf("frame number: '%d' \n", frame->coded_picture_number); printf("packet dts: '%d' \n", pkt.dts); printf("packet pts: '%d' \n", pkt.pts); } while (got_frame); printf("Demuxing succeeded.\n”); You can see that as soon as the frames are flushed at the end (frame 996 and onwards), dts and pts go to 0. packet dts: '0' packet pts: '0' packet dts: '512' packet pts: '512' packet dts: '1024' packet pts: '1024' packet dts: '1536' packet pts: '1536' video_frame n:0 coded_n:0 pts:NOPTS packet dts: '2048' packet pts: '2048' video_frame n:1 coded_n:1 pts:NOPTS packet dts: '2560' packet pts: '2560' video_frame n:2 coded_n:2 pts:NOPTS packet dts: '3072' packet pts: '3072' video_frame n:3 coded_n:3 pts:NOPTS packet dts: '3584' packet pts: '3584' video_frame n:4 coded_n:4 pts:NOPTS .. video_frame n:990 coded_n:990 pts:NOPTS packet dts: '508928' packet pts: '508928' video_frame n:991 coded_n:991 pts:NOPTS packet dts: '509440' packet pts: '509440' video_frame n:992 coded_n:992 pts:NOPTS packet dts: '509952' packet pts: '509952' video_frame n:993 coded_n:993 pts:NOPTS packet dts: '510464' packet pts: '510464' video_frame n:994 coded_n:994 pts:NOPTS packet dts: '510976' packet pts: '510976' video_frame n:995 coded_n:995 pts:NOPTS packet dts: '511488' packet pts: '511488' video_frame(cached) n:996 coded_n:996 pts:NOPTS frame number: '996' packet dts: '0' packet pts: '0' video_frame(cached) n:997 coded_n:997 pts:NOPTS frame number: '997' packet dts: '0' packet pts: '0' video_frame(cached) n:998 coded_n:998 pts:NOPTS frame number: '998' packet dts: '0' packet pts: '0' video_frame(cached) n:999 coded_n:999 pts:NOPTS frame number: '999' packet dts: '0' packet pts: '0' frame number: '0' packet dts: '0' packet pts: '0' Demuxing succeeded. _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user