Revision 15bc38e5

View differences:

ffmpeg.c
2881 2881
            if(me_threshold)
2882 2882
                enc->debug |= FF_DEBUG_MV;
2883 2883

  
2884
            assert(enc->frame_rate_base == rfps_base); // should be true for now
2885
            if (enc->frame_rate != rfps) { 
2884
            if (enc->frame_rate != rfps || enc->frame_rate_base != rfps_base) { 
2886 2885

  
2887 2886
                if (verbose >= 0)
2888
                    fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f->%2.2f\n",
2889
                            i, (float)enc->frame_rate / enc->frame_rate_base,
2887
                    fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
2888
                            i, (float)enc->frame_rate / enc->frame_rate_base, enc->frame_rate, enc->frame_rate_base,
2890 2889

  
2891
                    (float)rfps / rfps_base);
2890
                    (float)rfps / rfps_base, rfps, rfps_base);
2892 2891
            }
2893 2892
            /* update the current frame rate to match the stream frame rate */
2894 2893
            frame_rate      = rfps;
libavformat/flvdec.c
103 103
            return AVERROR_NOMEM;
104 104

  
105 105
        av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
106
        st->codec.frame_rate_base= 0;
106
        st->codec.frame_rate_base= 1;
107
        st->codec.frame_rate= 1000;
107 108
    }
108 109
    break;
109 110
 }
......
123 124
            }
124 125
        }
125 126
    }else{
126
        if(st->codec.frame_rate_base == 0){
127 127
            st->codec.codec_type = CODEC_TYPE_VIDEO;
128
            //guess the frame rate
129
            if(pts){
130
                st->codec.frame_rate_base=1;
131
                st->codec.frame_rate= (1000 + pts/2)/pts;
132
            }
133 128
            switch(flags & 0xF){
134 129
            case 2: st->codec.codec_id = CODEC_ID_FLV1; break;
135 130
            default:
136 131
                st->codec.codec_tag= flags & 0xF;
137 132
            }
138
        }
139 133
    }
140 134

  
141 135
    if (av_new_packet(pkt, size) < 0)
libavformat/utils.c
1726 1726
    AVStream *st;
1727 1727
    AVPacket pkt1, *pkt;
1728 1728
    AVPacketList *pktl=NULL, **ppktl;
1729
    int64_t last_dts[MAX_STREAMS];
1730
    int64_t best_duration[MAX_STREAMS];
1729 1731

  
1732
    for(i=0;i<MAX_STREAMS;i++){
1733
        last_dts[i]= AV_NOPTS_VALUE;
1734
        best_duration[i]= INT64_MAX;
1735
    }
1736
    
1730 1737
    count = 0;
1731 1738
    read_size = 0;
1732 1739
    ppktl = &ic->packet_buffer;
......
1792 1799
        if (pkt->duration != 0)
1793 1800
            st->codec_info_nb_frames++;
1794 1801

  
1802
        if(st->codec.codec_type == CODEC_TYPE_VIDEO){
1803
            int64_t last= last_dts[pkt->stream_index];
1804
            
1805
            if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && last < pkt->dts && 
1806
               best_duration[pkt->stream_index] > pkt->dts - last){
1807
                best_duration[pkt->stream_index] = pkt->dts - last;
1808
            }
1809
            last_dts[pkt->stream_index]= pkt->dts;
1810
        }
1795 1811
        /* if still no information, we try to open the codec and to
1796 1812
           decompress the frame. We try to avoid that in most cases as
1797 1813
           it takes longer and uses more memory. For MPEG4, we need to
......
1823 1839
        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
1824 1840
            if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample)
1825 1841
                st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt);
1842

  
1843
            if(best_duration[i] < INT64_MAX && st->codec.frame_rate_base*1000 <= st->codec.frame_rate){
1844
                st->r_frame_rate= st->codec.frame_rate;
1845
                st->r_frame_rate_base= av_rescale(best_duration[i], st->codec.frame_rate, AV_TIME_BASE);
1846
                av_reduce(&st->r_frame_rate, &st->r_frame_rate_base, st->r_frame_rate, st->r_frame_rate_base, 1<<15);
1847
            }
1848

  
1826 1849
            /* set real frame rate info */
1827 1850
            /* compute the real frame rate for telecine */
1828 1851
            if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||

Also available in: Unified diff