Revision f6580287 chunker_streamer/chunker_streamer.c

View differences:

chunker_streamer/chunker_streamer.c
715 715
				dcprintf(DEBUG_VIDEO_FRAMES, "VIDEOin pkt: dts %lld pts %lld pts-dts %lld\n", packet.dts, packet.pts, packet.pts-packet.dts );
716 716
				dcprintf(DEBUG_VIDEO_FRAMES, "VIDEOdecode: pkt_dts %lld pkt_pts %lld frame.pts %lld\n", pFrame->pkt_dts, pFrame->pkt_pts, pFrame->pts);
717 717
				dcprintf(DEBUG_VIDEO_FRAMES, "VIDEOdecode intype %d%s\n", pFrame->pict_type, pFrame->key_frame ? " (key)" : "");
718
				if (pFrame->pkt_pts != AV_NOPTS_VALUE) {
719
					pFrame->pts = av_rescale_q(pFrame->pkt_pts, pFormatCtx->streams[videoStream]->time_base, pCodecCtxEnc->time_base);
720
				} else {	//try to figure out the pts //TODO: review this
721
					if (pFrame->pkt_dts != AV_NOPTS_VALUE) {
722
						pFrame->pts = av_rescale_q(pFrame->pkt_dts, pFormatCtx->streams[videoStream]->time_base, pCodecCtxEnc->time_base);
723
					}
724
				}
725 718
				if(frameFinished)
726 719
				{ // it must be true all the time else error
727 720
				
......
774 767
						} else {
775 768
							memcpy(video_outbuf, packet.data, video_frame_size);
776 769
						}
777
					} else if(pCodecCtx->height != pCodecCtxEnc->height || pCodecCtx->width != pCodecCtxEnc->width) {
770
					} else {
771

  
772
					    if (pFrame->pkt_pts != AV_NOPTS_VALUE) {
773
						pFrame->pts = av_rescale_q(pFrame->pkt_pts, pFormatCtx->streams[videoStream]->time_base, pCodecCtxEnc->time_base);
774
					    } else {	//try to figure out the pts //TODO: review this
775
						if (pFrame->pkt_dts != AV_NOPTS_VALUE) {
776
							pFrame->pts = av_rescale_q(pFrame->pkt_dts, pFormatCtx->streams[videoStream]->time_base, pCodecCtxEnc->time_base);
777
						}
778
					    }
779

  
780
					    if(pCodecCtx->height != pCodecCtxEnc->height || pCodecCtx->width != pCodecCtxEnc->width) {
778 781
//						static AVPicture pict;
779 782
						static struct SwsContext *img_convert_ctx = NULL;
780 783
						
......
791 794
						scaledFrame->pts = pFrame->pts;
792 795
						scaledFrame->pict_type = 0;
793 796
						video_frame_size = avcodec_encode_video(pCodecCtxEnc, video_outbuf, video_outbuf_size, scaledFrame);
794
					} else {
797
					    } else {
795 798
						pFrame->pict_type = 0;
796 799
						video_frame_size = avcodec_encode_video(pCodecCtxEnc, video_outbuf, video_outbuf_size, pFrame);
800
					    }
801

  
802
					    //use pts if dts is invalid
803
					    if(pCodecCtxEnc->coded_frame->pts!=AV_NOPTS_VALUE)
804
						target_pts = av_rescale_q(pCodecCtxEnc->coded_frame->pts, pCodecCtxEnc->time_base, pFormatCtx->streams[videoStream]->time_base);
805
					    else {	//TODO: review this
806
						av_free_packet(&packet);
807
						continue;
808
						//fprintf(stderr, "VIDEOout: pts error\n");
809
						//exit(1);
810
					    }
797 811
					}
798 812

  
799 813
					if(video_frame_size <= 0)
......
821 835
					}
822 836
#endif
823 837

  
824
					//use pts if dts is invalid
825
					if(pCodecCtxEnc->coded_frame->pts!=AV_NOPTS_VALUE)
826
						target_pts = av_rescale_q(pCodecCtxEnc->coded_frame->pts, pCodecCtxEnc->time_base, pFormatCtx->streams[videoStream]->time_base);
827
					else	//TODO: review this
828
					{
829
						av_free_packet(&packet);
830
						continue;
831
						//fprintf(stderr, "VIDEOout: pts error\n");
832
						//exit(1);
833
					}
834

  
835 838
					if(offset_av)
836 839
					{
837 840
						if(FirstTimeVideo && target_pts>0) {

Also available in: Unified diff