av_seek_frame not working for .wmv, .mp4

Any other question that don't fit into the other support categorizes.
Post Reply
ganeshmundhe007
Posts: 3
Joined: Mon Jul 30, 2018 8:46 am

av_seek_frame not working for .wmv, .mp4

Post by ganeshmundhe007 » Mon Jul 30, 2018 8:57 am

I have been decoding video for a while.
Now i want to decode from start offset similar to (-ss) option from ffmpeg
i have tried av_seek_frame but it works only for .avi and raw video format(.y4m)

With time to timestamp

Code: Select all

double t = 7;//time in seconds
	int64_t timestamp = t * AV_TIME_BASE; //destination time
										
	AVRational r = av_make_q(1, AV_TIME_BASE);
	if (VideoStreamIndex >= 0) {
		timestamp = av_rescale_q(timestamp, r,
			fmt_ctx->streams[VideoStreamIndex]->time_base);
	}
	 av_seek_frame(fmt_ctx,-1, t * AV_TIME_BASE, AVSEEK_FLAG_ANY);
or
	av_seek_frame(fmt_ctx, VideoStreamIndex, timestamp, AVSEEK_FLAG_ANY);
With frame no

Code: Select all

 int frameNo = 300; //should <total no of frames ~= Duration * fps
			
	int64_t point = (int64_t(frameNo) * pavStream->r_frame_rate.den *  pavStream->time_base.den) / (int64_t(pavStream->r_frame_rate.num) *pavStream->time_base.num);
	av_seek_frame(fmt_ctx,VideoStreamIndex, point, AVSEEK_FLAG_ANY); 
But both ways failing for .mp4(h264) wmv video files

Need Help!

Post Reply