Home > OS >  Extract text between
Extract text between

Time:09-23

Could you please help me?

frame=48612 fps= 50 q=28.0 size=  113664kB time=00:33:45.42 bitrate= 459.7kbits/s speed=2.09x    
frame=48612 fps= 50 q=28.0 size=  113664kB time=00:33:45.45 bitrate= 459.7kbits/s speed=2.09x    
frame=48613 fps= 51 q=28.0 size=  113664kB time=00:33:45.45 bitrate= 459.7kbits/s speed=2.09x    
frame=48613 fps= 50 q=28.0 size=  113664kB time=00:33:45.47 bitrate= 459.7kbits/s speed=2.09x    
frame=48613 fps= 49 q=28.0 size=  113664kB time=00:33:45.49 bitrate= 459.7kbits/s speed=2.09x    
frame=48614 fps= 50 q=28.0 size=  113664kB time=00:33:45.49 bitrate= 459.7kbits/s speed=2.09x    
frame=48614 fps= 50 q=28.0 size=  113664kB time=00:33:45.51 bitrate= 459.7kbits/s speed=2.09x    
frame=48614 fps= 51 q=28.0 size=  113664kB time=00:33:45.53 bitrate= 459.7kbits/s speed=2.09x    
frame=48615 fps= 50 q=28.0 size=  113664kB time=00:33:45.53 bitrate= 459.7kbits/s speed=2.09x    
frame=48615 fps= 50 q=28.0 size=  113664kB time=00:33:45.55 bitrate= 459.7kbits/s speed=2.09x    
frame=48615 fps= 50 q=28.0 size=  113664kB time=00:33:45.57 bitrate= 459.7kbits/s speed=2.09x    
frame=48616 fps= 52 q=25.0 size=  113664kB time=00:33:45.57 bitrate= 459.7kbits/s speed=2.09x    

Do you know if it's possible to remove everything except FPS={num}? I want to output something like this:

50
50
51
50
49
50
...

What I have tried:

ffmpeg -i in.mp4 -stats_period 0.0001 out.mp4 | grep -o -P '(?<=fps= ).*(?= q=)'
ffmpeg -i in.mp4 -stats_period 0.0001 out.mp4 | grep fps | awk '{print $2}' | tr -d , 

Both do not work!

uname -svr => Linux 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021

Also, ffmpeg return each frame per second, isn't a static .txt file.

Thank you.

CodePudding user response:

Use the progress option to pipe stats to stdout and grep that.

ffmpeg -i in.mp4 -stats_period 0.0001 -progress pipe:1 out.mp4 | grep -oP "(?<=fps=)\d \.\d "

CodePudding user response:

Try the following:

ffmpeg -i in.mp4 -stats_period 0.0001 out.mp4 | awk -v OFS=" " '{print $3}'
  • Related