Re: [Libav-user] How to calculate pts/dts ???

2023-01-05 Thread wolverin via Libav-user

>>If you use libx264 encoder, have you tried tune zerolatency compensation flag?
Of course I use it like this
 
av_dict_set(, "tune", "zerolatency", 0);
avcodec_open2(pCdcCtxOut, pCdcOut, );
 
I probably still have a mistake somewhere in incorrect values or incorrect use 
of these variables
AVCodecContext->time_base
AVStream->avg_frame_rate
AVStream->r_frame_rate
 
Maybe for outgoing AVFrames it is necessary to count pts/dts in 
AVStream->time_base, but for AVPacket use AVCodecContext->time_base?___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-05 Thread Paul B Mahol
On Thu, Jan 5, 2023 at 3:43 PM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> On Mon, Jan 2, 2023 at 4:51 PM wolverin via Libav-user <
> libav-user@ffmpeg.org
> > wrote:
>
> Did I understand you correctly that I need to multiply time_base and
> system time between adjacent frames and add the resulting time to the
> previous PTS?
>
> Nope.
> PTS is just timebase * seconds represented as int64 number
>
> There are no additions with next/prev pts values.
>
>
>
> Then pts is the time of one frame?
>
>
> Yes, when used with tied time_base AVRational.
>
>
> Thank you very much, you helped me a lot, it significantly improved the
> smoothness of playback, but I still see 1 or 2 incomprehensible pauses at
> the beginning when watching live video in VLC.
>
> Currently, only the output AVStream->time_base is used to calculate
> pts/dts.
> But then what is the outgoing AVCodecContext->time_base needed for and
> what values? Do I need to initialize AVStream->avg_frame_rate or
> AVStream->r_frame_rate? Their change does not affect almost the video, but
> for some reason it increases traffic.
>
>
> avcodec_send_packet(pCdcCtxInp, pPktInp);
> avcodec_receive_frame(pCdcCtxInp, pFrm);
> pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base,
> pCdcCtxInp->time_base);
>
> avcodec_send_frame(pCdcCtxOut, pFrm);
> avcodec_receive_packet(pCdcCtxOut, pPktOut);
> pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base,
> pCdcCtxOut->time_base);
> pPktOut->dts = pPktOut->pts;
>
>
> Inspect values of input/output pts and used timebases(with printfs or
> other ways...) and you can figure it where PTS becomes nonsense.
>
>
> As I understand it, the input stream from the usb camera has a constant
> FR, transcoded I get a variable FR +
> I can start reading earlier frames from the camera additionally for
> writing to disk, so I can't scale timestamps directly.
>

If you use libx264 encoder, have you tried tune zerolatency compensation
flag?


>
>
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-requ...@ffmpeg.org with subject "unsubscribe".
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-05 Thread wolverin via Libav-user

>On Mon, Jan 2, 2023 at 4:51 PM wolverin via Libav-user < libav-user@ffmpeg.org 
>> wrote:
>>>Did I understand you correctly that I need to multiply time_base and system 
>>>time between adjacent frames and add the resulting time to the previous PTS?
>>> 
>>>Nope.
>>>PTS is just timebase * seconds represented as int64 number
>>> 
>>>There are no additions with next/prev pts values.
>>> 
>> 
>>Then pts is the time of one frame?
> 
>Yes, when used with tied time_base AVRational.
> 
Thank you very much, you helped me a lot, it significantly improved the 
smoothness of playback, but I still see 1 or 2 incomprehensible pauses at the 
beginning when watching live video in VLC.
 
Currently, only the output AVStream->time_base is used to calculate pts/dts.
But then what is the outgoing AVCodecContext->time_base needed for and what 
values? Do I need to initialize AVStream->avg_frame_rate or 
AVStream->r_frame_rate? Their change does not affect almost the video, but for 
some reason it increases traffic.
 
>>avcodec_send_packet(pCdcCtxInp, pPktInp);
>>avcodec_receive_frame(pCdcCtxInp, pFrm);
>>pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base, 
>>pCdcCtxInp->time_base);
>> 
>>avcodec_send_frame(pCdcCtxOut, pFrm);
>>avcodec_receive_packet(pCdcCtxOut, pPktOut);
>>pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base, 
>>pCdcCtxOut->time_base);
>>pPktOut->dts = pPktOut->pts;
> 
>Inspect values of input/output pts and used timebases(with printfs or other 
>ways...) and you can figure it where PTS becomes nonsense.
 
As I understand it, the input stream from the usb camera has a constant FR, 
transcoded I get a variable FR + 
I can start reading earlier  frames from the camera additionally for writing to 
disk, so I can't scale timestamps directly.

 ___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread Paul B Mahol
On Mon, Jan 2, 2023 at 4:51 PM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> Did I understand you correctly that I need to multiply time_base and
> system time between adjacent frames and add the resulting time to the
> previous PTS?
>
> Nope.
> PTS is just timebase * seconds represented as int64 number
>
> There are no additions with next/prev pts values.
>
>
>
> Then pts is the time of one frame?
>

Yes, when used with tied time_base AVRational.


>
>
>
> I used av_rescale_q to scale time_base from an incoming MJPEG stream to an
> outgoing H264 one, but for some reason timestamps pts/dts are meaningless
> in this case.
>
>
> Show your code.
>
>
> I have greatly simplified it to understand how I am trying to use avscale,
> as it is done in different threads using buffers to use other ARM cores.
>
> avcodec_send_packet(pCdcCtxInp, pPktInp);
> avcodec_receive_frame(pCdcCtxInp, pFrm);
> pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base,
> pCdcCtxInp->time_base);
>
> avcodec_send_frame(pCdcCtxOut, pFrm);
> avcodec_receive_packet(pCdcCtxOut, pPktOut);
> pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base,
> pCdcCtxOut->time_base);
> pPktOut->dts = pPktOut->pts;
>

Inspect values of input/output pts and used timebases(with printfs or other
ways...) and you can figure it where PTS becomes nonsense.
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread wolverin via Libav-user

>Did I understand you correctly that I need to multiply time_base and system 
>time between adjacent frames and add the resulting time to the previous PTS?
> 
>Nope.
>PTS is just timebase * seconds represented as int64 number
> 
>There are no additions with next/prev pts values.
> 
 
Then pts is the time of one frame?
 
>> 
>>I used av_rescale_q to scale time_base from an incoming MJPEG stream to an 
>>outgoing H264 one, but for some reason timestamps pts/dts are meaningless in 
>>this case.
> 
>Show your code.
 
I have greatly simplified it to understand how I am trying to use avscale, as 
it is done in different threads using buffers to use other ARM cores.
 
avcodec_send_packet(pCdcCtxInp, pPktInp);
avcodec_receive_frame(pCdcCtxInp, pFrm);
pFrm->pts = av_rescale_q(pPktInp->pts, pFmtCtxInp->streams[0]->time_base, 
pCdcCtxInp->time_base);
 
avcodec_send_frame(pCdcCtxOut, pFrm);
avcodec_receive_packet(pCdcCtxOut, pPktOut);
pPktOut->pts = av_rescale_q(pFrm->pts, pCdcCtxInp->time_base, 
pCdcCtxOut->time_base);
pPktOut->dts = pPktOut->pts;
 ___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread Paul B Mahol
On Mon, Jan 2, 2023 at 3:39 PM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> On Mon, Jan 2, 2023 at 3:13 PM wolverin via Libav-user <
> libav-user@ffmpeg.org
> > wrote:
>
>
> *Output #0, rtsp, to 'rtsp://127.0.1.1:555 ':*
> *  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown),
> 1280x720, q=2-31, 500 kb/s, 15 tbr, 90k tbn*
>
>
> I compared such an approximate calculation of pts/dts in ffprobe for my
> code and ffmpeg and they match until the real fps becomes different from
> the calculated one, then I see either delays or frame losses in VLC.
>
>
> You can not use 15 from video frame rate to calculate PTS when video is
> variable frame rate.
>
>
> ok, but then how do I calculate the pts/dts of each frame correctly???
>
>
> PTS is represented as relative time starting from 0 for start of file.
>
> PTS is just a int64_t number that tells relative time.
> To know time resolution one use timebase.num/den, so they are actually
> tied together with pts timestamp.
>
> If video is VFR than there are gaps e.g. non-monotonous increasing of pts
> from older to newer ones.
>
> Say time of frame is 5.5 seconds and timebase used is 1/9 than time of
> 1 second would have value of 9 stored in pts.
> 5.5 seconds would then be 5*9 + 0.5*9.
>
> Hope that you can conclude from this demonstration how to solve your
> problem.
>
> To rescale PTS from one timebase resolution to another one use
> av_rescale_q().
>
>
> Did I understand you correctly that I need to multiply time_base and
> system time between adjacent frames and add the resulting time to the
> previous PTS?
>

Nope.
PTS is just timebase * seconds represented as int64 number

There are no additions with next/prev pts values.


>
> I used av_rescale_q to scale time_base from an incoming MJPEG stream to an
> outgoing H264 one, but for some reason timestamps pts/dts are meaningless
> in this case.
>

Show your code.


>
> Thank you so much for your help!
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-requ...@ffmpeg.org with subject "unsubscribe".
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread wolverin via Libav-user

>On Mon, Jan 2, 2023 at 3:13 PM wolverin via Libav-user < libav-user@ffmpeg.org 
>> wrote:  
Output #0, rtsp, to 'rtsp:// 127.0.1.1:555 ':
  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown), 1280x720, 
q=2-31, 500 kb/s, 15 tbr, 90k tbn
 
 
I compared such an approximate calculation of pts/dts in ffprobe for my 
code and ffmpeg and they match until the real fps becomes different from 
the calculated one, then I see either delays or frame losses in VLC.
>>> 
>>>You can not use 15 from video frame rate to calculate PTS when video is 
>>>variable frame rate.
>> 
>>ok, but then how do I calculate the pts/dts of each frame correctly???
> 
>PTS is represented as relative time starting from 0 for start of file.
> 
>PTS is just a int64_t number that tells relative time.
>To know time resolution one use timebase.num/den, so they are actually tied 
>together with pts timestamp.
> 
>If video is VFR than there are gaps e.g. non-monotonous increasing of pts from 
>older to newer ones.
> 
>Say time of frame is 5.5 seconds and timebase used is 1/9 than time of 1 
>second would have value of 9 stored in pts.
>5.5 seconds would then be 5*9 + 0.5*9.
> 
>Hope that you can conclude from this demonstration how to solve your problem.
> 
>To rescale PTS from one timebase resolution to another one use av_rescale_q().
 
Did I understand you correctly that I need to multiply time_base and system 
time between adjacent frames and add the resulting time to the previous PTS?
 
I used av_rescale_q to scale time_base from an incoming MJPEG stream to an 
outgoing H264 one, but for some reason timestamps pts/dts are meaningless in 
this case.
 
Thank you so much for your help!___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread Paul B Mahol
On Mon, Jan 2, 2023 at 3:13 PM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> *Output #0, rtsp, to 'rtsp://127.0.1.1:555 ':*
> *  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown),
> 1280x720, q=2-31, 500 kb/s, 15 tbr, 90k tbn*
>
>
> I compared such an approximate calculation of pts/dts in ffprobe for my
> code and ffmpeg and they match until the real fps becomes different from
> the calculated one, then I see either delays or frame losses in VLC.
>
>
> You can not use 15 from video frame rate to calculate PTS when video is
> variable frame rate.
>
>
> ok, but then how do I calculate the pts/dts of each frame correctly???
>

PTS is represented as relative time starting from 0 for start of file.

PTS is just a int64_t number that tells relative time.
To know time resolution one use timebase.num/den, so they are actually tied
together with pts timestamp.

If video is VFR than there are gaps e.g. non-monotonous increasing of pts
from older to newer ones.

Say time of frame is 5.5 seconds and timebase used is 1/9 than time of
1 second would have value of 9 stored in pts.
5.5 seconds would then be 5*9 + 0.5*9.

Hope that you can conclude from this demonstration how to solve your
problem.

To rescale PTS from one timebase resolution to another one use
av_rescale_q().



> I want my SoC ARM to provide maximum transcoding speed, this is especially
> important for a resolution of 1920x1080 when fps is 8-11
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-requ...@ffmpeg.org with subject "unsubscribe".
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread wolverin via Libav-user

>>Output #0, rtsp, to 'rtsp:// 127.0.1.1:555 ':
>>  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown), 1280x720, 
>>q=2-31, 500 kb/s, 15 tbr, 90k tbn
>> 
>> 
>>I compared such an approximate calculation of pts/dts in ffprobe for my code 
>>and ffmpeg and they match until the real fps becomes different from the 
>>calculated one, then I see either delays or frame losses in VLC.
> 
>You can not use 15 from video frame rate to calculate PTS when video is 
>variable frame rate.
 
ok, but then how do I calculate the pts/dts of each frame correctly???
I want my SoC ARM to provide maximum transcoding speed, this is especially 
important for a resolution of 1920x1080 when fps is 8-11___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread Paul B Mahol
On Mon, Jan 2, 2023 at 12:16 PM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> On Thu, Dec 29, 2022 at 9:45 AM wolverin via Libav-user <
> libav-user@ffmpeg.org
> >
> wrote:
>
> I'm transcoding live video from MJPEG to H264 using ffmpeg library in my
> C/C++ project
>
> Help me figure out how to calculate the pts/dts correctly, using various
> av_rescale* functions did not give the correct values and I tried my simple
> version, but the number of frames per second is different all the time and
> of course these values are approximate
>
> int64_t * pcnt
>
> pPktOut->pos = (*pcnt);
> pPktOut->pts = pPktOut->pos * pFmtCtxOut->streams[0]->time_base.den  /
> pCdcCtxOut->time_base.den;
>
>
> This does not make any sense.
>
> Time base is rational and thus both numerator and denumerator should be
> used.
>
>
> Thanks for your reply.
> Yes, you are right, but I have time_base.num = 1 (for out stream 1/9,
> for codeccontext 1/15 — 15 fps is the desired frequency, but in reality it
> varies between 16-20)
> Here is an example of my time base dumps
>
> *Input #0, video4linux2,v4l2, from '/dev/video0':*
> *  Duration: N/A, start: 532397.028007, bitrate: N/A*
> *  Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc,
> bt470bg/unknown/unknown), 1280x720, 30 fps, 30 tbr, 1000k tbn*
>
> *[libx264 @ 0x14ef370] using cpu capabilities: ARMv6 NEON*
> *[libx264 @ 0x14ef370] profile High 4:2:2, level 3.1, 4:2:2 8-bit*
> *[libx264 @ 0x14ef370] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC
> codec - Copyleft 2003-2015 - http://www.videolan.org/html
>  - options: cabac=0 ref=1 deblock=0:0:0
> analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16
> chrom1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1
> chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 sl4 nr=0
> decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0
> weightp=0 keyint=250 keyint_min=15 scenecut=0 _refresh=0 rc_lookahead=0
> rc=cbr mbtree=0 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69
> qpstep=4 vbv_maxrate=500 vbv_ze=1000 nal_hrd=none filler=0 ip_ratio=1.40
> aq=0*
> *Output #0, rtsp, to 'rtsp://127.0.1.1:555 ':*
> *  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown),
> 1280x720, q=2-31, 500 kb/s, 15 tbr, 90k tbn*
>
>
> I compared such an approximate calculation of pts/dts in ffprobe for my
> code and ffmpeg and they match until the real fps becomes different from
> the calculated one, then I see either delays or frame losses in VLC.
>

You can not use 15 from video frame rate to calculate PTS when video is
variable frame rate.


>
>
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-requ...@ffmpeg.org with subject "unsubscribe".
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread wolverin via Libav-user

>On Thu, Dec 29, 2022 at 9:45 AM wolverin via Libav-user < 
>libav-user@ffmpeg.org > wrote:
>>I'm transcoding live video from MJPEG to H264 using ffmpeg library in my 
>>C/C++ project
>> 
>>Help me figure out how to calculate the pts/dts correctly, using various 
>>av_rescale* functions did not give the correct values and I tried my simple 
>>version, but the number of frames per second is different all the time and of 
>>course these values are approximate
>> 
>>int64_t * pcnt
>> 
>>pPktOut->pos = (*pcnt);
>>pPktOut->pts = pPktOut->pos * pFmtCtxOut->streams[0]->time_base.den  / 
>>pCdcCtxOut->time_base.den;
> 
>This does not make any sense.
> 
>Time base is rational and thus both numerator and denumerator should be used.
 
Thanks for your reply.
Yes, you are right, but I have time_base.num = 1 (for out stream 1/9, for 
codeccontext 1/15 — 15 fps is the desired frequency, but in reality it varies 
between 16-20)
Here is an example of my time base dumps
 
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 532397.028007, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 
1280x720, 30 fps, 30 tbr, 1000k tbn
 
[libx264 @ 0x14ef370] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x14ef370] profile High 4:2:2, level 3.1, 4:2:2 8-bit
[libx264 @ 0x14ef370] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - 
Copyleft 2003-2015 -  http://www.videolan.org/html - options: cabac=0 ref=1 
deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 
me_range=16 chrom1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 
chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 sl4 nr=0 
decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 
keyint=250 keyint_min=15 scenecut=0 _refresh=0 rc_lookahead=0 rc=cbr mbtree=0 
bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 
vbv_ze=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
Output #0, rtsp, to 'rtsp://127.0.1.1:555':
  Stream #0:0: Video: h264, yuv422p(tv, bt470bg/unknown/unknown), 1280x720, 
q=2-31, 500 kb/s, 15 tbr, 90k tbn
 
 
I compared such an approximate calculation of pts/dts in ffprobe for my code 
and ffmpeg and they match until the real fps becomes different from the 
calculated one, then I see either delays or frame losses in VLC.
 
 ___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".


Re: [Libav-user] How to calculate pts/dts ???

2023-01-02 Thread Paul B Mahol
On Thu, Dec 29, 2022 at 9:45 AM wolverin via Libav-user <
libav-user@ffmpeg.org> wrote:

> I'm transcoding live video from MJPEG to H264 using ffmpeg library in my
> C/C++ project
>
> Help me figure out how to calculate the pts/dts correctly, using various
> av_rescale* functions did not give the correct values and I tried my simple
> version, but the number of frames per second is different all the time and
> of course these values are approximate
>
> int64_t * pcnt
>
> pPktOut->pos = (*pcnt);
> pPktOut->pts = pPktOut->pos * pFmtCtxOut->streams[0]->time_base.den  /
> pCdcCtxOut->time_base.den;
>

This does not make any sense.

Time base is rational and thus both numerator and denumerator should be
used.


> pPktOut->dts = pPktOut->pts;
>
> (*pcnt)++;
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-requ...@ffmpeg.org with subject "unsubscribe".
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-requ...@ffmpeg.org with subject "unsubscribe".