Revision 6bcafa93

View differences:

libav/grab.c
32 32
    int width, height;
33 33
    int frame_rate;
34 34
    INT64 time_frame;
35
    INT64 time_frame_start;
36 35
    int frame_size;
37 36
    struct video_capability video_cap;
38 37
    struct video_audio audio_saved;
......
241 240
    st->codec.height = height;
242 241
    st->codec.frame_rate = frame_rate;
243 242
    
244
    s->time_frame_start = s->time_frame;
245

  
246 243
    av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in us */
247 244

  
248 245
    return 0;
......
285 282
    INT64 curtime, delay;
286 283
    struct timespec ts;
287 284
    INT64 per_frame = (INT64_C(1000000) * FRAME_RATE_BASE) / s->frame_rate;
288
    int dropped = 0;
289 285

  
290 286
    /* Calculate the time of the next frame */
291 287
    s->time_frame += per_frame;
......
297 293
        if (delay <= 0) {
298 294
            if (delay < -per_frame) {
299 295
                /* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
300
                dropped = 1;
301 296
                s->time_frame += per_frame;
302 297
            }
303 298
            break;
......
312 307

  
313 308
    pkt->pts = curtime & ((1LL << 48) - 1);
314 309

  
315
    if (dropped)
316
        pkt->flags |= PKT_FLAG_DROPPED_FRAME;
317

  
318
    pkt->pts = (s->time_frame - s->time_frame_start) * s1->pts_den / ((INT64)s1->pts_num * 1000000);
319

  
320
    //printf("setting pkt->pts=%lld (time_frame=%lld)\n", pkt->pts, s->time_frame);
321

  
322 310
    /* read one frame */
323 311
    if (s->aiw_enabled) {
324 312
        return aiw_read_picture(s, pkt->data);

Also available in: Unified diff