make sure last frame gets saved
This commit is contained in:
parent
5baabca5c8
commit
da8b1c5c75
1 changed files with 15 additions and 7 deletions
22
oxframe.c
22
oxframe.c
|
@ -153,12 +153,17 @@ int dump_frame_callback (OggPlay *player, int num_tracks,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long pt = oggplay_callback_info_get_presentation_time(headers[0]);
|
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) {
|
if (pt >= frame_pos) {
|
||||||
video_data = oggplay_callback_info_get_video_data(headers[0]);
|
video_data = oggplay_callback_info_get_video_data(headers[0]);
|
||||||
write_frame(player, i, video_data);
|
write_frame(player, i, video_data);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
} else if (duration-pt < 500) {
|
||||||
|
video_data = oggplay_callback_info_get_video_data(headers[0]);
|
||||||
|
write_frame(player, i, video_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -229,10 +234,12 @@ int main (int argc, char * argv[]) {
|
||||||
max_num = 1 << granuleshift;
|
max_num = 1 << granuleshift;
|
||||||
offset = (1000 * max_num * fps_denom) / fps_num;
|
offset = (1000 * max_num * fps_denom) / fps_num;
|
||||||
|
|
||||||
/*
|
|
||||||
duration = oggplay_get_duration(player);
|
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(frame_pos - offset > 0) {
|
||||||
if (oggplay_seek(player, frame_pos - offset) == E_OGGPLAY_CANT_SEEK) {
|
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_start_decoding(player);
|
||||||
|
|
||||||
oggplay_close (player);
|
oggplay_close (player);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue