Skip to content

Commit 0cb16be

Browse files
committed
Assign PTS to the right frame
The PTS was read from the socket and set as the current one even before the frame was consumed, so it could be assigned to the previous frame "in advance". Store the PTS for the current frame and the last PTS read from the packet header of the next frame in separate fields. As a side-effect, this fixes the warning on quit: > Application provided invalid, non monotonically increasing dts to > muxer in stream 0: 17164020 >= 17164020
1 parent 2de0a9e commit 0cb16be

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/src/decoder.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size) {
4040

4141
remaining = decoder->remaining;
4242
if (remaining == 0) {
43+
// the previous PTS read is now for the current frame
44+
decoder->pts = decoder->next_pts;
45+
4346
// FIXME what if only half of the header is available?
4447
ret = net_recv(decoder->video_socket, header, HEADER_SIZE);
4548
if (ret <= 0)
4649
return ret;
4750

48-
decoder->pts = from_be(header, 8);
51+
// read the PTS for the next frame
52+
decoder->next_pts = from_be(header, 8);
4953
decoder->buffer_info_flags = from_be(header + 8, 4);
5054
remaining = from_be(header + 12, 4);
5155
}

app/src/decoder.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct decoder {
1515
SDL_Thread *thread;
1616
SDL_mutex *mutex;
1717
struct recorder *recorder;
18+
uint64_t next_pts;
1819
uint64_t pts;
1920
uint32_t buffer_info_flags;
2021
int remaining;

0 commit comments

Comments
 (0)