Ffmpeg record screen update

I often write about ffmpeg, because I use it for my videos. The reason I use ffmpeg, this tool to manipulate video, record screen etc. is due to the fact that it is fast, once you understood the command you need (not easy indeed) your workflow goes to the speed of light, and that is saves memory as the .mp4 of the recorded screen are very light. You can do a lot of things. Last thing that I am trying is recording just a window, to save even more memory. It is not so easy, but I am experimenting. I want to share this fact here, a bit curious. I wanted to record the Prompt of windows, but it gave me some errors do to the dimension of the window, something like … this screen size is not divisible… so, I tryied different sizes until I put the col and row in the property of the window to 100×20 and… it worked! So these are the commands, but remember to choose a divisible size (!).

This dimentions worked for me

Create a .bat file like this

ffmpeg -rtbufsize 1500M -f dshow -i audio="Microfono (8- Logitech USB Headset)" -f gdigrab -framerate 30 -draw_mouse 1 -i title="Prompt dei comandi" -pix_fmt yuv420p -profile:v baseline -y output\output3_xp.mp4
pause

The devices… how to check the name of the mic

Save a .bat file with these commands if you need to know the name of the mic to substitute the one in the code above, because in each pc it is different

ffmpeg -list_devices true -f dshow -i dummy

pause

An example

This is what I recorded as an example

Another example

In this example, instead, I haven’t had the problems I had with the Prompt… I used this python file code that asks me the name of the window (in this exampe is Python):

import os

name = input("Window name: ")
os.system("""ffmpeg -rtbufsize 1500M -f dshow -i audio="Microfono (8- Logitech USB Headset)" -f gdigrab -framerate 30 -draw_mouse 1 -i title=""" + name + """ -pix_fmt yuv420p -profile:v baseline -y output\\output2.mp4""")

This is an example of a recording of the Python window …

Record just a window for some time

To record a specific window (by its name) and for a specific amount of time, you can use this code and save it as a .bat file

ffmpeg -rtbufsize 1500M -f dshow -i audio="Microfono (8- Logitech USB Headset)" -f gdigrab -framerate 30 -draw_mouse 1 -i title=Trace -pix_fmt yuv420p -profile:v baseline -y -t 00:00:30 win30sec.mp4

pause

The duration is the -t 00:00:30

You can change it to the duration you want.

Ffmpeg & Python for videos

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.