Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-22 Thread Carl Zwanzig

On 3/22/2021 12:36 PM, Hassan wrote:
Or suggest any other solution. 


I did.

z!
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-22 Thread Carl Eugen Hoyos
Am Mo., 22. März 2021 um 20:36 Uhr schrieb Hassan :

> Given the discussion above and the question under discussion, can you
> please give a command to achieve the accurate timestamping of the frames?

You should start with something like the following:
$ ffmpeg -f gdigrab -i desktop -vcodec libx264 -pix_fmt yuv420p
-preset ultrafast out.mkv

mkv is not ideal for many framerates, the mov muxer is believed by its original
developer to not work correctly for vfr, so it is not easy to suggest an ideal
file format, consider testing nut.

If your system is fast enough, you can switch to libx264rgb and
increase the framerate,
In a second step, you can then write the timestamp on the frames if
you believe that
this is needed.

If you need more support, please do not forget to post the command line you
tested together with the complete, uncut console output.

Note that many systems are not fast enough to do what you want.

Carl Eugen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-22 Thread Hassan
>
> This filter chain looks either useless or broken.
>

Given the discussion above and the question under discussion, can you
please give a command to achieve the accurate timestamping of the frames?
Or suggest any other solution. Thanks.

-- 
Regards
Hassan Iqbal
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-22 Thread Carl Eugen Hoyos
Am Mo., 22. März 2021 um 14:51 Uhr schrieb Hassan :

> > ffmpeg -f gdigrab  -i desktop

> > -vf "settb=expr=1/72, setpts=N*12000, fps=60"

This filter chain looks either useless or broken.

Carl Eugen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-22 Thread Hassan
>
> Try this:
> ffmpeg -f gdigrab  -i desktop -vf "settb=expr=1/72, setpts=N*12000,
> fps=60" -c:v libx264rgb
> -preset ultrafast ./test_SD_1.mkv
> See if it works.
>
>  \ffmpeg> ffmpeg -f gdigrab  -i desktop -vf "settb=expr=1/72,
setpts=N*12000, fps=60" -c:v libx264rgb -preset ultrafast ./test_SD_1.mkv
ffmpeg version 4.3.2-2021-02-20-essentials_build-www.gyan.dev Copyright (c)
2000-2021 the FFmpeg developers
pencore-amrwb --enable-libmp3lame --enable-libtheora
--enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb
--enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil  56. 51.100 / 56. 51.100
  libavcodec 58. 91.100 / 58. 91.100
  libavformat58. 45.100 / 58. 45.100
  libavdevice58. 10.100 / 58. 10.100
  libavfilter 7. 85.100 /  7. 85.100
  libswscale  5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc55.  7.100 / 55.  7.100
[gdigrab @ 02755743dc80] Capturing whole desktop as 1920x1080x32 at
(0,0)
[gdigrab @ 02755743dc80] Stream #0: not enough frames to estimate rate;
consider increasing probesize
Input #0, gdigrab, from 'desktop':
  Duration: N/A, start: 1616419007.328868, bitrate: 1988680 kb/s
Stream #0:0: Video: bmp, bgra, 1920x1080, 1988680 kb/s, 29.97 fps,
1000k tbr, 1000k tbn, 1000k tbc
File './test_SD_1.mkv' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264rgb))
Press [q] to stop, [?] for help
[libx264rgb @ 027557442240] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264rgb @ 027557442240] profile High 4:4:4 Predictive, level 4.2,
4:4:4, 8-bit
[libx264rgb @ 027557442240] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4
AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.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 chroma_me=1 trellis=0 8x8dct=0
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12
lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250
keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, matroska, to './test_SD_1.mkv':
  Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264rgb) (H264 / 0x34363248), rgb24,
1920x1080, q=-1--1, 60 fps, 1k tbn, 60 tbc
Metadata:
  encoder : Lavc58.91.100 libx264rgb
Side data:
  cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  588 fps= 30 q=-1.0 Lsize=4425kB time=00:00:09.78
bitrate=3704.7kbits/s speed=0.497x
video:4420kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.095925%
[libx264rgb @ 027557442240] frame I:3 Avg QP:15.33  size:1206028
[libx264rgb @ 027557442240] frame P:585   Avg QP:15.77  size:  1552
[libx264rgb @ 027557442240] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264rgb @ 027557442240] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:
 0.5%  0.0%  0.0%  0.0%  0.0%skip:99.5%
[libx264rgb @ 027557442240] coded y,u,v intra: 33.4% 33.6% 33.4% inter:
0.2% 0.2% 0.2%
[libx264rgb @ 027557442240] i16 v,h,dc,p: 65% 30%  3%  1%
[libx264rgb @ 027557442240] kb/s:3694.57
Exiting normally, received signal 2.


Here is the output of ffprobe on the above recorded video

ffmpeg> ffprobe .\test_SD_1.mkv
ffprobe version 4.3.2-2021-02-20-essentials_build-www.gyan.dev Copyright
(c) 2007-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static
--disable-w32threads --disable-autodetect --enable-fontconfig
--enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma
--enable-zlib --enable-libsrt --enable-libssh --enable-libzmq
--enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg
--enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi
--enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf
--enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec
--enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx
--enable-libgme --enable-libopenmpt --enable-libopencore-amrwb
--enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc
--enable-libgsm --enable-libopencore-amrnb --enable-libopus
--enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil  56. 51.100 / 56. 51.100
  libavcodec 58. 91.100 / 58. 91.100
  libavformat58. 45.100 / 58. 45.100
  libavdevice58. 10.100 / 58. 10.100
  libavfilter 7. 85.100 /  7. 85.100
  libswscale  5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc55.  7.100 / 55.  7.100
Input #0, matroska,webm, from '.\test_SD_1.mkv':
  Metadata:
ENCODER : Lavf58.45.100

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Mark Filipak (ffmpeg)

On 2021-03-21 19:01, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 23:55 Uhr schrieb Mark Filipak (ffmpeg)
:


On 2021-03-21 18:36, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 23:31 Uhr schrieb Mark Filipak (ffmpeg)
:


On 2021-03-21 17:50, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
:


I think '-framerate 60' may not be needed at all.


It is only needed if 60fps recording is wanted.



As said before, setpts should generally be avoided and
this is even more true for settb.


Serious questions:

'setpts=N/FR/TB' seems to be reliable, and is the only way
I've gotten some of my frame gymnastics to work.


Serious question:
What does this tell you?


You are "answering" a question with a question.


This is clearly a "lie" to quote another contributor ;-)


I don't know to what you refer. Are you making a joke?


I don't know what your "answer" means.


It was a (too?) subtle way to indicate that what you try to
do makes no sense.


'setpts' exists. It makes sense to me -- and it works. I'm sure it made sense to the person who 
wrote the 'setpts' filter. Why does it make no sense to you?



What is wrong/dangerous about 'setpts"?


I can only work for input that is strictly cfr,...


Of course, that's true.


...this is typically not true for screen recordings.



What are "screen recordings"?


The topic of this mailing list thread.


Oh! Thanks. I thought the OP was asking about camera output. My bad.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Carl Eugen Hoyos
Am So., 21. März 2021 um 23:55 Uhr schrieb Mark Filipak (ffmpeg)
:
>
> On 2021-03-21 18:36, Carl Eugen Hoyos wrote:
> > Am So., 21. März 2021 um 23:31 Uhr schrieb Mark Filipak (ffmpeg)
> > :
> >>
> >> On 2021-03-21 17:50, Carl Eugen Hoyos wrote:
> >>> Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
> >>> :
> >>>
>  I think '-framerate 60' may not be needed at all.
> >>>
> >>> It is only needed if 60fps recording is wanted.
> >
> >>> As said before, setpts should generally be avoided and
> >>> this is even more true for settb.
> >>
> >> Serious questions:
> >>
> >> 'setpts=N/FR/TB' seems to be reliable, and is the only way
> >> I've gotten some of my frame gymnastics to work.
> >
> > Serious question:
> > What does this tell you?
>
> You are "answering" a question with a question.

This is clearly a "lie" to quote another contributor ;-)

> I don't know what your "answer" means.

It was a (too?) subtle way to indicate that what you try to
do makes no sense.

> >> What is wrong/dangerous about 'setpts"?
> >
> > I can only work for input that is strictly cfr,...
>
> Of course, that's true.
>
> >...this is typically not true for screen recordings.

> What are "screen recordings"?

The topic of this mailing list thread.

Carl Eugen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Mark Filipak (ffmpeg)

On 2021-03-21 18:36, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 23:31 Uhr schrieb Mark Filipak (ffmpeg)
:


On 2021-03-21 17:50, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
:


I think '-framerate 60' may not be needed at all.


It is only needed if 60fps recording is wanted.



As said before, setpts should generally be avoided and
this is even more true for settb.


Serious questions:

'setpts=N/FR/TB' seems to be reliable, and is the only way
I've gotten some of my frame gymnastics to work.


Serious question:
What does this tell you?


You are "answering" a question with a question. I don't know what your "answer" 
means.


What is wrong/dangerous about 'setpts"?


I can only work for input that is strictly cfr,...


Of course, that's true.


...this is typically not true for screen recordings.


What are "screen recordings"?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Carl Eugen Hoyos
Am So., 21. März 2021 um 23:31 Uhr schrieb Mark Filipak (ffmpeg)
:
>
> On 2021-03-21 17:50, Carl Eugen Hoyos wrote:
> > Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
> > :
> >
> >> I think '-framerate 60' may not be needed at all.
> >
> > It is only needed if 60fps recording is wanted.

> > As said before, setpts should generally be avoided and
> > this is even more true for settb.
>
> Serious questions:
>
> 'setpts=N/FR/TB' seems to be reliable, and is the only way
> I've gotten some of my frame gymnastics to work.

Serious question:
What does this tell you?

> What is wrong/dangerous about 'setpts"?

I can only work for input that is strictly cfr, this is typically
not true for screen recordings.

Carl Eugen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Mark Filipak (ffmpeg)

On 2021-03-21 17:50, Carl Eugen Hoyos wrote:

Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
:


I think '-framerate 60' may not be needed at all.


It is only needed if 60fps recording is wanted.

As said before, setpts should generally be avoided and
this is even more true for settb.


Serious questions:

'setpts=N/FR/TB' seems to be reliable, and is the only way I've gotten some of my frame gymnastics 
to work. What is wrong/dangerous about 'setpts"?
Note: I'm aware that frames can be out-of-order for some input streams (e.g. mpeg2video) but they 
seem to be in-order in the frame pipeline. Is there some reason to *not* take advantage of that?


'settb=expr=1/72' seems to be pretty useful for improving the timing resolution of the filter 
pipeline. Why do you think it should be avoided?


Regards, and Much Thanks,
Mark.

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

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Carl Eugen Hoyos
Am So., 21. März 2021 um 22:13 Uhr schrieb Mark Filipak (ffmpeg)
:

> I think '-framerate 60' may not be needed at all.

It is only needed if 60fps recording is wanted.

As said before, setpts should generally be avoided and
this is even more true for settb. If you have to smooth
timestamps, use the fps filter or the ffmpeg option -r.

Carl Eugen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Mark Filipak (ffmpeg)

On 2021-03-21 13:31, Hassan wrote:


@Mark: I have tried to modify the setts and setpts options. Below is the
command:
ffmpeg -f gdigrab -framerate 60 -offset_x 550 -offset_y 350 -video_size
640x480 -thread_queue_size 1024 -i desktop -vf "settb=expr=1/72,
setpts=N*12000,fps=60,
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast ./test_SD_1.mkv
However, the seconds never increment and the milliseconds loop in three
values 0,333,666. Have a set anything incorrect in the command?.


Let's get the basics working, eh?

I think '-framerate 60' may not be needed at all.
These: '-offset_x 550 -offset_y 350 -video_size 640x480 -thread_queue_size 1024' can probably be 
left out for now.

'drawtext' can be left out for now.
Try this:
ffmpeg -f gdigrab  -i desktop -vf "settb=expr=1/72, setpts=N*12000, fps=60" -c:v libx264rgb 
-preset ultrafast ./test_SD_1.mkv

See if it works.



I have another challenge. I want to record at FPs higher than 60 FPS, i.e.,
120 FPS. For that, i set -framerate 120 and in -vf, I set r=120. However,
the recording that I get is just 60 FPS. Is it because my LCD has a refresh
rate of 60hz? Or FFmpeg is not concerned about LCD hardware? How can I
record at 120 FPS?

Another question is regarding the working of FFmpeg. Suppose, I am
capturing a video from a desktop that is playing at 60 FPS. My frame rate
for capturing is also set at 60 FPS. Is it likely that a frame of video
appears on LCD and the ffmpeg captures it at a delta of almost a full
frame, i.e., ~16. mec ? If so, then isn't recording a 60 FPS video with
-framerate 60 an incorrect choice?



On Mon, Mar 15, 2021 at 10:52 PM Mark Filipak (ffmpeg) 
wrote:


On 2021-03-15 13:43, Hassan wrote:

Hello,

I am using ffmpeg on a Windows 10 machine and I want to record the

desktop

at a high frame rate while appending accurate timestamps to each frame.
I am recording my desktop using the following command:

ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',


drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0
:x=10:y=10'"

-c:v libx264rgb -crf 0 -preset ultrafast output.mkv

The long text next to -vf flag is used to append timestamp (date and
current time in milliseconds) on the top left corner of the frame with
black background.

The issue is that, ideally, when I am recording at 60 FPS, each

subsequent

frame should have a timestamp with an increment of 16.66 msec. However,

the

timestamp is not incremented as such. Instead, it stays the same on a lot
of frames and then changes.

For example, when I break the video into frames, the frame titled
"img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
[image: image.png].
Then until "next 40 frames, it says the same. On file "img0469.png", the
timestamp changes and becomes 18:44:17.510.
[image: image.png]
So, the timestamp changed after 41 frames and the time difference is 682
milliseconds. Ideally, each of the 40 frames between these two frames
should carry an incremental timestamp by a step size of 16.66 msec but

this

is not happening.


Hello Hassan,

I don't know anything about 'gdigrab' but I have a lot of experience with
frame rate manipulation.

"I am recording at 60 FPS..."
A little higher than 60 fps. Look:

(468 - 428 + 1 frames)/(17510[+/-0.5...] - 16828[+/-0.5...] ms)(1000 ms/s)
= 60.029 to 60.206 frames/s.

"...with an increment of 16.66 msec."
The 'gdigrab' timing resolution may not be +/-0.01 ms. For example, it may
be +/-0.1 ms or even +/-1 ms.

If you can tolerate setting fps to exactly 60 (you're saving video to
disk, you're not streaming to
the Internet), put this:

settb=expr=1/72,setpts=N*12000,fps=60,

at the beginning of the filter chain. It will set frame rate to exactly
60fps and will also preserve
excellent timing resolution (0.013[8..] ms) in any succeeding processing
(without affecting the
final encoder).

Regards,
Mark.


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

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Carl Zwanzig

Please do not top-post on this list.

On 3/21/2021 10:31 AM, Hassan wrote:

... Following is the command.

ffmpeg -f gdigrab -framerate 60 -offset_x 550 -offset_y 350 -video_size
640x480 -thread_queue_size 1024 -i desktop  -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=30:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d\:3}.%{n}:fontsize=30:r=60:x=(w-tw)/2:
y=h-(2*lh):box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'" -c:v
libx264rgb -crf 0 -preset ultrafast ./test_SD_1.mkv


You always need to show the output of the command.


 it gives an error of Unterminated %{} near '{pts'. Can
you please help fix the above command?


But it looks like there's a quote nesting error in the drawtext, there's a 
end " but not a start.





I have another challenge. I want to record at FPs higher than 60 FPS, i.e.,
120 FPS. For that, i set -framerate 120 and in -vf, I set r=120. However,
the recording that I get is just 60 FPS. Is it because my LCD has a refresh
rate of 60hz? Or FFmpeg is not concerned about LCD hardware? How can I
record at 120 FPS?


Please don't add new questions to a topic, it's better to start a new one. 
However, ffmpeg doesn't know about the display hardware, and certainly not 
when you're using gdi, but yes, if the HW is a 60fps rate, the display 
driver isn't going to render more often since it doesn't need to.


If you _really_ want to capture with accurate timing and at faster than 
60fps, use a hardware device like a Blackmagic Decklink or Intensity card 
and get the actual output of the graphics card. You will need a second 
system to hold the card.


z!
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-21 Thread Hassan
So I have modified to recording resolution and applied the offset to
capture only the area of interest. It speeds up the capturing of timestamps
and I am getting a timestamp on each frame at an interval of (14ms to
18ms). Which is close to ideal 16.6msec for 60 FPS recording, yet not
accurate enough. Following is the command.

ffmpeg -f gdigrab -framerate 60 -offset_x 550 -offset_y 350 -video_size
640x480 -thread_queue_size 1024 -i desktop  -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=30:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d\:3}.%{n}:fontsize=30:r=60:x=(w-tw)/2:
y=h-(2*lh):box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'" -c:v
libx264rgb -crf 0 -preset ultrafast ./test_SD_1.mkv

@Marton: Could you please see the above command and let me know how to add
-copyts opinion? Also, when you mentioned the use of '%{pts\:localtime}'
variable expansion, it gives an error of Unterminated %{} near '{pts'. Can
you please help fix the above command?

@Mark: I have tried to modify the setts and setpts options. Below is the
command:
ffmpeg -f gdigrab -framerate 60 -offset_x 550 -offset_y 350 -video_size
640x480 -thread_queue_size 1024 -i desktop -vf "settb=expr=1/72,
setpts=N*12000,fps=60,
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast ./test_SD_1.mkv
However, the seconds never increment and the milliseconds loop in three
values 0,333,666. Have a set anything incorrect in the command?.


I have another challenge. I want to record at FPs higher than 60 FPS, i.e.,
120 FPS. For that, i set -framerate 120 and in -vf, I set r=120. However,
the recording that I get is just 60 FPS. Is it because my LCD has a refresh
rate of 60hz? Or FFmpeg is not concerned about LCD hardware? How can I
record at 120 FPS?

Another question is regarding the working of FFmpeg. Suppose, I am
capturing a video from a desktop that is playing at 60 FPS. My frame rate
for capturing is also set at 60 FPS. Is it likely that a frame of video
appears on LCD and the ffmpeg captures it at a delta of almost a full
frame, i.e., ~16. mec ? If so, then isn't recording a 60 FPS video with
-framerate 60 an incorrect choice?



On Mon, Mar 15, 2021 at 10:52 PM Mark Filipak (ffmpeg) 
wrote:

> On 2021-03-15 13:43, Hassan wrote:
> > Hello,
> >
> > I am using ffmpeg on a Windows 10 machine and I want to record the
> desktop
> > at a high frame rate while appending accurate timestamps to each frame.
> > I am recording my desktop using the following command:
> >
> > ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
> > setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
> >
> drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0
> :x=10:y=10'"
> > -c:v libx264rgb -crf 0 -preset ultrafast output.mkv
> >
> > The long text next to -vf flag is used to append timestamp (date and
> > current time in milliseconds) on the top left corner of the frame with
> > black background.
> >
> > The issue is that, ideally, when I am recording at 60 FPS, each
> subsequent
> > frame should have a timestamp with an increment of 16.66 msec. However,
> the
> > timestamp is not incremented as such. Instead, it stays the same on a lot
> > of frames and then changes.
> >
> > For example, when I break the video into frames, the frame titled
> > "img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
> > [image: image.png].
> > Then until "next 40 frames, it says the same. On file "img0469.png", the
> > timestamp changes and becomes 18:44:17.510.
> > [image: image.png]
> > So, the timestamp changed after 41 frames and the time difference is 682
> > milliseconds. Ideally, each of the 40 frames between these two frames
> > should carry an incremental timestamp by a step size of 16.66 msec but
> this
> > is not happening.
>
> Hello Hassan,
>
> I don't know anything about 'gdigrab' but I have a lot of experience with
> frame rate manipulation.
>
> "I am recording at 60 FPS..."
> A little higher than 60 fps. Look:
>
> (468 - 428 + 1 frames)/(17510[+/-0.5...] - 16828[+/-0.5...] ms)(1000 ms/s)
> = 60.029 to 60.206 frames/s.
>
> "...with an increment of 16.66 msec."
> The 'gdigrab' timing resolution may not be +/-0.01 ms. For example, it may
> be +/-0.1 ms or even +/-1 ms.
>
> If you can tolerate setting fps to exactly 60 (you're saving video to
> disk, you're not streaming to
> the Internet), put this:
>
> settb=expr=1/72,setpts=N*12000,fps=60,
>
> at the beginning of the filter chain. It will set frame rate to exactly
> 60fps and will also preserve
> excellent timing resolution (0.013[8..] ms) in any succeeding processing
> (without affecting the
> final encoder).
>
> Regards,
> Mark.
> 

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-15 Thread Mark Filipak (ffmpeg)

On 2021-03-15 13:43, Hassan wrote:

Hello,

I am using ffmpeg on a Windows 10 machine and I want to record the desktop
at a high frame rate while appending accurate timestamps to each frame.
I am recording my desktop using the following command:

ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast output.mkv

The long text next to -vf flag is used to append timestamp (date and
current time in milliseconds) on the top left corner of the frame with
black background.

The issue is that, ideally, when I am recording at 60 FPS, each subsequent
frame should have a timestamp with an increment of 16.66 msec. However, the
timestamp is not incremented as such. Instead, it stays the same on a lot
of frames and then changes.

For example, when I break the video into frames, the frame titled
"img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
[image: image.png].
Then until "next 40 frames, it says the same. On file "img0469.png", the
timestamp changes and becomes 18:44:17.510.
[image: image.png]
So, the timestamp changed after 41 frames and the time difference is 682
milliseconds. Ideally, each of the 40 frames between these two frames
should carry an incremental timestamp by a step size of 16.66 msec but this
is not happening.


Hello Hassan,

I don't know anything about 'gdigrab' but I have a lot of experience with frame 
rate manipulation.

"I am recording at 60 FPS..."
A little higher than 60 fps. Look:

(468 - 428 + 1 frames)/(17510[+/-0.5...] - 16828[+/-0.5...] ms)(1000 ms/s) = 
60.029 to 60.206 frames/s.

"...with an increment of 16.66 msec."
The 'gdigrab' timing resolution may not be +/-0.01 ms. For example, it may be 
+/-0.1 ms or even +/-1 ms.

If you can tolerate setting fps to exactly 60 (you're saving video to disk, you're not streaming to 
the Internet), put this:


settb=expr=1/72,setpts=N*12000,fps=60,

at the beginning of the filter chain. It will set frame rate to exactly 60fps and will also preserve 
excellent timing resolution (0.013[8..] ms) in any succeeding processing (without affecting the 
final encoder).


Regards,
Mark.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-15 Thread Marton Balint



On Mon, 15 Mar 2021, Hassan wrote:


Hello,

I am using ffmpeg on a Windows 10 machine and I want to record the desktop
at a high frame rate while appending accurate timestamps to each frame.
I am recording my desktop using the following command:

ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast output.mkv

The long text next to -vf flag is used to append timestamp (date and
current time in milliseconds) on the top left corner of the frame with
black background.

The issue is that, ideally, when I am recording at 60 FPS, each subsequent
frame should have a timestamp with an increment of 16.66 msec. However, the
timestamp is not incremented as such. Instead, it stays the same on a lot
of frames and then changes.

For example, when I break the video into frames, the frame titled
"img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
[image: image.png].
Then until "next 40 frames, it says the same. On file "img0469.png", the
timestamp changes and becomes 18:44:17.510.
[image: image.png]
So, the timestamp changed after 41 frames and the time difference is 682
milliseconds. Ideally, each of the 40 frames between these two frames
should carry an incremental timestamp by a step size of 16.66 msec but this
is not happening.

Therefore, my questions are as follows:
1. Am I using the right method to append timestamps to the recorded frames?


No. If you use a filter to set timestamps, that definitely will cause 
jitter in the output.



2. What is the reason that the timestamping on the frames is not correct?


Because you are setting time timestamps in a filter. If you want something 
like 10 millisecond accuracy, filter processing delays, or encoding 
latencies are not negligable at all.



3. How can I fix this issue?


Use the original timestamps which are returned by gdigrab. Also use
-copyts to pass the timestamps to the filters unmodified. Also use
-thread_queue_size parameter to enable threaded reading of input. And use 
'%{pts\:localtime}' variable expansion to get the date based on frame 
timestamp.



4. What are the alternate methods to append accurate epoch timestamps to
each of the recorded frames?


As stated above. Note that it will still not be very accurate. In order to 
make it better I think a more accurate av_usleep() implementation is 
needed on Windows. With that, it should be decent enought.


Regards,
Marton
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-15 Thread pdr0
Hassan wrote
> Hello,
> 
> I am using ffmpeg on a Windows 10 machine and I want to record the desktop
> at a high frame rate while appending accurate timestamps to each frame.
> I am recording my desktop using the following command:
> 
> ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
> setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
> drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
> -c:v libx264rgb -crf 0 -preset ultrafast output.mkv
> 
> The long text next to -vf flag is used to append timestamp (date and
> current time in milliseconds) on the top left corner of the frame with
> black background.
> 
> The issue is that, ideally, when I am recording at 60 FPS, each subsequent
> frame should have a timestamp with an increment of 16.66 msec. However,
> the
> timestamp is not incremented as such. Instead, it stays the same on a lot
> of frames and then changes.
> 
> For example, when I break the video into frames, the frame titled
> "img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
> [image: image.png].
> Then until "next 40 frames, it says the same. On file "img0469.png", the
> timestamp changes and becomes 18:44:17.510.
> [image: image.png]
> So, the timestamp changed after 41 frames and the time difference is 682
> milliseconds. Ideally, each of the 40 frames between these two frames
> should carry an incremental timestamp by a step size of 16.66 msec but
> this
> is not happening.
> 
> Therefore, my questions are as follows:
> 1. Am I using the right method to append timestamps to the recorded
> frames?
> 2. What is the reason that the timestamping on the frames is not correct?
> 3. How can I fix this issue?
> 4. What are the alternate methods to append accurate epoch timestamps to
> each of the recorded frames?
> 
> Please guide me. Thanks.
> 
> -- 
> Regards
> Hassan Iqbal


gdigrab is not very optimized. 

Your hardware might not be fast enough to capture desktop at 60fps,
resulting in dropped frames, and thus wrong times. Look at the console
output for the fps for a rough idea of the processing speed on your system





--
Sent from: http://ffmpeg-users.933282.n4.nabble.com/
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

[FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

2021-03-15 Thread Hassan
Hello,

I am using ffmpeg on a Windows 10 machine and I want to record the desktop
at a high frame rate while appending accurate timestamps to each frame.
I am recording my desktop using the following command:

ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black@1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast output.mkv

The long text next to -vf flag is used to append timestamp (date and
current time in milliseconds) on the top left corner of the frame with
black background.

The issue is that, ideally, when I am recording at 60 FPS, each subsequent
frame should have a timestamp with an increment of 16.66 msec. However, the
timestamp is not incremented as such. Instead, it stays the same on a lot
of frames and then changes.

For example, when I break the video into frames, the frame titled
"img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
[image: image.png].
Then until "next 40 frames, it says the same. On file "img0469.png", the
timestamp changes and becomes 18:44:17.510.
[image: image.png]
So, the timestamp changed after 41 frames and the time difference is 682
milliseconds. Ideally, each of the 40 frames between these two frames
should carry an incremental timestamp by a step size of 16.66 msec but this
is not happening.

Therefore, my questions are as follows:
1. Am I using the right method to append timestamps to the recorded frames?
2. What is the reason that the timestamping on the frames is not correct?
3. How can I fix this issue?
4. What are the alternate methods to append accurate epoch timestamps to
each of the recorded frames?

Please guide me. Thanks.

-- 
Regards
Hassan Iqbal
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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