Archive
Capture screen and mic input using FFmpeg and ALSA
Hi there,
Recently, interesting commands appeared in commandlinefu about x11grab using ffmpeg. All are very interesting commands and they did what I expected in my Debian. But only one thing is missing. While creating a screencast, If I want to speak, that should appear in the capturing stream.
Thanks to alsa and ffmpeg, they have a way to capture my laptop’s in-built mic input. So I customized the existing commands which appeared in commandlinefu and created a small script.
#!/bin/sh
# simple command to capture your screen
OUTPUT="${1:?[usage] screencast.sh OUTPUTFILE}"
getgeometry()
{
xwininfo -root |
grep 'geometry' |
awk '{print $2;}'
}
captureX11()
{
ffmpeg -f alsa -itsoffset 00:00:02.000 -ac 2 -i hw:0,0 \
-f x11grab -s $(getgeometry) -r 10 -i :0.0 \
-sameq -f mp4 \
-s wvga \
-y "${OUTPUT}"
}
captureX11
Finally I created my first screencast using ‘screencast.sh’ script. Here is the video
Atlast, I don’t want to install one more app to create screencast. FFmpeg is with me !!!
Kadhalan BGM
Hello my friends,
Yesterday I asked Srinath, Naraen and Suganthi about what is their favourite background music? Srinath told lot of movies and he is really loving BGM, espcially from AR Rahman. Naraen also told lot of movies and suganthi already collected a bunch. After comming to room, I thought I can create BGM from my favourite movie ‘kadhalan’.
Kadhalan is a fentastic movie directed by shankar casting prabhudava, nagma, raguvaran, spb and a lot. During this time, shankar as well as rahman are new to this industry, this film made them from new to star. Rahman songs and its extrodinary BGM score will never go away from our mind.
Here I created a dozen BGM scores from this movie. All I did is,
1. Download the movie from desiterminal.org.
2. Watch it in mplayer with OSD enabled. So that I can see the exact seconds to cut the clips.
3. Use ffmpeg to cut the clips as well as convert them to whatever format you want.
I downloaded the movie from desiterminal(Kudos to you guys, thanks for the movie). Then I converted them using the below generic commandline.
$ ffmpeg -i moviepart.flv -ss starttime_hh_mm_ss -t cliplength_in_seconds \ -acodec libmp3lame -vcodec mpeg2video \ -ar 44100 -ab 128k clipfilename.mpg
Once I create the cllips, I moved them to a seperate directory. I used this below single command to dump the audio streams from the clips in mp3 format.
$ (for FILE in `ls`; do mplayer -dumpaudio \
-dumpfile "${FILE%.mpg}.mp3" "${FILE}"; done)
Thats all, I created all the interesting clips and also got them as mp3. Here is the BGMs.
Kadhalan_Indriyo_eval_sundriyo.mp3
Kadhalan_Kaatru_kudriyelae_en_karkuzhal.mp3
Kadhalan_Kollayela_thennai_vaithu.mp3
Kadhalan_Naatiyaliya_intro.mp3
Kadhalan_Nagma_challenge_to_prabhudava.mp3
Kadhalan_Nagma_Intro.mp3
Kadhalan_Nagma_takeoff_from_chidambaram.mp3
Kadhalan_Prabhudava_extrodinary_reply_to_nagma.mp3
Kadhalan_Prabhudava_practicing_for_the_reply.mp3
Kadhalan_Raguvaran_intro.mp3
Kadhalan_Title_Music.mp3
Kadhalan_Vadivalu_Intro.mp3
I also included my favourite sceen here. After tremendous practice, prabhudeva will showcase his talent which was questioned previously by nagma. Prabhudeva learnt a critical art in bharadhanatiyam within short time where nagma learnt for a period of 6 year. She challenged prabhudeva previously and in this sceen prabhudeva takeoff his Ultra revenge. Hope all of you will enjoy!!!
Kesavan’s Birthday with ffmpeg and mencoder
Hi there,
Today is kesavan’s birthday, shankar reminded us about this day before yesterday by telling that kesavan’s birthday is on Feb 19. So I bags a cake and went to room. I also called stalin to come to room.
I reached home at 11pm, within few minutes, stalin also came. But kesavan and santhosh didn’t come as per the timing. But we waited.
At 2am, santhosh and kesavan reached the room, and we wished kesavan with full of bumps, and beat him everywhere. He became frustrated and asked us to stop. We finally stopped and he asked “why you are beating me?”. We said today is your birthday, and he said, “Ada nadhari payabulligala, Innaiku illada nalaiku thaanda nan porandha naal”.
What a mess, But we said, “Parava illada oru naal munnadi adikarathula onnum thappu illa”. Then we started to prepare for the celebration. Santhosh started to capture that moments in stalin’s mobile(Its a Nokia 3500 classic).
Everybody enjoyed those moments and we captured that moment in mobile. Then kesavan, santhosh started to sleep, But something telling to me to do something with the video.
I transfered that video to my system and started to convert it to mpeg using ffmpeg, but it didn’t work, because ffmpeg don’t know howto decode smr audio stream. Thankfully mencoder knows howto decode smr audio. I used mencoder to convert that 3gp to mpeg4.
$ mencoder -oac lavc -ovc lavc -lavcopts acodec=libmp3lame:vcodec=mpeg4 -af scale=::::::qpal -o Video000.mp4 Video000.3gp
Converted that video to mp4 format. Now its time for ffmpeg to convert it into normal mpeg, because In my office, that windows media player don’t know how to play mp4. So I decided to convert it to mpeg then to avi. Here is the commands,
$ ffmpeg -i Video000.mp4 -ar 44100 -ab 128k -acodec libmp3lame -vcidec mpeg2video -s qcif Video000.mpg
$ ffmpeg -i Video000.mpg -ar 44100 -ab 128k -acodec wmav2 -vcodec msmpeg4 -s qcif Kesavan_Birthday.avi
everything went fine and we uploaded mpeg video to orkut through youtube and we mail .avi video to all our ignite friends.
That night is one dam good night for me. Here is the video,
Mounam Pesiyadhe BGM
Ooh I love this music, Yuvan you are marvalous!! This is one of the best (I can say it is the best) from you!! keep rocking!!
Today suddenly I heared this BGM music one more time from Mounam Pasiyadhae, an unforgettable film I ever watched, the background music will take anyone to heaven. I have all the songs of Mounam Pasiyadhae, but don’t able to get this BGM music.
sometimes back, I learnt howto use ffmpeg, ffmpeg2theora, mplayer and mencoder, so I decided to download entire movie and do some stuff to convert that music into mp3.
While downloading the first part, my temper is out, I desperately want to convert that amazing background music immediately, first I played the downloading movie part with mplayer, enabling(press key o) OSD output. mplayer started to play the movie, man!!! what a music!! I will hear this 2min music for my lifetime :), OSD showed 00:02:12 as its passed time, I decided to use mplayer with -dumpaudio -dumpfile and -endpos 00:02:12 to dump audio only for that duration, but mplayer did differently. It dumped the whole audio upto the downloaded part of the movie. Damn!!
So its fallback time, I decided to go to friendly beast ffmpeg, here is the command I did,
$ ffmpeg -i TamilBlast.Com_Mounam_Part\ I.avi -t 00:02:12 -f mp3 -ab 128k Mounam_Pasiyadhae_BGM.mp3
Thats all, I got the perfect duration of that music. All ends well and I’m writting this post while hearing this BGM music, thana.. naa.. naa.. naananaa.. naaa.. na!!!
