Revision a38469e1

View differences:

ffmpeg.c
97 97
static char *str_comment = NULL;
98 98
static int do_benchmark = 0;
99 99
static int do_hex_dump = 0;
100
static int do_play = 0;
100 101

  
101 102
typedef struct AVOutputStream {
102 103
    int file_index;          /* file index */
......
188 189
    return -1;
189 190
}
190 191

  
191
#define AUDIO_FIFO_SIZE 8192
192
#else
192 193

  
193
/* main loop for grabbing */
194
int av_grab(AVFormatContext *s)
194
/* no interactive support */
195
static void term_exit(void)
195 196
{
196
    UINT8 audio_buf[AUDIO_FIFO_SIZE];
197
    UINT8 audio_buf1[AUDIO_FIFO_SIZE];
198
    UINT8 audio_out[AUDIO_FIFO_SIZE];
199
    UINT8 video_buffer[1024*1024];
200
    char buf[256];
201
    short *samples;
202
    URLContext *audio_handle = NULL, *video_handle = NULL;
203
    int ret;
204
    AVCodecContext *enc, *first_video_enc = NULL;
205
    int frame_size, frame_bytes;
206
    int use_audio, use_video;
207
    int frame_rate, sample_rate, channels;
208
    int width, height, frame_number, i, pix_fmt = 0;
209
    AVOutputStream *ost_table[s->nb_streams], *ost;
210
    UINT8 *picture_in_buf = NULL, *picture_420p = NULL;
211
    int audio_fifo_size = 0, picture_size = 0;
212
    INT64 time_start;
213

  
214
    /* init output stream info */
215
    for(i=0;i<s->nb_streams;i++)
216
        ost_table[i] = NULL;
217

  
218
    /* output stream init */
219
    for(i=0;i<s->nb_streams;i++) {
220
        ost = av_mallocz(sizeof(AVOutputStream));
221
        if (!ost)
222
            goto fail;
223
        ost->index = i;
224
        ost->st = s->streams[i];
225
        ost_table[i] = ost;
226
    }
227

  
228
    use_audio = 0;
229
    use_video = 0;
230
    frame_rate = 0;
231
    sample_rate = 0;
232
    frame_size = 0;
233
    channels = 1;
234
    width = 0;
235
    height = 0;
236
    frame_number = 0;
237
    
238
    for(i=0;i<s->nb_streams;i++) {
239
        AVCodec *codec;
240

  
241
        ost = ost_table[i];
242
        enc = &ost->st->codec;
243
        codec = avcodec_find_encoder(enc->codec_id);
244
        if (!codec) {
245
            fprintf(stderr, "Unknown codec\n");
246
            return -1;
247
        }
248
        if (avcodec_open(enc, codec) < 0) {
249
            fprintf(stderr, "Incorrect encode parameters\n");
250
            return -1;
251
        }
252
        switch(enc->codec_type) {
253
        case CODEC_TYPE_AUDIO:
254
            use_audio = 1;
255
            if (enc->sample_rate > sample_rate)
256
                sample_rate = enc->sample_rate;
257
            if (enc->frame_size > frame_size)
258
                frame_size = enc->frame_size;
259
            if (enc->channels > channels)
260
                channels = enc->channels;
261
            break;
262
        case CODEC_TYPE_VIDEO:
263
            if (!first_video_enc)
264
                first_video_enc = enc;
265
            use_video = 1;
266
            if (enc->frame_rate > frame_rate)
267
                frame_rate = enc->frame_rate;
268
            if (enc->width > width)
269
                width = enc->width;
270
            if (enc->height > height)
271
                height = enc->height;
272
            break;
273
        }
274
    }
275

  
276
    /* audio */
277
    samples = NULL;
278
    if (use_audio) {
279
        snprintf(buf, sizeof(buf), "audio:%d,%d", sample_rate, channels);
280
        ret = url_open(&audio_handle, buf, URL_RDONLY);
281
        if (ret < 0) {
282
            fprintf(stderr, "Could not open audio device: disabling audio capture\n");
283
            use_audio = 0;
284
        } else {
285
            URLFormat f;
286
            /* read back exact grab parameters */
287
            if (url_getformat(audio_handle, &f) < 0) {
288
                fprintf(stderr, "could not read back video grab parameters\n");
289
                goto fail;
290
            }
291
            sample_rate = f.sample_rate;
292
            channels = f.channels;
293
            audio_fifo_size = ((AUDIO_FIFO_SIZE / 2) / audio_handle->packet_size) * 
294
                audio_handle->packet_size;
295
            fprintf(stderr, "Audio sampling: %d Hz, %s\n", 
296
                    sample_rate, channels == 2 ? "stereo" : "mono");
297
        }
298
    }
299
    
300
    /* video */
301
    if (use_video) {
302
        snprintf(buf, sizeof(buf), "video:%d,%d,%f", 
303
                 width, height, (float)frame_rate / FRAME_RATE_BASE);
304

  
305
        ret = url_open(&video_handle, buf, URL_RDONLY);
306
        if (ret < 0) {
307
            fprintf(stderr,"Could not init video 4 linux capture: disabling video capture\n");
308
            use_video = 0;
309
        } else {
310
            URLFormat f;
311
            const char *pix_fmt_str;
312
            /* read back exact grab parameters */
313
            if (url_getformat(video_handle, &f) < 0) {
314
                fprintf(stderr, "could not read back video grab parameters\n");
315
                goto fail;
316
            }
317
            width = f.width;
318
            height = f.height;
319
            pix_fmt = f.pix_fmt;
320
            switch(pix_fmt) {
321
            case PIX_FMT_YUV420P:
322
                pix_fmt_str = "420P";
323
                break;
324
            case PIX_FMT_YUV422:
325
                pix_fmt_str = "422";
326
                break;
327
            case PIX_FMT_RGB24:
328
                pix_fmt_str = "RGB24";
329
                break;
330
            case PIX_FMT_BGR24:
331
                pix_fmt_str = "BGR24";
332
                break;
333
            default:
334
                pix_fmt_str = "???";
335
                break;
336
            }
337
            picture_size = video_handle->packet_size;
338
            picture_in_buf = malloc(picture_size);
339
            if (!picture_in_buf)
340
                goto fail;
341
            /* allocate a temporary picture if not grabbing in 420P format */
342
            if (pix_fmt != PIX_FMT_YUV420P) {
343
                picture_420p = malloc((width * height * 3) / 2);
344
            }
345
            fprintf(stderr, "Video sampling: %dx%d, %s format, %0.2f fps\n", 
346
                    width, height, pix_fmt_str, (float)frame_rate / FRAME_RATE_BASE);
347
        }
348
    }
349

  
350
    if (!use_video && !use_audio) {
351
        fprintf(stderr,"Could not open grab devices : exiting\n");
352
        exit(1);
353
    }
354

  
355
    /* init built in conversion functions */
356
    for(i=0;i<s->nb_streams;i++) {
357
        ost = ost_table[i];
358
        enc = &ost->st->codec;
359
        switch(enc->codec_type) {
360
        case CODEC_TYPE_AUDIO:
361
            ost->audio_resample = 0;
362
            if ((enc->channels != channels ||
363
                 enc->sample_rate != sample_rate)) {
364
                ost->audio_resample = 1;
365
                ost->resample = audio_resample_init(enc->channels, channels,
366
                                                    enc->sample_rate, sample_rate);
367
            }
368
            if (fifo_init(&ost->fifo, (2 * audio_fifo_size * enc->sample_rate *
369
                                       enc->channels) / sample_rate))
370
                goto fail;
371
            break;
372
        case CODEC_TYPE_VIDEO:
373
            ost->video_resample = 0;
374
            if (enc->width != width ||
375
                enc->height != height) {
376
                UINT8 *buf;
377
                ost->video_resample = 1;
378
                buf = malloc((enc->width * enc->height * 3) / 2);
379
                if (!buf)
380
                    goto fail;
381
                ost->pict_tmp.data[0] = buf;
382
                ost->pict_tmp.data[1] = buf + enc->width * height;
383
                ost->pict_tmp.data[2] = ost->pict_tmp.data[1] + (enc->width * height) / 4;
384
                ost->pict_tmp.linesize[0] = enc->width;
385
                ost->pict_tmp.linesize[1] = enc->width / 2;
386
                ost->pict_tmp.linesize[2] = enc->width / 2;
387
                ost->img_resample_ctx = img_resample_init(
388
                                  ost->st->codec.width, ost->st->codec.height,
389
                                  width, height);
390
            }
391
        }
392
    }
393

  
394
    fprintf(stderr, "Press [q] to stop encoding\n");
395

  
396
    s->format->write_header(s);
397
    time_start = gettime();
398
    term_init();
399
    
400
    for(;;) {
401
        /* if 'q' pressed, exits */
402
        if (read_key() == 'q')
403
            break;
404

  
405
        /* read & compress audio frames */
406
        if (use_audio) {
407
            int ret, nb_samples, nb_samples_out;
408
            UINT8 *buftmp;
409

  
410
            for(;;) {
411
                ret = url_read(audio_handle, audio_buf, audio_fifo_size);
412
                if (ret <= 0)
413
                    break;
414
                /* fill each codec fifo by doing the right sample
415
                   rate conversion. This is not optimal because we
416
                   do too much work, but it is easy to do */
417
                nb_samples = ret / (channels * 2);
418
                for(i=0;i<s->nb_streams;i++) {
419
                    ost = ost_table[i];
420
                    enc = &ost->st->codec;
421
                    if (enc->codec_type == CODEC_TYPE_AUDIO) {
422
                        /* rate & stereo convertion */
423
                        if (!ost->audio_resample) {
424
                            buftmp = audio_buf;
425
                            nb_samples_out = nb_samples;
426
                        } else {
427
                            buftmp = audio_buf1;
428
                            nb_samples_out = audio_resample(ost->resample, 
429
                                                            (short *)buftmp, (short *)audio_buf,
430
                                                            nb_samples);
431
                        }
432
                        fifo_write(&ost->fifo, buftmp, nb_samples_out * enc->channels * 2, 
433
                                   &ost->fifo.wptr);
434
                    }
435
                }
436
                
437
                /* compress as many frame as possible with each audio codec */
438
                for(i=0;i<s->nb_streams;i++) {
439
                    ost = ost_table[i];
440
                    enc = &ost->st->codec;
441
                    if (enc->codec_type == CODEC_TYPE_AUDIO) {
442
                        frame_bytes = enc->frame_size * 2 * enc->channels;
443
                        
444
                        while (fifo_read(&ost->fifo, audio_buf, 
445
                                         frame_bytes, &ost->fifo.rptr) == 0) {
446
                            ret = avcodec_encode_audio(enc,
447
                                                       audio_out, sizeof(audio_out), 
448
                                                       (short *)audio_buf);
449
                            s->format->write_packet(s, ost->index, audio_out, ret);
450
                        }
451
                    }
452
                }
453
            }
454
        }
455

  
456
        if (use_video) {
457
            AVPicture *picture1, *picture2, *picture;
458
            AVPicture picture_tmp0, picture_tmp1;
459

  
460
            ret = url_read(video_handle, picture_in_buf, picture_size);
461
            if (ret < 0)
462
                break;
463
            
464
            picture2 = &picture_tmp0;
465
            avpicture_fill(picture2, picture_in_buf, pix_fmt, width, height);
466

  
467
            if (pix_fmt != PIX_FMT_YUV420P) {
468
                picture = &picture_tmp1;
469
                avpicture_fill(picture, picture_420p, 
470
                               PIX_FMT_YUV420P, width, height);
471
                img_convert(picture, PIX_FMT_YUV420P,
472
                            picture2, pix_fmt, 
473
                            width, height);
474
            } else {
475
                picture = picture2;
476
            }
477
            
478
            for(i=0;i<s->nb_streams;i++) {
479
                ost = ost_table[i];
480
                enc = &ost->st->codec;
481
                if (enc->codec_type == CODEC_TYPE_VIDEO) {
482
                    int n1, n2, nb;
483

  
484
                    /* feed each codec with its requested frame rate */
485
                    n1 = ((INT64)frame_number * enc->frame_rate) / frame_rate;
486
                    n2 = (((INT64)frame_number + 1) * enc->frame_rate) / frame_rate;
487
                    nb = n2 - n1;
488
                    if (nb > 0) {
489
                        /* resize the picture if needed */
490
                        if (ost->video_resample) {
491
                            picture1 = &ost->pict_tmp;
492
                            img_resample(ost->img_resample_ctx, 
493
                                         picture1, picture);
494
                        } else {
495
                            picture1 = picture;
496
                        }
497
                        ret = avcodec_encode_video(enc, video_buffer, 
498
                                                   sizeof(video_buffer), 
499
                                                   picture1);
500
                        s->format->write_packet(s, ost->index, video_buffer, ret);
501
                    }
502
                }
503
            }
504
            frame_number++;
505
        }
506
        
507
        /* write report */
508
        {
509
            char buf[1024];
510
            INT64 total_size;
511
            float ti, bitrate;
512
            static float last_ti;
513
            INT64 ti1;
514

  
515
            total_size = url_ftell(&s->pb);
516
            ti1 = gettime() - time_start;
517
            /* check elapsed time */
518
            if (recording_time && ti1 >= recording_time)
519
                break;
520

  
521
            ti = ti1 / 1000000.0;
522
            if (ti < 0.1)
523
                ti = 0.1;
524
            /* dispaly twice per second */
525
            if ((ti - last_ti) >= 0.5) {
526
                last_ti = ti;
527
                bitrate = (int)((total_size * 8) / ti / 1000.0);
528
                
529
                buf[0] = '\0';
530
                if (use_video) {
531
                    sprintf(buf + strlen(buf), "frame=%5d fps=%4.1f q=%2d ",
532
                            frame_number, (float)frame_number / ti, first_video_enc->quality);
533
                }
534
                
535
                sprintf(buf + strlen(buf), "size=%8LdkB time=%0.1f bitrate=%6.1fkbits/s", 
536
                        total_size / 1024, ti, bitrate);
537
                fprintf(stderr, "%s    \r", buf);
538
                fflush(stderr);
539
            }
540
        }
541
    }
542
    term_exit();
543

  
544
    for(i=0;i<s->nb_streams;i++) {
545
        ost = ost_table[i];
546
        enc = &ost->st->codec;
547
        avcodec_close(enc);
548
    }
549
    s->format->write_trailer(s);
550
    
551
    if (audio_handle)
552
        url_close(audio_handle);
553

  
554
    if (video_handle)
555
        url_close(video_handle);
556

  
557
    /* write report */
558
    {
559
        float ti, bitrate;
560
        INT64 total_size;
561

  
562
        total_size = url_ftell(&s->pb);
563

  
564
        ti = (gettime() - time_start) / 1000000.0;
565
        if (ti < 0.1)
566
            ti = 0.1;
567
        bitrate = (int)((total_size * 8) / ti / 1000.0);
197
}
568 198

  
569
        fprintf(stderr, "\033[K\nTotal time = %0.1f s, %Ld KBytes, %0.1f kbits/s\n", 
570
                ti, total_size / 1024, bitrate);
571
        if (use_video) {
572
            fprintf(stderr, "Total frames = %d\n", frame_number);
573
        }
574
    }
199
static void term_init(void)
200
{
201
}
575 202

  
576
    ret = 0;
577
 fail1:
578
    if (picture_in_buf)
579
        free(picture_in_buf);
580
    if (picture_420p)
581
        free(picture_420p);
582
    for(i=0;i<s->nb_streams;i++) {
583
        ost = ost_table[i];
584
        if (ost) {
585
            if (ost->fifo.buffer)
586
                fifo_free(&ost->fifo);
587
            if (ost->pict_tmp.data[0])
588
                free(ost->pict_tmp.data[0]);
589
            if (ost->video_resample)
590
                img_resample_close(ost->img_resample_ctx);
591
            if (ost->audio_resample)
592
                audio_resample_close(ost->resample);
593
            free(ost);
594
        }
595
    }
596
    return ret;
597
 fail:
598
    ret = -ENOMEM;
599
    goto fail1;
203
static int read_key(void)
204
{
205
    return -1;
600 206
}
601 207

  
602
#endif /* CONFIG_WIN32 */
208
#endif
603 209

  
604 210
int read_ffserver_streams(AVFormatContext *s, const char *filename)
605 211
{
606 212
    int i;
607 213
    AVFormatContext *ic;
608 214

  
609
    ic = av_open_input_file(filename, FFM_PACKET_SIZE);
215
    ic = av_open_input_file(filename, NULL, FFM_PACKET_SIZE, NULL);
610 216
    if (!ic)
611 217
        return -EIO;
612 218
    /* copy stream format */
......
1156 762
    /* open files and write file headers */
1157 763
    for(i=0;i<nb_output_files;i++) {
1158 764
        os = output_files[i];
1159
        os->format->write_header(os);
765
        if (os->format->write_header(os) < 0) {
766
            fprintf(stderr, "Could not write header for output file #%d (incorrect codec paramters ?)\n", i);
767
            ret = -EINVAL;
768
            goto fail;
769
        }
1160 770
    }
1161 771

  
772
#ifndef CONFIG_WIN32
773
    if (!do_play) {
774
        fprintf(stderr, "Press [q] to stop encoding\n");
775
    } else {
776
        fprintf(stderr, "Press [q] to stop playing\n");
777
    }
778
#endif
779
    term_init();
780

  
1162 781
    start_time = gettime();
1163 782
    min_pts = 0;
1164 783
    for(;;) {
......
1171 790
        AVPicture picture;
1172 791
        short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
1173 792

  
1174
        /* select the input file with the smallest pts */
1175 793
    redo:
794
        /* if 'q' pressed, exits */
795
        if (read_key() == 'q')
796
            break;
797

  
798
        /* select the input file with the smallest pts */
1176 799
        file_index = -1;
1177 800
        min_pts = MAXINT64;
1178 801
        for(i=0;i<nb_istreams;i++) {
......
1189 812
        if (recording_time > 0 && min_pts >= recording_time)
1190 813
            break;
1191 814
        /* read a packet from it and output it in the fifo */
1192
        
1193 815
        is = input_files[file_index];
1194 816
        if (av_read_packet(is, &pkt) < 0) {
1195 817
            file_table[file_index].eof_reached = 1;
......
1358 980
            }
1359 981
        }
1360 982
    }
983
    term_exit();
1361 984

  
1362 985
    /* dump report by using the first video and audio streams */
1363 986
    {
......
2090 1713
    video_codec_id = CODEC_ID_NONE;
2091 1714
}
2092 1715

  
1716
#ifdef CONFIG_GRAB
1717

  
1718
/* prepare dummy protocols for grab */
1719
void prepare_grab(void)
1720
{
1721
    int has_video, has_audio, i, j;
1722
    AVFormatContext *oc;
1723
    AVFormatContext *ic;
1724
    AVFormatParameters ap1, *ap = &ap1;
1725

  
1726
    /* see if audio/video inputs are needed */
1727
    has_video = 0;
1728
    has_audio = 0;
1729
    memset(ap, 0, sizeof(*ap));
1730
    for(j=0;j<nb_output_files;j++) {
1731
        oc = output_files[j];
1732
        for(i=0;i<oc->nb_streams;i++) {
1733
            AVCodecContext *enc = &oc->streams[i]->codec;
1734
            switch(enc->codec_type) {
1735
            case CODEC_TYPE_AUDIO:
1736
                if (enc->sample_rate > ap->sample_rate)
1737
                    ap->sample_rate = enc->sample_rate;
1738
                if (enc->channels > ap->channels)
1739
                    ap->channels = enc->channels;
1740
                has_audio = 1;
1741
                break;
1742
            case CODEC_TYPE_VIDEO:
1743
                if (enc->width > ap->width)
1744
                    ap->width = enc->width;
1745
                if (enc->height > ap->height)
1746
                    ap->height = enc->height;
1747
                if (enc->frame_rate > ap->frame_rate)
1748
                    ap->frame_rate = enc->frame_rate;
1749
                has_video = 1;
1750
                break;
1751
            }
1752
        }
1753
    }
1754
    
1755
    if (has_video == 0 && has_audio == 0) {
1756
        fprintf(stderr, "Output file must have at least one audio or video stream\n");
1757
        exit(1);
1758
    }
1759
    
1760
    if (has_video) {
1761
        ic = av_open_input_file("", "video_grab_device", 0, ap);
1762
        if (!ic) {
1763
            fprintf(stderr, "Could not open video grab device\n");
1764
            exit(1);
1765
        }
1766
        input_files[nb_input_files] = ic;
1767
        dump_format(ic, nb_input_files, v4l_device, 0);
1768
        nb_input_files++;
1769
    }
1770
    if (has_audio) {
1771
        ic = av_open_input_file("", "audio_device", 0, ap);
1772
        if (!ic) {
1773
            fprintf(stderr, "Could not open audio grab device\n");
1774
            exit(1);
1775
        }
1776
        input_files[nb_input_files] = ic;
1777
        dump_format(ic, nb_input_files, audio_device, 0);
1778
        nb_input_files++;
1779
    }
1780
}
1781

  
1782
#else
1783

  
1784
void prepare_grab(void)
1785
{
1786
    fprintf(stderr, "Must supply at least one input file\n");
1787
    exit(1);
1788
}
1789

  
1790
#endif
1791

  
1792
/* open the necessary output devices for playing */
1793
void prepare_play(void)
1794
{
1795
    file_format = guess_format("audio_device", NULL, NULL);
1796
    if (!file_format) {
1797
        fprintf(stderr, "Could not find audio device\n");
1798
        exit(1);
1799
    }
1800
    
1801
    opt_output_file(audio_device);
1802
}
1803

  
1804

  
2093 1805
#ifndef CONFIG_WIN32
2094 1806
INT64 getutime(void)
2095 1807
{
......
2165 1877

  
2166 1878
void show_help(void)
2167 1879
{
1880
    const char *prog;
2168 1881
    const OptionDef *po;
2169 1882
    int i, expert;
1883
    
1884
    prog = do_play ? "ffplay" : "ffmpeg";
2170 1885

  
2171
    printf("ffmpeg version " FFMPEG_VERSION ", Copyright (c) 2000,2001 Gerard Lantau\n"
2172
           "usage: ffmpeg [[options] -i input_file]... {[options] outfile}...\n"
2173
           "Hyper fast MPEG1/MPEG4/H263/RV and AC3/MPEG audio encoder\n"
2174
           "\n"
1886
    printf("%s version " FFMPEG_VERSION ", Copyright (c) 2000, 2001 Gerard Lantau\n", 
1887
           prog);
1888
    
1889
    if (!do_play) {
1890
        printf("usage: ffmpeg [[options] -i input_file]... {[options] outfile}...\n"
1891
               "Hyper fast MPEG1/MPEG4/H263/RV and AC3/MPEG audio encoder\n");
1892
    } else {
1893
        printf("usage: ffplay [options] input_file...\n"
1894
               "Simple audio player\n");
1895
    }
1896
           
1897
    printf("\n"
2175 1898
           "Main options are:\n");
2176 1899
    for(i=0;i<2;i++) {
2177 1900
        if (i == 1)
......
2246 1969
    int optindex, i;
2247 1970
    const char *opt, *arg;
2248 1971
    const OptionDef *po;
1972
    INT64 ti;
2249 1973
    
2250 1974
    register_all();
2251 1975

  
1976
    /* detect if invoked as player */
1977
    i = strlen(argv[0]);
1978
    if (i >= 6 && !strcmp(argv[0] + i - 6, "ffplay"))
1979
        do_play = 1;
1980

  
2252 1981
    if (argc <= 1)
2253 1982
        show_help();
2254

  
1983
    
1984
    /* parse options */
2255 1985
    optindex = 1;
2256 1986
    while (optindex < argc) {
2257 1987
        opt = argv[optindex++];
......
2280 2010
                po->u.func_arg(arg);
2281 2011
            }
2282 2012
        } else {
2283
            opt_output_file(opt);
2013
            if (!do_play) {
2014
                opt_output_file(opt);
2015
            } else {
2016
                opt_input_file(opt);
2017
            }
2284 2018
        }
2285 2019
    }
2286 2020

  
2287 2021

  
2288
    if (nb_input_files == 0) {
2289
#ifdef CONFIG_GRAB
2290
        if (nb_output_files != 1) {
2291
            fprintf(stderr, "Only one output file supported when grabbing\n");
2292
            exit(1);
2293
        }
2294
        av_grab(output_files[0]);
2295
#else
2296
        fprintf(stderr, "Must supply at least one input file\n");
2297
#endif
2298
    } else {
2299
        INT64 ti;
2300

  
2022
    if (!do_play) {
2023
        /* file converter / grab */
2301 2024
        if (nb_output_files <= 0) {
2302 2025
            fprintf(stderr, "Must supply at least one output file\n");
2303 2026
            exit(1);
2304 2027
        }
2305
        ti = getutime();
2306
        av_encode(output_files, nb_output_files, input_files, nb_input_files, 
2307
                  stream_maps, nb_stream_maps);
2308
        ti = getutime() - ti;
2309
        if (do_benchmark) {
2310
            printf("bench: utime=%0.3fs\n", ti / 1000000.0);
2028
        
2029
        if (nb_input_files == 0) {
2030
            prepare_grab();
2311 2031
        }
2032
    } else {
2033
        /* player */
2034
        if (nb_input_files <= 0) {
2035
            fprintf(stderr, "Must supply at least one input file\n");
2036
            exit(1);
2037
        }
2038
        prepare_play();
2039
    }
2040

  
2041
    ti = getutime();
2042
    av_encode(output_files, nb_output_files, input_files, nb_input_files, 
2043
              stream_maps, nb_stream_maps);
2044
    ti = getutime() - ti;
2045
    if (do_benchmark) {
2046
        printf("bench: utime=%0.3fs\n", ti / 1000000.0);
2312 2047
    }
2313 2048

  
2314 2049
    /* close files */

Also available in: Unified diff