Image and video processing recipes

I often need to perform some operations on videos or image sequences. Usually I use linux and `ffmpeg`, and sometimes I struggle to remember all the commands. Here is a collection of recipes that I usually use with a bit of explanations. Video conversions ========================== Cut a range of frames --------------------------- Cut a range of frames (100, 130) from a video and save it to mp4 with a good quality using x264 codec: ....

March 27, 2020 · SergeM

Streaming camera output from Raspberry Pi

Task was to transmit image from camera on raspberry pi through web interface to the PC. PC is connected to raspberry through local network. Enable camera on your raspberry pi in raspi-conf. Reboot. Save the following source code to a file on your raspberry (let’s say do sudo pip3 install picamera run python3 on the target machine (PC) go to http://<your raspberry ip or host name>:8000. output from the camera must be streaming in realtime....

May 23, 2017 · SergeM

Convert all *.avi files in current directory to png sequences

Using python and ffmpeg: 1 2 3 4 5 6 7 8 9 10 11 12 13 #!/usr/bin/python import glob import os t=glob.glob("*.avi" ) # search all AVI files for v in t: vv = os.path.splitext(v)[0]; os.makedirs( vv ) # make a directory for each input file pathDst = os.path.join( vv, "%05d.png" ) # deststination path os.system("ffmpeg -i {0} {1}".format( v, pathDst ) )

October 22, 2013 · SergeM