From da8b1c5c75031e180ef109b9c921f412e946cad4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 26 Apr 2010 19:32:40 +0300 Subject: [PATCH] make sure last frame gets saved --- oxframe.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/oxframe.c b/oxframe.c index fd19ac6..367fac4 100644 --- a/oxframe.c +++ b/oxframe.c @@ -153,12 +153,17 @@ int dump_frame_callback (OggPlay *player, int num_tracks, break; } long pt = oggplay_callback_info_get_presentation_time(headers[0]); - //printf("time: %ld\n", pt); + //printf("time: %ld %ld %ld\n", pt, duration, duration-pt); if (pt >= frame_pos) { - video_data = oggplay_callback_info_get_video_data(headers[0]); - write_frame(player, i, video_data); - exit(0); + video_data = oggplay_callback_info_get_video_data(headers[0]); + write_frame(player, i, video_data); + exit(0); + } else if (duration-pt < 500) { + video_data = oggplay_callback_info_get_video_data(headers[0]); + write_frame(player, i, video_data); + } + break; default: break; @@ -229,10 +234,12 @@ int main (int argc, char * argv[]) { max_num = 1 << granuleshift; offset = (1000 * max_num * fps_denom) / fps_num; - /* duration = oggplay_get_duration(player); - fprintf(stderr, "seek to: %ld duration: %ld\n", frame_pos, (long)duration); - */ + + if (frame_pos > duration) { + fprintf (stderr, "can not seek to frame later than duration\n"); + exit (1); + } if(frame_pos - offset > 0) { if (oggplay_seek(player, frame_pos - offset) == E_OGGPLAY_CANT_SEEK) { @@ -241,6 +248,7 @@ int main (int argc, char * argv[]) { } } oggplay_start_decoding(player); + oggplay_close (player); return 0;