| 6579 | } |
| 6580 | |
| 6581 | static int ffmpeg_seek( hb_stream_t *stream, float frac ) |
| 6582 | { |
| 6583 | AVFormatContext *ic = stream->ffmpeg_ic; |
| 6584 | int res; |
| 6585 | if ( frac > 0. ) |
| 6586 | { |
| 6587 | int64_t pos = (double)stream->ffmpeg_ic->duration * (double)frac + |
| 6588 | ffmpeg_initial_timestamp( stream ); |
| 6589 | res = avformat_seek_file( ic, -1, 0, pos, pos, AVSEEK_FLAG_BACKWARD); |
| 6590 | if (res < 0) |
| 6591 | { |
| 6592 | hb_error("avformat_seek_file failed"); |
| 6593 | } |
| 6594 | } |
| 6595 | else |
| 6596 | { |
| 6597 | int64_t pos = ffmpeg_initial_timestamp( stream ); |
| 6598 | res = avformat_seek_file( ic, -1, 0, pos, pos, AVSEEK_FLAG_BACKWARD); |
| 6599 | if (res < 0) |
| 6600 | { |
| 6601 | hb_error("avformat_seek_file failed"); |
| 6602 | } |
| 6603 | } |
| 6604 | stream->need_keyframe = 1; |
| 6605 | return 1; |
| 6606 | } |
| 6607 | |
| 6608 | // Assumes that we are always seeking forward |
| 6609 | static int ffmpeg_seek_ts( hb_stream_t *stream, int64_t ts ) |
no test coverage detected