Revision a71e2c5e src/Chunkiser/output-stream-play.c

View differences:

src/Chunkiser/output-stream-play.c
759 759
      o->t0=getmicro();
760 760
    }
761 761
    av_set_parameters(o->outctx, NULL);
762
    snprintf(o->outctx->filename, sizeof(o->outctx->filename), "%s", o->output_file);
763 762
    dump_format(o->outctx, 0, o->output_file, 1);
764
    url_fopen(&o->outctx->pb, o->output_file, URL_WRONLY );
765
  
766
    if (o->outctx->pb == NULL) {
767
      fprintf(stderr, "Cannot open %s!\n", o->output_file);
768
    }
769

  
770
    av_write_header(o->outctx);
771 763
  }
772 764
  if ((o->streams & media_type) == 0) {
773 765
    return;    /* Received a chunk for a non-selected stream */
......
795 787
      //                                       av_rescale_q(pts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q),
796 788
      //                                       av_rescale_q(dts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q));
797 789

  
798

  
799
      if (pkt.stream_index==0){
800
        pkt.pts = av_rescale_q(pts, o->video_time_base, o->outctx->streams[0]->time_base);
801
      } else {
802
        pkt.pts = av_rescale_q(pts, o->audio_time_base, o->outctx->streams[1]->time_base);
803
      }
790
      pkt.pts = pts;
804 791
    } else {
805 792
      pkt.pts = AV_NOPTS_VALUE;
806 793
    }
807 794
    dts += (dts < o->prev_dts - ((1LL << 31) - 1)) ? ((o->prev_dts >> 32) + 1) << 32 : (o->prev_dts >> 32) << 32;
808 795
    o->prev_dts = dts;
809
    if (pkt.stream_index==0){
810
      pkt.dts = av_rescale_q(dts, o->video_time_base, o->outctx->streams[0]->time_base);
811
    } else {
812
      pkt.dts = av_rescale_q(dts, o->audio_time_base, o->outctx->streams[1]->time_base);
813
    }
796
    pkt.dts = dts;
814 797
    // pkt.data = p;
815 798
    pkt.data = av_mallocz(frame_size+FF_INPUT_BUFFER_PADDING_SIZE);
816 799
    memcpy(pkt.data,p,frame_size);
......
863 846
	pthread_cond_signal(&s->condaudio);
864 847
	pthread_cond_signal(&s->condvideo);
865 848
  snd_pcm_close (s->playback_handle);
866
  av_write_trailer(s->outctx);
867
  url_fclose(s->outctx->pb);
868 849
  audio_resample_close(s->rsc);
869 850
  pthread_join(&s->tid_video,NULL);
870 851
  pthread_join(&s->tid_audio,NULL);

Also available in: Unified diff