| 523 | } |
| 524 | |
| 525 | static int read_ffserver_streams(AVFormatContext *s, const char *filename) |
| 526 | { |
| 527 | int i, err; |
| 528 | AVFormatContext *ic; |
| 529 | int nopts = 0; |
| 530 | |
| 531 | err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL); |
| 532 | if (err < 0) |
| 533 | return err; |
| 534 | /* copy stream format */ |
| 535 | s->nb_streams = ic->nb_streams; |
| 536 | for(i=0;i<ic->nb_streams;i++) { |
| 537 | AVStream *st; |
| 538 | AVCodec *codec; |
| 539 | |
| 540 | // FIXME: a more elegant solution is needed |
| 541 | st = av_mallocz(sizeof(AVStream)); |
| 542 | memcpy(st, ic->streams[i], sizeof(AVStream)); |
| 543 | st->codec = avcodec_alloc_context(); |
| 544 | if (!st->codec) { |
| 545 | print_error(filename, AVERROR(ENOMEM)); |
| 546 | av_exit(1); |
| 547 | } |
| 548 | avcodec_copy_context(st->codec, ic->streams[i]->codec); |
| 549 | s->streams[i] = st; |
| 550 | |
| 551 | codec = avcodec_find_encoder(st->codec->codec_id); |
| 552 | if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 553 | if (audio_stream_copy) { |
| 554 | st->stream_copy = 1; |
| 555 | } else |
| 556 | choose_sample_fmt(st, codec); |
| 557 | } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { |
| 558 | if (video_stream_copy) { |
| 559 | st->stream_copy = 1; |
| 560 | } else |
| 561 | choose_pixel_fmt(st, codec); |
| 562 | } |
| 563 | |
| 564 | if(!st->codec->thread_count) |
| 565 | st->codec->thread_count = 1; |
| 566 | if(st->codec->thread_count>1) |
| 567 | avcodec_thread_init(st->codec, st->codec->thread_count); |
| 568 | |
| 569 | if(st->codec->flags & CODEC_FLAG_BITEXACT) |
| 570 | nopts = 1; |
| 571 | } |
| 572 | |
| 573 | if (!nopts) |
| 574 | s->timestamp = av_gettime(); |
| 575 | |
| 576 | av_close_input_file(ic); |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | static double |
| 581 | get_sync_ipts(const AVOutputStream *ost) |
no test coverage detected