[Libav-user] AV_SEEK_FRAME failing for compressed formats like .wmv .mp4

MUNDHE Ganesh Ganesh.MUNDHE at 3ds.com
Tue Jul 24 10:25:17 EEST 2018

Hello all,

I have been trying to decode videos where I need to offset start position.
I have tried to use AV_seek_frame but it works on raw video format (.y4m) but fails on mpeg2 compressed formats.
Generally videos are in mp4 or wmv and I need to write for those directly instead of converting them into .y4m
Here how I'm using it

//When using with time
       double t = 5;//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,

       av_seek_frame(fmt_ctx, VideoStreamIndex, timestamp, AVSEEK_FLAG_ANY);
if I know the frame no

int frmaeno = 100;
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, 0);

Tried with avformat_seek_file api too but still failing.
Need help here.

Thanks & Warm Regards,

This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180724/1d386a6e/attachment.html>

More information about the Libav-user mailing list