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

Refactoring python code. Extracting variables and other.

Pycon2016 talk by Brett Slatkin Example 1: Extract variable import random month = random.choice(MONTHS) if (month.lower().endswith('r') or month.lower().endswith('ary')): print('%s is a good time to eat oysters' % month) elif 8 > MONTHS.index(month) > 4: print('%s is a good time to eat tomatoes' % month) else: print('%s is a good time to eat asparagus' % month) Becomes: class OystersGood: def __init__(self, month): month = month month_lowered = month.lower() self.ends_in_r = month_lowered.endswith('r') self....

October 8, 2016 · SergeM

Useful python links

Books Test-Driven Development with Python Harry Percival Python Testing with unittest, nose, pytest : eBook Testing Python: Applying Unit Testing, TDD, BDD and Acceptance Testing link . Videos Outside-In TDD Harry Percival, PyCon 2016 Докеризация веб приложения на Python, Антон Егоров Thinking about Concurrency, Raymond Hettinger, Python core developer Tutorials Разработка идеального pypi пакета с поддержкой разных версий python (Rus), 2020. The Little Book of Python Anti-Patterns - an awesome collection of best practices with examples....

October 8, 2016 · SergeM

every day photos

https://vimeo.com/108551893 - 16 years, related http://jk-keller.com/daily-photo/related-photo-projects/ http://www.365plrds.com/slideshow.html https://www.youtube.com/watch?v=tWzPDNabdBs https://www.youtube.com/watch?v=3MPyoAN4FIk https://www.youtube.com/watch?v=qJutZCyXEJg https://www.youtube.com/watch?v=qJutZCyXEJg https://www.youtube.com/watch?v=JSzL-osslUg https://www.youtube.com/watch?v=9_Fms1Yyanc https://www.youtube.com/watch?v=nN_jcom8TR4 https://www.youtube.com/watch?v=NQxyfOpZmAQ https://www.youtube.com/watch?v=ZGgd0DUKok4 https://vimeo.com/99392 https://vimeo.com/125593599 https://vimeo.com/47134932 https://www.youtube.com/watch?v=VVe92OXwJpk https://www.youtube.com/watch?v=OxT4HaE-ZdM https://www.youtube.com/watch?v=e5sgWG2saxs https://www.youtube.com/watch?v=Ertu9_MhFiM https://www.youtube.com/watch?v=HWBqTyUfPlk upd 201701: https://www.youtube.com/watch?v=AfcDuysiej0 Upd 201712: https://youtu.be/zuRd_Eneuk8 https://www.youtube.com/watch?v=65nfbW-27ps https://www.youtube.com/watch?v=nPxdhnT4Ec8 https://www.youtube.com/watch?v=iPPzXlMdi7o https://gfycat.com/familiarbriefiberianemeraldlizard https://www.youtube.com/watch?v=kPRXTwM3kYM up 2019 01 https://www.reddit.com/r/videos/comments/alp7ng/i_took_a_photo_every_day_from_12_years_old_until/ Update 2020 01 https://youtu.be/yfqpqiTMUEg

May 26, 2015 · 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

Using h264/multiview codec from Intel Media SDK

I needed to launch multiview compression using codec from Intel MVC. Approximately a half a year ago I launched it normally. Yesterday it tried and I got such an error: $ ./sample_encode.exe h264 -i input.yuv -o output.h264 -w 1920 -h 1080 Return on error: error code -3, .\src\pipeline_encode.cpp 865 Return on error: error code 1, .\src\sample_encode.cpp 343 Frame number: 0 I started debug and found out the error appears in...

October 11, 2013 · SergeM

Trim frames from raw YUV video using FFMPEG

Trim 5 frames starting from 160-th frame and write to png sequence ffmpeg -pix_fmt yuv420p -s 1920x1088 -r 1 -i input_video.yuv -r 1 -ss 160 -frames 5 output_sequence_%d.png size of input video is 1920x1088, format YUV420 progressive. UPD: ffmpeg is renamed to avconv. Using it for trimming AVI video: avconv -ss 00:58:00 -t 00:59:30 -i ./video.avi frame_%05d.png UPD2: it seems ffmpeg is back.

July 2, 2013 · SergeM

SSIM по русски

Нужно будет тут записать как работает метрика SSIM по человечески

May 28, 2013 · SergeM