Sunday, 17 February 2013

Muxing Audio stream of different play length onto a Video Stream

 I have been creating a some screencasts and posting the same on my blog recently. The list of videos have been linked in a separate videos tab. But whenever I uploaded the video onto youtube, it would complain that it is not able to detect any audio stream on my videos. That triggered an interest in experimenting with adding a sound track to one of my videos. I started searching on the net and tried to get some audio clips filed under "Creative commons" license. I found a webpage (Legal Music For Videos) which lists many sites which showcase good audio content. I narrowed down the choice of tracks to two of them and finally choose the first one.
 Now comes the hard part of muxing / mixing of the audio track onto videos. Two potential candidate emerged that can easily mix audio streams onto video files. Both are command line tools (mencoder , ffmpeg). I saw sample code for both of them here. I also found that in order to use mencoder(based on mplayer), i had to un-install mplayer2-as-mplayer as it conflicts with mplayer backend :-(. I did not want to do this and opted for ffmpeg instead.
The command to mix the audio into video is pretty basic
ffmpeg -i <inputVideo> -i <inputAudio> -c copy <outputvideo>
 I choose one of my recent videos and tried to add the sound track. I substituted the file names as appropriate and got the below command and it did produce a output file. But when i played the output video i found that audio kept playing even after the video had ended. I realised that this was due to the audio track length being greater than that of video.
ffmpeg -i YaSTAddCustomRepo.webm -i Dwaram_Venkataswami_Naidu.mp3 -c copy output.avi
 After making a few more search I found this page which talked about using the "shorten" option. I opened "man" for ffmpeg in GNOME "help browser" using command launcher (Alt+F2) and command "xdg-open man:ffmpeg".Demystifying Man explains various ways of using man command. I found that "shortest" option should be used in a manner as shown below and came up with revised code to convert the video.
-shortest (output) - Finish encoding when the shortest input stream ends.
$ffmpeg -i YaSTAddCustomRepo.webm -i Dwaram_Venkataswami_Naidu.mp3 -shortest -c copy output.avi
Demo video where i have mixed audio stream and video Stream of different playlengths. Since the audio is lifted from a Gramophone record it is course at some places.

Video demo on Addition Of custom repo to YaST installer

 This video demonstrates as to how one can add a custom repository to YaST Installer on GNOME 3.4.2, openSUSE 12.2.
Notes:-
  • Always use appropriate repo version in YaST ( i.e. if you are using openSUSE 12.2, always use repos which have "12.2" string in their url)
  • It is always a good idea to Turn off "Allow Vendor Change" in YaST when custom repos are used.
  • Your system may get horribly broken if you perform "zypper dup" with custom repos on your openSUSE.
  • Repository used in the video demonstration is :- http://download.opensuse.org/repositories/network:/utilities/openSUSE_12.2/

Friday, 15 February 2013

How to add custom menus or application shortcuts to GNOME 3.X panel ?

 Yesterday I saw a comment in one of my articles about "Adding a new application to Universal Access Settings". Brief transcript of the conversation is as below :-
@Yogesh-I want to add my own new customize setting in this menu? is it possible ,if yes then how?
@vazhavandan- what kind of customised setting do you want ? Please be more specific
@super hero -i want to add new feature in universal access setting panel that will open particular application for eg.Eekboard
 I admit that i am not geeky enough to hack "Universal Access menu". Here is my workaround.
  • I first install Eekboard(eekboard is a virtual keyboard) using the one click from this page.
  • Then i set about installing a extension known as QuickLaunch. For more details about some cool extensions one can take a look at this article.
  • Then i restart GNOME Shell using command launcher (Alt+F2) and then typing in r followed by return or enter key. Now the extension will appear in top panel / taskbar.
  • I click on "Create new launcher..' menu in the extension and it opens up"gnome-desktop-item-edit" application where i can create shortcut for any application.
Notes
By default all new shortcuts or launchers are placed in below folder:-
/home/<profileName>/.local/share/gnome-shell/quicklaunch
(OR)
~/.local/share/gnome-shell/quicklaunch
All the GNOME Shell Extensions are installed into below folder:-
/home/<profileName>/.local/share/gnome-shell/extensions
(OR)
~/.local/share/gnome-shell/extensions
Creating new menu item for Eekboard
Creating new menu item for Eekboard Quicklaunch Extension
Now i can launch the application using the new menu
Launching Eekboard using Quicklaunch Extension from GNOME Shell Panel
Update to Article:- 
 The user pointed out that he / she did not want to use quicklaunch and pointed out to files under frolder /usr/share/gnome-shell/js/ui/status/
@super hero -
Thank You for your reply.
i don't want to use Quick Launch.
I want to add new option on Universal Access setting Panel ,which will open installed application.
i came to know about accessibility.js file (/usr/share/gnome-shell/js/ui/
status/),which has all UI details, but i am not getting how it launches that particular application.
 I found the file in question accessibility.js and I opened that file and added the below lines and it worked. I never dreamt GNOME would be some simple to change :-)
this.menu.addSettingsAction(_("Universal Access Settings"), 'gnome-universal-access-panel.desktop');
//Add the damn new virtual keyboard
this.menu.addSettingsAction(_("Eekboard"), 'eekboard.desktop');
 
Screenshot of line addition
Adding Eekboard launcher To Accessibility.js using Geany
The menu appears under "Universal..."
Launching Eekboard from Universal Access Settings GNOME Shell Panel