Posts Tagged ‘totem’

How to take multiple screenshots with scrot and ImageMagick import commands in terminal on GNU / Linux and FreeBSD

Friday, January 13th, 2012

scrot and import are two commands, which can be used to take screenshot in terminal on Linux and FreeBSD:

To use scrot cmd to take screenshots on Ubuntu and Debian the scrot package has to be installed:

noah:~# apt-get install scrot
...

scrot should also be available on most other Linux distributions in the main repositories, I'll be glad to hear if someone has used it on Fedora, SUSE etc.

On FreeBSD, there is a port called scrot , to install on FreeBSD:

freebsd# cd /usr/ports/graphics/scrot
freebsd# make install clean
...

Scrot has plenty of nice arguments one can use to make a screenshot. Maybe the most handy one in my view is after a preliminary set delay before screenshot is taken.

To take screenshot with it after lets say 5 seconds delay before the screenshot:

hipo@noah:~/Desktop$ scrot -t 20 -d 5

Screenshot scrot my debian Linux gnome-termina

To put an year, month and day and year followed by screen resolution with scrot :

hipo@noah:~$ scrot '%Y-%m-%d_$wx$h.png'

Another way to take a screenshot of screen with command is by using ImageMagick'simport image manipulation package.
To take screenshot of the current screen via terminal using import , type in xterm, gnome-termina or Gnome's Run Application (ALT+F2)

hipo@noah:~$ import -window root ScreenShot.png

To make import command to save the taken screenshot in a format (minute:hour:day:month:year)i :

hipo@noah:~$ import -window root $screenshot_dir/screenshot-$(date +%M_%k_%d_%m_%Y|sed -e 's/^ *//').png

Taking a delayed screenshot is also possible via The GIMP via menus File -> Create -> Screenshot

GIMP Screenshot 15 seconds delay GIMP window screenshot

Now here is an interesting question, what if I would like to take periodic screenshots of what I do on my Desktop to take random movie scenes from a movie I watch with totem or vlc??

This task is quite easily achiavable with a little bash shell script, I wrote:

screenshot_dir='Screenshots';
seconds='60';
if [ ! -d "$screenshot_dir" ]; then
mkdir $screenshot_dir;
fi
while [ 1 ]; do
sleep $seconds;
(import -window root $screenshot_dir/screenshot-$(date +%M_%k_%d_%m_%Y|sed -e 's/^ *//').png) &
done

This script will take screenshot automatically to Screenshots/ directory every (1 min – 60 seconds)
You can also my downloads take_screenshot_every_60_secs_import.sh here

To use take_screenshot_every_60_secs_import.sh just issue the script inside xterm or gnome-terminal, after that simply use your computer as you normally would.
The script will take snapshots every minute and store all taken screenshots in Screenshots dir.

If you prefer to use scrot to take automatically the screenshots every lets say 5 minutes, you can use a script like:

screenshot_dir='Screenshots';
# 300 secs (5 mins)seconds='300';
if [ ! -d "$screenshot_dir" ]; then
mkdir $screenshot_dir;
fi
while [ 1 ]; do
sleep $seconds;
(scrot $screenshot_dir/'%Y-%m-%d_$wx$h.png') &
done

You can fetch take_screenshot_every_60_secs_scrot.sh here

The script using scrot is better in terms of efficiency, the system load scrot will put on your machine will be less.
Using some of this scripts will be handy if you need screenshots to Movies, Programs and favourite Free Software games.
Hope this is educative to someone 😉

How to play VCD videos in Debian Linux

Monday, September 26th, 2011

Totem VCD error occured, could not open location you might not have permissions to open the file

A friend of mine gave me a VCD with some coptic Orthodox Christian exorcism, where there pope was chasing some evil spirits from possessed muslims who came to the Coptic Orthodox Church in egypt. The video was made to be in VCD and as you can expect this did not worked out of the box with Totem and VLC out of the box.
Putting in the VCD video inside my cdrom poped up an error like the one in the header of the post.
In order to make the video play I had to use the old school and now a bit obsolete mplayer.
Hence in order to play the VCD on Debian Linux I had to install mplayer and w32codecs packages first e.g.:

debian:~# apt-get update && apt-get install mplayer w32codecs

Second to play the video from gnome-terminal, I had to switch to the mounted cdrom location /media/cdrom0 and launch the video with mplayer cmd like so:

debian:~$ cd /media/cdrom0/vcd
debian:/media/cdrom0/vcd$ mplayer vcd://2
...

In some cases it might be necessery to play the video with mplayer command like:

debian:/media/cdrom0/vdd$ mplayer vcd://2 vcd://3

Watching it with mplayer from console has some downsides as I couldn’t make the fast rewind work, but still it’s way better than nothing.
Too bad in Debian Squeeze 6 gmplayer is no longer installable. The gmplayer can probably be installed if mplayer is compiled from source, but I’m too lazy to try it out.
I’ve red also in some forums online that gxine is capable of playing the VCD play nice, but I couldn’t install it from my existing Debian repositories so I did not give it a go.

How to edit, convert, join, split and re-time movie subtitle files on Linux (Fix Subtitles bad timing) / Install subtitle manipulation console tools for Linux

Tuesday, April 19th, 2011

As a Linux user I sometimes face difficulties with watching subtitled, movies. I mostly use Mplayer, Totem or VLC to watch the common video files.
The most common problems I face with subtitles are caused by bad timing, many times the solution to the bad timing issues is very simpleand comes up to changing the default movie player I use MPlayer to VLC or Totem.

However at many occasions trying to watch the movie with different kind of movie player does not help.
In this dark moments I get seriously irritated I am not a regular Windows user, where such kind of problems are almost none as many of the Windows movie player problems does fix bad timing issues automatically.

Luckily there is a work-around to this subtitles timing issues and other mishaps caused by guys who created a Movie subtitle files with a Windows subtitle editor program, subtitles timing, the Linux work-around takes a few more minutes to install a package called Subtitles

The Subtitles text utility is written in Perl and contains two executables subplay and subs .

Subtitles is the Linux subtitle Swiss Army Knife as it is capable of convert, join, split, and re-time of subtitles files

Installing Subtitles tools on Linux is a trivial job and it comes to download and installation of the 2 perl executables.
Here is how:

1. Download Subtitles.tar.gz toolsI have mirrored Linux Subtitles (Subtitles.tar.gz) here originally the binaries are to be found on URL address: http://karasik.eu.org/software/ , issue the commands:

linux:~# cd /usr/local/src
linux:/usr/local/src# wget https://www.pc-freak.net/files/Subtitles.tar.gz
...
2. Unarchive it

linux:/usr/local/src# tar -zxvvf tar -zxvvf Subtitles.tar.gz...
linux:/usr/local/src# cd Subtitles-1.0

3. Compile and install Subtitles system widePitily the Subtitles tools are not currently available as a packages in the repositories of Debian and Ubuntu Linux and thus easy installation without compilation via apt-get is unfortunately not available.

Here is the commands with which to compile and install Subtitles:

linux:/usr/local/src/Subtitles-1.0# perl Makefile.PL
...
linux:/usr/local/src/Subtitles-1.0# make
...
linux:/usr/local/src/Subtitles-1.0# make test
...

All tests successful.Files=1, Tests=17, 1 wallclock secs ( 0.05 usr 0.00 sys + 0.06 cusr 0.01 csys = 0.12 CPU)Result: PASS

linux:/usr/local/src/Subtitles-1.0# make install

Installing /usr/local/share/perl/5.10.1/Subtitles.pm
Installing /usr/local/man/man1/subplay.1p
Installing /usr/local/man/man1/subs.1p
Installing /usr/local/man/man3/Subtitles.3pm
Installing /usr/local/bin/subplay
Installing /usr/local/bin/subs
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod

Now as we have the subs executable installed, Let’s say your movie subtitles displays 5 seconds earlier before the movie scenes (bad timing), all you need to do to adjust your subtitles to show up in correct movie scenes is issue:

hipo@linux:/home/hipo/Movies$ subs -i -b 5 your_movie_subtitle_file_name.sub

now check out the subtitle files once again with your favourite player and the early subtitles display on your movie should be fixed.
Let’s have another scenario, say that your movie file is encoded to display 24 frames per seconds (fps) but the subtitle file is created to display the subtitles for a 25 fps, to solve this situation issue:

hipo@linux:~# subs -i -a 24/25 your_movie_subtitle_file.sub

Another possible scenario where subs command will be a precious asset is if you for example want to merge two subtitle files into one.Let’s say you have subtitles for a movie which are split over in 2 parts and the corresponding subtitles are in 2 different files, but eventually you find a better quality of the movie (DVD quality) in a single file and therefore you need the movie subtitles to be stored in one single file.
In that case to merge the subtitle files from let’s say the files movie_subtitle_file1.sub and movie_subtitle_file2.sub use the command:

subs -z movie_subtitle_file1.sub movie_subtitle_file2.sub

Some few other helpful things you can do with subs on Linux, are for example: splitting a file after a determined period of time, separating overlapped lines, and joining files into a single subtitle.

If you want to remove all the comments of gestures, facial expressions loud laughing etc. which displays usually the annoying (‘[Sneezing]’ or ‘[Music playing]) during the movie screen play, issue:

subs -e 's/[s-]*[.*]s*n*//gs' movie_subtitle_file.sub

Also other interesting Linux tool which is useful if you want to make conversions between subtitle in a (.sub) format to (.srt) format is called sub2srt perl script:

sub2srt’s home page is located on the URL address: http://www.robelix.com/sub2srt/, just to ensure it won’t just disappear with time I have created sub2srt mirror here

The most basic usage of sub2srt linux converting tool is by simply passing input sub and output srt file names like so:

linux:~# ./sub2srt 5rFF-pop.sub 5rFF-pop.srt

sub2srt supports changing of fps rate per second during conversion with the -f option as well as creationg of converted files in dos like end of file (CR+LF) with the –dos option.

Hope this article makes sense. If you find it useful, please drop me a thanks comment 😉