summaryrefslogtreecommitdiffstats
path: root/libhb/stream.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-12-23 00:02:17 +0000
committerjstebbins <[email protected]>2009-12-23 00:02:17 +0000
commit84683fb1af90f1b5887b0149fa7962b26f8ce87f (patch)
tree0a6f3d1d66d61bbe8f389b2892c0f8095e560ecc /libhb/stream.c
parent2252eabba54132b98b11c86f3457b2a9e307d645 (diff)
add point-to-point encoding
allows frame and pts based start points. end points were already previously supported. New job variables pts_to_start and frame_to_start specify the start point. There can be a period during the encode where it has to search for the start point. During this period, libhb sets a new state HB_STATE_SEARCHING and sets progress and eta till start point found. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3039 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r--libhb/stream.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index d1244f5ee..fc51b1b23 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -207,6 +207,7 @@ static void ffmpeg_close( hb_stream_t *d );
static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream );
static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf );
static int ffmpeg_seek( hb_stream_t *stream, float frac );
+static int ffmpeg_seek_ts( hb_stream_t *stream, int64_t ts );
/*
* streams have a bunch of state that's learned during the scan. We don't
@@ -1309,6 +1310,15 @@ int hb_stream_seek( hb_stream_t * stream, float f )
return 1;
}
+int hb_stream_seek_ts( hb_stream_t * stream, int64_t ts )
+{
+ if ( stream->hb_stream_type == ffmpeg )
+ {
+ return ffmpeg_seek_ts( stream, ts );
+ }
+ return -1;
+}
+
static const char* make_upper( const char* s )
{
static char name[8];
@@ -2983,3 +2993,16 @@ static int ffmpeg_seek( hb_stream_t *stream, float frac )
}
return 1;
}
+
+// Assumes that we are always seeking forward
+static int ffmpeg_seek_ts( hb_stream_t *stream, int64_t ts )
+{
+ AVFormatContext *ic = stream->ffmpeg_ic;
+ int64_t pos;
+
+ pos = ts * AV_TIME_BASE / 90000;
+ stream->need_keyframe = 1;
+ // Seek to the nearest timestamp before that requested where
+ // there is an I-frame
+ return av_seek_frame( ic, -1, pos, AVSEEK_FLAG_BACKWARD );
+}