Showing posts with label Linux Tools. Show all posts
Showing posts with label Linux Tools. Show all posts

Friday, July 27, 2012

Tips and Tricks for Linux

I am going to put down useful commands for Linux here and continuously update it. If you want to contribute to this page, please post your suggestion in comments.
1) Installing from a .iso file
Easiest thing to do is to mount the .iso in a tmp location and install it from there.
sudo mkdir /tmp/matlab 
sudo mount /<path to .iso file>/matlab.iso /tmp/matlab -t iso9660  -o loop=/dev/loop0
2) Using FFmpeg to break a video into parts
ffmpeg -i STOPS_20111214_CR1_02_C5.mov -sameq -ss 00:00:00 -t 00:00:30 videopart1.mov

So this code takes in a video named STOPS_20111214_CR1_02_C5.mov, uses all the parameters of video such as framerate, bit rate to make a new video and extracts all the frames from start time of 0 seconds to end time of 30 secs and writes it as videopart1.mov
3) Overcoming too many threads error of ffmpeg
http://crazedmuleproductions.blogspot.com/2007/10/multithreading-in-ffmpeg-and-mpstat.html

Wednesday, June 27, 2012

Renaming Files in a folder using Shell in Linux

I work with a lot of different image dataset and find it helpful if the image files are named in a particular order that I want. Below is the script that will convert all the 'png' files in a folder into frame_%05d.png format.

#!/bin/sh
prefix=$1

count=1
for f in *.png; do
    nn=`printf %05d $count`
    mv "$f" "frame_$prefix$nn".png
    count=`expr $count + 1`
done

Save this script as a .sh file (maybe frameconvert.sh) and then you can run it from command prompt using 'sh frameconvert.sh' . You can modify this script for your own purposes.