Showing posts with label multimedia. Show all posts
Showing posts with label multimedia. Show all posts

Thursday, 18 November 2010

Recording anything that gets played in your computer

I knew it was possible, but I had forgotten the details, so here they go...

Sometimes you might want to record audio played by an application in your computer (system sounds, music in a webpage, etc... basically anything that the computer can output to speakers/headphones). Recording that is actually very easy... In Ubuntu 10.04 I got the instructions from https://wiki.ubuntu.com/PulseAudio

I decided to try recording a song from Spotify (which is running inside Wine in my PC) using Audacity. The only extra software that I needed was PulseAudio Volume Control, and that was also the only one that I needed to configure.


When you start playing a song in Spotify and start recording in Audacity, it probably does not record anything, because Audacity will try to record from the "wrong" source. To route the sound properly, you just need to open the PulseAudio Volume Control and (while recording, otherwise this option is not available) change the option "ALSA Capture from" to "Monitor of Internal Audio Analog Stereo", as shown below, and Audacity will record them properly:


Thursday, 4 November 2010

The best video editor in Linux? OpenShot vs. Kdenlive? The jury is still out.

I'm starting to create videos more or less frequently, and the software that I tried so far, while good, was not working that well. My video editing needs are simple: put together a number of sequences, mix them with audio, apply some effects and transitions (fade in, fade out, etc.), and add some titles, credits, etc., and export it all to different formats: for Internet, DVD, etc.; and obviously, all within Linux.

When I start creating videos more regularly, perhaps I change my mind about the software I've used, but so far the fight is between OpenShot and Kdenlive. The video editing software that I have used:

Pitivi, was behaving properly, it looked stable and easy to use, but transition effects are not yet implemented, only fades.


Open Movie Editor, the interface does not look very polished, although it was quite OK for some of the videos I did, but the main problem for me was that I didn't find a way to zoom in or zoom out in the timeline. This was a problem when I had very short clips (perhaps just a few seconds), because it would be difficult to select them, in order to move them around or cut them, etc.

Kdenlive, this is probably the most complete editor of them all, and it has all those features that I want and many more, but in the past it crashed on me many times. Today I'm trying it again, with a new version (0.7.7.1), which apparently squashed many bugs, and it looks very promising. If I manage to run this version without crashes, this is probably the one that will win my heart. A screenshot of the video I'm editing right now:



OpenShot is the new kid in the block, and the interface is quite clean and it is feature rich. So far, my only gripe is that if I apply effects to consecutive video clips, sometimes artifacts are created in the audio, but I think this also happens with Kdenlive, so I need to investigate. The screenshot of the same project with Openshot:

 
There are a few more programs to try, (see http://en.wikipedia.org/wiki/Comparison_of_video_editing_software), but I think one of these two is going to be more than enough for my needs.

Friday, 29 October 2010

Youtube videos to MP3 (or mpeg)

Today I wanted to download the music of a YouTube video, in order to show it to some friends off-line. It turns out that this is quite easy (for reference, this is using Ubuntu 10.04 LTS). (Information consulted: http://hubpages.com/hub/Youtube-to-MP3-on-Ubuntu-Linux and http://lookherefirst.wordpress.com/2007/12/15/how-to-convert-flv-files-to-mpg-or-mp3/).

The first step is to get the aptly named script youtube-dl. The version available in Ubuntu 10.04 is 2010.04.04, but this does not work properly anymore, and it gives the following error when trying to download a video:

angelv~$ youtube-dl http://www.youtube.com/watch?v=BTwhEPiv0U8
[youtube] Setting language
[youtube] BTwhEPiv0U8: Downloading video info webpage
[youtube] BTwhEPiv0U8: Extracting video information
ERROR: format not available for video
angelv~$


If we download the latest version (2010.10.24) from http://bitbucket.org/rg3/youtube-dl/wiki/Home, and just copy the file to /usr/bin/youtube-dl, then we have no trouble and the video (in .flv format) is saved:

angelv~$ youtube-dl http://www.youtube.com/watch?v=BTwhEPiv0U8
[youtube] Setting language
[youtube] BTwhEPiv0U8: Downloading video webpage
[youtube] BTwhEPiv0U8: Downloading video info webpage
[youtube] BTwhEPiv0U8: Extracting video information
[download] Destination: BTwhEPiv0U8.flv
[download] 100.0% of 7.73M at   59.74k/s ETA 00:00

angelv~$ ls -lt *flv
-rw-r--r-- 1 angelv dialout 8100631 2010-10-29 10:01 BTwhEPiv0U8.flv
angelv~$


Then, in order to convert it to an MP3 you will need ffmpeg and the libmp3lame0 library (and in Ubuntu 10.04, perhaps also in others, the package libavcodec-unstripped-52, so that ffmpeg cand find libmp3lame). With this in place, a small script will take care of everything:

#!/bin/bash
x=$RANDOM.flv
youtube-dl --output=$x "$1"
ffmpeg -i $x -ar 44100 -ab 160k -ac 2 "$2"
rm $x


As an example:

angelv~/temp$ yt2mp3 http://www.youtube.com/watch?v=BTwhEPiv0U8 chiclana.mp3
[youtube] Setting language
[youtube] BTwhEPiv0U8: Downloading video webpage
[youtube] BTwhEPiv0U8: Downloading video info webpage
[youtube] BTwhEPiv0U8: Extracting video information
[download] Destination: 17660.flv
[download] 100.0% of 7.73M at   59.97k/s ETA 00:00
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --e\
nable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc \
--enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar  4 2010 12:41:55, gcc: 4.4.3

Seems stream 0 codec frame rate differs from container frame rate: 49.99 (4999/100) -> 25.00 (25/1)
Input #0, flv, from '17660.flv':
  Duration: 00:03:24.44, start: 0.000000, bitrate: 253 kb/s
    Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 253 kb/s, 25 tbr, 1k tbn, 49.99 tbc
    Stream #0.1: Audio: aac, 22050 Hz, stereo, s16
Output #0, mp3, to 'chiclana.mp3':
    Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 160 kb/s
Stream mapping:
  Stream #0.1 > #0.0
Press [q] to stop encoding
size=    4003kB time=204.93 bitrate= 160.0kbits/s
video:0kB audio:4003kB global headers:0kB muxing overhead 0.000781%
 

angelv~/temp$ ls -lt *mp3
-rw-r--r-- 1 angelv dialout 4098644 2010-10-29 10:34 chiclana.mp3
angelv~/temp$ 


Despite its name, we can also use the script as-is to convert Youtube videos for example to mpeg format:

angelv@vaso:~$ yt2mp3 http://www.youtube.com/watch?v=McdD9Ng4VnY funny.mpg


UPDATE (10-Apr-2013): With Ubuntu 12.10, youtube-dl works perfect right now to download YouTube videos, and it even has an option to extract automatically the audio, so what I was achieving with this post is now a no-brainer:


angelv@pilas:~$ youtube-dl --extract-audio --audio-format=mp3 http://www.youtube.com/watch?v=suTKOmmoBtw
[youtube] Setting language
[youtube] suTKOmmoBtw: Downloading video webpage
[youtube] suTKOmmoBtw: Downloading video info webpage
[youtube] suTKOmmoBtw: Extracting video information
[download] Destination: suTKOmmoBtw.flv
[download] 100.0% of 13.89M at   80.60k/s ETA 00:00
[avconv] Destination: suTKOmmoBtw.mp3
angelv@pilas:~$ 


Thursday, 4 February 2010

BBC iPlayer Overseas

I'm quite fond of the BBC, but I'm currently located outside the UK, which means that by default I cannot use their BBC iPlayer. The following steps solve this. I assume you have Unbuntu Karmic (64 bits), although for other distributions the steps should be similar.

* As a browser we will be using Firefox, since it has a very nice Proxy manager (FoxyProxy), which makes things easier.

* First, we follow the option two in http://www.torproject.org/docs/debian.html.en to add the Tor repositories. Tor is an anonymizer, which will help to pretend that we are located in the UK.

* Then, via the Synaptic Package Manager we should install FoxyProxy, vidalia and tor.

* We want to have control as to when Tor will be running, so we run the following to avoid it starting automatically after each reboot

sudo update-rc.d tor disable

* When we want to start Tor, we use Vidalia, which will give us an easy way to start/stop tor.

* Once Tor is started (Vidalia will tell you "Connected to the Tor network!"), it is time to try if it's working fine with Firefox/FoxyProxy

* In the FoxyProxy options (clicking in the status bar of Firefox), go to File->Tor Wizard, and configure a new Tor proxy (without Privoxy, default port). In the URL Patterns tab, you can write URL patterns that you need to anonymize, for the moment make sure it has *torcheck*

* Then, from the FoxyProxy options in the status bar (click with right button), select the one that says "Use proxies based on their pre-defined patterns...", and visit: http://torcheck.xenobite.eu/index.php (if all went well you should see the message: Your IP is identified to be a Tor-EXIT.)

* Now, we want a bit more control, and we want to make sure that the exit node in Tor is based in the UK. For this, we should edit the file .vidalia/torrc in your home directory and add:

StrictExitNodes 1
exitnodes {GB}


(you can get the country codes needed in the "View the Network" option with Vidalia).

* Stop/start Tor from within Vidalia. Recheck with http://torcheck.xenobite.eu/index.php and now you should get a UK IP address.

* So now for the BBC... Add as patterns for the Tor FoxyProxy (perhaps not all are necessary, should recheck):

http://www.bbc.co.uk/iplayer/episode/*
http://www.bbc.co.uk/mediaselector/4/js/download/*
http://www.bbc.co.uk/mediaselector/4/mtis/stream*


* Now go to http://www.bbc.co.uk/iplayer/, and select any of the TV programmes in there. If it tells you "Currently BBC iPlayer TV programmes are available to play in the UK only" you have done something wrong. If the message is not displayed, but you don't see anything, perhaps is a Flash Issue. With my versions of Ubuntu (9.10, 64bits), Firefox (3.5.7) and Flash (Shockwave Flash 10.1 d51) this was solved by selecting "None" (no visual effects) in System->Preferences->Appearance->Visual Effects.

* Now get a beer and enjoy the BBC programmes...

UPDATE (16/1/2013): With Ubuntu 12.10 now, I was having trouble to make this work as per the instructions above. In the end I got it working by getting rid of Vidalia, and letting Tor run as a daemon, which is run all the time in the background. Since my use of Tor is exclusively for this at the moment, I modified the global configuration file:


angelv@pilas:~$ tail -n 4 /etc/tor/torrc
#PublishServerDescriptor 0

StrictNodes 1
exitnodes {GB}
angelv@pilas:~$ 


With that, I use FoxyProxy in a similar manner as described above, but in Chromium (Version 23.0.1271.97 Ubuntu 12.10 (23.0.1271.97-0ubuntu0.12.10.1)). This time I didn't use the Tor wizard, but the details for the proxy are very simple, just use host: 127.0.0.1, port 9050, and check the SOCKS proxy? option.

When using the iPlayer, I find that the playback will not work for me at normal bandwith, so I switch to low bandwith, and all is OK.

Also, for convenience I install caffeine, which at first refuses to work, until I find the solution (to install gir1.2-appindicator3-0.1 and gir1.2-notify-0.7) at https://bugs.launchpad.net/caffeine/+bug/889705



Monday, 21 December 2009

3D animation creation service

Through something completely unrelated I found the xtranormal webpage, which lets you create simple 3D animations in a very easy way. In a minute you can create something really simple (for example: a greetings message). Creating a personalized cartoon for the kids goes now into the TO DO list...

Tuesday, 8 December 2009

Ripping a DVD with many tracks into a single AVI file

Since I'm likely to forget... Starting a few months ago, I now make a copy of every CD or DVD that I buy. This is normally a no-brainer, but today I had to copy a DVD that has many content tracks (usually the "interesting" content is in just one of the big tracks, while the "auxiliary" tracks can be discarded). I normally use dvd::rip, but for this I realized that AcidRip was a better option, since it lets me queue the ripping of all the tracks and then I can go away until they are finished (with dvd::rip I didn't find a way to do that). Once all the tracks are ripped into individual AVI files, I tried to put them all together with the aptly named avimerge, but I found (and apparently this happens to other people as well) that the audio gets broken, so I did it with menconder (got the thip from here):

mencoder -oac copy -ovc copy part1.avi part2.avi part3.avi -o WHOLE-THING.avi