Skip to main content

Posts

Showing posts from November, 2018

Setting up virtual environment for Python

Many specialized tools are written for some version of Python like python2.7 and has dependencies on some versions of packages like pandas 0.7.3. Installing these older versions will remove newer versions and create conflicts with existing code. So a better option is to create a virtual environment with the specific package versions only. For example, QSTK does not work with Python 3 or pandas 0.21. It only works with python2.7 and pandas 0.7.3. So we have to create a virtual environment and install these versions. virtualenv --python=/usr/bin/python2.7 ~/python2.7-virtual-env This will create the ~/python2.7-virtual-env directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter, the standard library, and various supporting files. Now go to that directory and run source activate to start a new environment (just like a chroot environment). source ~/python2.7-virtual-env/bin/activate This will start a new envi

Batch rotate video files

I like to capture videos of scenery while I am driving. I do that with the help of my phone mounted on a car cell phone holder. The phone keeps recording and later I edit out the boring parts. Now, this works very well when the phone is already mounted in the horizontal position when the recording starts and as well when it ends. However, if for any reason I pick up the phone anytime during recording the video gets saved in a vertical format. So I have to rotate those videos a lot. They can also be rotated in a video editing software like Kdenlive by applying the "Rotate" effect. However, then the video gets chopped off from the sides. I find it easier to rotate the videos before importing them to the video editing software. Since a lot of videos might end up being vertical when they should be horizontal I have to rotate a lot of videos. So I wrote a batch script to rotate a bunch of videos at once. The script runs on every mp4 file in the directory. The script needs to be