<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>Is it possible that the PTS of a particular frame in a file is different with the PTS of the same frame in the same file while it is being streamed?<br></div>When I read a frame using av_read_frame I store the video stream in a AVStream. After I decode the frame with avcodec_decode_video2, I store the time stamp of that frame in a int64_t using av_frame_get_best_effort_timestamp. Now if the program is getting its input from a file I get a different timestamp than if I stream the input (from the same file) to the program.<br>To change the input type I simply change the argv argument from "/path/to/file.mp4" to something like "udp://localhost:1234", then I stream the file with ffmpeg in command line: "ffmpeg -re -i /path/to/file.mp4 -f mpegts udp://localhost:1234".<br></div>Below is my code (simplified). By reading the previous mailing lists I realized that the time_base that I'm looking for is in the AVStream and not the AVCodecContext. Instead of using av_frame_get_best_effort_timestamp I have also tried using the packet.pts but the results don't change.<br></div><div>I need the time stamps to have a notion of frame number in a streaming video.<br></div><div>I would really appreciate any sort of help.<br></div><div><br>//..<br>//argv[1]="/file.mp4";<br>argv[1]="udp://localhost:7777";<br></div>// define AVFormatContext, AVFrame...<br></div>// register av, avcodec, avformat_network_init()...<br>avformat_open_input(&pFormatCtx, argv, NULL, NULL);<br>avformat_find_stream_info(pFormatCtx, NULL);<br><div><div><div>// find the video stream...<br>// pointer to the codec context...<br></div><div>// open codec...<br></div><div>pFrame=av_frame_alloc();<br>while(av_read_frame(pFormatCtx, &packet)>=0) {<br>        AVStream *strem = pFormatCtx->streams[videoStream];<br>        if(packet.stream_index==videoStream) {<br>            avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);<br>            if(frameFinished) {<br>                int64_t perts = av_frame_get_best_effort_timestamp(pFrame);<br></div><div>                if (isMyFrame(pFrame)){<br></div><div>                     cout << perts*av_q2d(strem->time_base) << "\n";<br></div><div>                }<br>             }<br>}<br></div><div>//free allocated space<br>}<br>//..<br><br></div><div>Thanks a lot,<br></div><div>Maziar<br></div></div></div></div>