How to extract the very starting frame for every second on a live videi input?
Hi everyone, I am trying yo select select the very starting frame of every second on a live input video. Input is a .ts file. I have a command to select the 0th frame of every second on a non-live video. ffmpeg -i INPUT.ts -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" output-%04d.png But this is useless for me, as I want to work on live feed. I have tried another command also i.e ffmpeg -i INPUT.ts -vf "select='if(not(floor(mod(t,1)))*lt(ld(1),1),st(1,1)+st(2,n)+st(3,t));if(eq(ld(1),1)*lt(n,ld(2)+1),1,if(trunc(t-ld(3)),st(1,0)))'" -vsync 0 out%d.png The above command extracting the frames but they are not in the correct order as per the time. I have ran the command on TCR time code video to check whether the frames are in sync. Can anyone help me on this? Regards, -- Sent from: http://www.ffmpeg-archive.org/
Am Mo., 13. Apr. 2020 um 15:12 Uhr schrieb Ramana <ramanajajula9@gmail.com>:
I am trying yo select select the very starting frame of every second on a live input video. Input is a .ts file. I have a command to select the 0th frame of every second on a non-live video.
ffmpeg -i INPUT.ts -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" output-%04d.png
But this is useless for me, as I want to work on live feed.
Why would this command not work on a live feed? Carl Eugen
Hi Carl, Thanks for your response. I don't know, it is extracting the more and more number of frames, I have scheduled the live input feed as 1 hour video for 24x7. currently I am using the ffmpeg -i input.ts -vf fps=1 output_%d.jpg command to extract the frames for every second. When I compared the extracted frames for example with the 1800th frame(It is supposed to at 30th min zero-th frame). But actual frame is extracted at 30th min 12th frame. Not only for 1800th frame. Every frame is extracting at 12th frame for every second. To overcome this, I used the below command. ffmpeg -i INPUT.ts -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" output-%04d.jpg The above command is extracting the zero-th frame on every second total number of extracted frames are 3600. But, it is not working on live feed. It is extracting almost 100000 frames per hour when I run it on live feed. I don't know the exact reason for this. -- Sent from: http://www.ffmpeg-archive.org/
Am Mo., 13. Apr. 2020 um 15:29 Uhr schrieb Ramana <ramanajajula9@gmail.com>:
ffmpeg -i INPUT.ts -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" output-%04d.jpg
The above command is extracting the zero-th frame on every second total number of extracted frames are 3600. But, it is not working on live feed.
It is extracting almost 100000 frames per hour when I run it on live feed.
I don't know the exact reason for this.
(Complete, uncut console output missing) Since the live stream can start at any frame within a second, I don't think counting frames will help you to get the first frame of a second. Carl Eugen
Okay, is there any way to extract the first frame of each and every second for this live input stream. I tried with the below command also, but they are not in the sync. ffmpeg -i INPUT.ts -vf "select='if(not(floor(mod(t,1)))*lt(ld(1),1),st(1,1)+st(2,n)+st(3,t));if(eq(ld(1),1)*lt(n,ld(2)+1),1,if(trunc(t-ld(3)),st(1,0)))'" -vsync 0 out%d.jpg Could you or anyone suggest me to do any modifications or any options to achieve this on live feed? -- Sent from: http://www.ffmpeg-archive.org/
Am Mo., 13. Apr. 2020 um 15:29 Uhr schrieb Ramana <ramanajajula9@gmail.com>:
I don't know, it is extracting the more and more number of frames, I have scheduled the live input feed as 1 hour video for 24x7. currently I am using the ffmpeg -i input.ts -vf fps=1 output_%d.jpg command to extract the frames for every second.
When I compared the extracted frames for example with the 1800th frame(It is supposed to at 30th min zero-th frame). But actual frame is extracted at 30th min 12th frame. Not only for 1800th frame. Every frame is extracting at 12th frame for every second.
Did you see the documentation of the select filter? https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect Did you try to test the pts for whole seconds? Carl Eugen
Hi Carl, I am very beginner to ffmpeg. I usually get the commands from the browsing from online blogs. I don't know how to set those options clearly. Could you send me an example to use this pts and prev_pts options in the command? Also I tried the below command to extract. ffmpeg -i INPUT.ts -vf "select=not(mod(n\,25))" -vsync vfr -q:v 2 output_%d.jpg The above command is also not working, as it is extracting the more number of frames. -- Sent from: http://www.ffmpeg-archive.org/
Ramana (12020-04-13):
I am trying yo select select the very starting frame of every second on a live input video. Input is a .ts file. I have a command to select the 0th frame of every second on a non-live video.
-vf fps=1 If necessary, play with the rounding option, or use setpts to finely adjust the phase. Regards, -- Nicolas George
HI Nicolas George, Thanks for your response, when I use -vf fps=1 option, ffmpeg is extracting the 12th frame of every second. Could you tell me how can we use those setpts and rounding options and phase in the command, How can I make use of them properly? Any pseudo example would be fine. Regards. -- Sent from: http://www.ffmpeg-archive.org/
emb-pro (12020-04-13):
Thanks for your response, when I use -vf fps=1 option, ffmpeg is extracting the 12th frame of every second. Could you tell me how can we use those setpts and rounding options and phase in the command, How can I make use of them properly? Any pseudo example would be fine.
Have you read the doc? What did you try? -- Nicolas George
Hi Nicolas George, I have tried using the select filter option. -vf "select=not(mod(n\,25))" -vsync 0 The frames extracted are not in sync. I checked this on a tcr time code video. Regards. -- Sent from: http://www.ffmpeg-archive.org/
HI Nicolas, This is also one of my trials to get the output. -vf "select='if(not(floor(mod(t,1)))*lt(ld(1),1),st(1,1)+st(2,n)+st(3,t));if(eq(ld(1),1)*lt(n,ld(2)+1),1,if(trunc(t-ld(3)),st(1,0)))'" -vsync 0 The above command is extracting the frames, but they are not in the sync. Regards. -- Sent from: http://www.ffmpeg-archive.org/
emb-pro (12020-04-13):
This is also one of my trials to get the output.
That's not the fps filter. What have you tried to get the fps filter to work? Have you read the its documentation and that of setpts? Regards, -- Nicolas George
Hi Nicolas, I have used the pts the pts options like below, ffmpeg -i input.ts -vf "select='if(eq(n\,0),1,floor(t)-floor(prev_selected_t))" -vsync 0 output-%04d.png But it is not extracting properly. Regards. -- Sent from: http://www.ffmpeg-archive.org/
emb-pro (12020-04-14):
Hi Nicolas,
If you want help, start by helping yourself. Use the advice I gave you in the previous mails or don't, but it is there. -- Nicolas George
participants (4)
-
Carl Eugen Hoyos -
emb-pro -
Nicolas George -
Ramana