int FFVideoStream::load(VFrame *vframe, int64_t pos)
{
- if( video_seek(pos) < 0 ) return -1;
+ int ret = video_seek(pos);
+ if( ret < 0 ) return -1;
if( !frame && !(frame=av_frame_alloc()) ) {
fprintf(stderr, "FFVideoStream::load: av_frame_alloc failed\n");
return -1;
}
- int ret = 0;
for( int i=0; ret>=0 && !flushed && curr_pos<=pos && i<1000; ++i ) {
ret = read_frame(frame);
}
if( gop < 4 ) gop = 4;
if( gop > 64 ) gop = 64;
if( pos >= curr_pos && pos <= curr_pos + gop ) return 0;
+ if( pos == curr_pos-1 && curr_pos > seek_pos ) return 1;
if( !st->codec || !st->codec->codec ) return -1;
avcodec_flush_buffers(st->codec);
// back up a few frames to read up to current to help repair damages
return (AVRational){1, sample_rate};
}
-extern void get_exe_path(char *result); // from main.C
-
void FFMPEG::set_option_path(char *path, const char *fmt, ...)
{
get_exe_path(path);
return ret;
}
-int FFMPEG::scan_options(const char *options, AVDictionary *&opts)
+int FFMPEG::scan_options(const char *options, AVDictionary *&opts, AVStream *st)
{
FILE *fp = fmemopen((void *)options,strlen(options),"r");
if( !fp ) return 0;
int ret = read_options(fp, options, opts);
fclose(fp);
+ AVDictionaryEntry *tag = av_dict_get(opts, "id", NULL, 0);
+ if( tag ) st->id = strtol(tag->value,0,0);
return ret;
}
break;
}
has_audio = 1;
- if( scan_options(asset->ff_audio_options, sopts) ) {
+ if( scan_options(asset->ff_audio_options, sopts, st) ) {
eprintf("FFMPEG::open_encoder: bad audio options %s:%s\n",
codec_name, filename);
ret = 1;
break;
}
has_video = 1;
- if( scan_options(asset->ff_video_options, sopts) ) {
+ if( scan_options(asset->ff_video_options, sopts, st) ) {
eprintf("FFMPEG::open_encoder: bad video options %s:%s\n",
codec_name, filename);
ret = 1;