My thoughts on Slackware, life and everything

Tag: youtube

A journey into recording sound & video in Slackware

ssr When it comes to audio and sounds in Slackware, we’re happy to have ALSA as the sound subsystem. It works reliably, and has done so ever since it replaced OSS in Slackware all those years ago. In due course ALSA got capable of dynamically mixing multiple sound sources – which is basically what a sound server does, too. We were never plagued with the issues of other distros when they abandoned ALSA for PulseAudio.
When the Arts sound daemon of KDE was deprecated and finally removed with the release of KDE4, Slackware was left without a sound “server” that ran out of the box. We still have ESD, the Enlightened Sound Daemon but that one has limited use because of the wrapper programs it needs.
There are however scenarios where you wish Slackware had some sort of audio server. Until now, the only times when that thought crossed my mind it was related to streaming audio over a network – think of remote desktop sessions and virtual machines. I may write some more about that topic in a future post because I think I have the solution now – read on.

A more immediate need arose when I went looking for software that can record videos of my Slackware desktop – individual program windows and gameplay footage. My son is a huge Minecraft fan and wants to be able to do in Slackware what he already does with Fraps in Windows. My intention is to task him with creating some Slackware “end-user” videos to attract newcomers to the distro 🙂

It turns out that there really is not all that many good desktop video recording software in Linux land. I have tried recordmydesktop and like it well enough (that is how it ended up in Slackware’s “/extra” section) but it does not deliver stellar videos, in particular I don’t think it is suited for recording gameplay. It also produces OGG video only, which is OK since that gives you the only free and open video format and codecs… but I believe this design decision limits my options too much.

I read up on ArsTechnica’s attempts to record gameplay footage on SteamOS. To this day, the ArsTechnica folk have not found a way to record the audio of a game… apparently it is not as easy as you might think, to record OpenGL games. Programs like FFMPEG and VLC are able to record (parts of) your desktop but it is cumbersome and also does not deliver high-quality video with properly synced audio. These programs are not capable of intercepting OpenGL renders either, which limits their use.
So I went looking… and came across GLC, an ALSA & OpenGL recording software for Linux which was inspired by Fraps and Yukon, but it seems mostly abandoned by its author. Then there also is SimpleScreenRecorder, a relatively new piece of work by Maarten Baert. The program uses FFMPEG’s codecs to allow you to record audio and video into any format supported by the locally installed version of ffmpeg. It supports the recording of ALSA sound sources (think of a microphone). The word “simple” in its name only characterizes the ease-of-use, not the featureset! And it has a Qt-based GUI which nicely blends into my KDE desktop. By means of an OpenGL injection library it also supports direct recording of OpenGL renders (read: games). That should produce superior videos compared to merely recording the desktop window (because that produces lower frame rate videos or lower quality).

Unfortunately it turned out that SimpleScreenRecorder was not capable of recording my Slackware desktop’s sound, and therefore game videos are silent.
That is a show stopper… apparently you need a sound server like PulseAudio in order to record the audio as well. I am not prepared to install PulseAudio on Slackware – as you are well aware, this is a personal issue I have with the PA author and the way he writes code. So I investigated further, and found out that the unreleased GIT sources of SimpleScreenRecorder support JACK as a new sound source next to ALSA (and PulseAudio). I built the program from its GIT sources and then went on to learn about JACK Audio Connection Kit. I knew that JACK is primarily used by audio professionals and musicians because of its low-latency core design. But as it goes with versatile programs, it is inherently difficult to grasp its concepts and complex to configure. But I persevered and ultimately found a way to configure JACK on my desktop, and reconfigure my ALSA setup so that all the programs that I use can still emit sound, and SimpleScreenRecorder is now capable of recording video and audio! I put a demo video online which I recorded for the intro sequence from the Metro: Last Light game.

As you can see, the game stutters a bit, but that is not caused by the recording software – it’s my desktop PC which is just not fast enough for the game.

ssr_qtui

My next post will be about how I built and configured JACK, and what I had to change in my ALSA configuration so that for instance Steam games (using SDL for audio) and MineCraft (using OpenAL for audio) would still make sounds.

In the meantime, if you want to try SimpleScreenRecorder, there’s a couple of dependencies you need to install as well. SimpleScreenRecorder was built against ffmpeg (version 2.1 to be precise – please note that upgrades of ffmpeg will usually break a lot of applications that depend on it due to a change in library versions). Also, the package which I released has been built against jack – even if you do not plan on using it, you’ll have to install it… or you can rebuild SimpleScreenRecorder yourself.
If you want to use SimpleScreenRecorder to record 32-bit OpenGL programs (Steam games, WINE based games) and are running a 64-bit Slackware, it will have to be a multilib system and you will have to use the “convertpkg-compat32″ script (part of my compat32-tools package) to convert and install the 32-bits “compat32” versions of the simplescreenrecorder, ffmpeg and jack packages as well as the 64-bit versions.
If you want to try and record a Steam game without the Steam windows being visible (those are also rendered in OpenGL), you’ll definitely have to read these instructions: http://www.maartenbaert.be/simplescreenrecorder/recording-steam-games/#native-steam-for-linux because currently it involves some manual tweaking to get this working (I expect that this will get easier in time). Judging by his Wiki, Maarten is responsive to the users of his program and is able to write meaningful documentation.

Get packages (and sources) here:

Have fun! Eric

Youtube HD mp4 download

*** This post was updated with new JavaScript code on 27-oct-2009 ***

Sure, you can install Video Downloadhelper for Firefox if you want an easy way to download your favourite YouTube videos.

However, these will be downloaded in “FLV” format (Flash video). Nowadays, many videos on YouTube are available in High-Definition (HD) format and you may want to retrieve the higher quality (MP4) movies instead.

Here is a bit of JavaScript which checks if the movie you selected is available as HD 720p. If a HD format is available it will be the preferred download type (fmt24) instead of the usual “high” (fmt18) or
“regular”quality.

I got the javascript code from this page, which I found after my original javascript code stopped working (I guess Google removed the javascript functions to block folks like us):  http://googlesystem.blogspot.com/2008/04/download-youtube-videos-as-mp4-files.html . The new code is a lot uglier than the initial javascript, but it works. That page also has the same code available, nicely reformatted, as a GreaseMonkey script if you have that firefox extension already installed.

Define the following text as a bookmark and you are only a click away from downloading HD YouTube videos (in Firefox, right-click the link below and select “bookmark this link“):

javascript:var%20video_id=null;var%20video_hash=null;var%20video_player=document.getElementById(‘movie_player’);if(video_player){var%20flash_variables=video_player.attributes.getNamedItem(‘flashvars’);if(flash_variables){var%20flash_values=flash_variables.value;if(flash_values){var%20video_id_match=flash_values.match(/[^a-z]video_id=([^(\&|$)]*)/);if(video_id_match!=null)video_id=video_id_match[1];var%20video_hash_match=flash_values.match(/[^a-z]t=([^(\&|$)]*)/);if(video_hash_match!=null)video_hash=video_hash_match[1]}}}if(video_id==null||video_hash==null){var%20args=null;try{args=yt.getConfig(‘SWF_ARGS’)}catch(e){}if(args){video_id=args[‘video_id’];video_hash=args[‘t’]}}if(video_id!=null&&video_hash!=null){var%20fmt=’18’;try{if(yt.getConfig(‘IS_HD_AVAILABLE’))fmt=’22’}catch(e){}if(!document.getElementById(‘download-youtube-video’)){var%20yt_mp4_path=’http://www.youtube.com/get_video?fmt=’+fmt+’&video_id=’+video_id+’&t=’+video_hash;var%20div_embed=document.getElementById(‘watch-embed-div’);if(div_embed){var%20div_download=document.createElement(‘div’);div_download.innerHTML=’%3Cbr%20/%3E%20%3Cspan%20id=\’download-youtube-video\’%3E%20%3Ca%20href=\”+yt_mp4_path+’\’%20onclick=\’blur(this);\’%3EDownload%20as%20MP4%3C/a%3E%3C/span%3E’;div_embed.appendChild(div_download);}if(navigator.appName!=’Microsoft%20Internet%20Explorer’){document.location.href=’http://www.youtube.com/get_video?fmt=’+fmt+’&video_id=’+video_id+’&t=’+video_hash}}}void(0);

Note: this was the old code which now will no longer work:

javascript:if(document.location.href.match(/http:\/\/[a-zA-Z\.]*youtube\.com\/watch/)){document.location.href=’http://www.youtube.com/get_video?fmt=’+(isHDAvailable?’22’:’18’)+’&video_id=’+swfArgs[‘video_id’]+’&t=’+swfArgs[‘t’]}

The proof of the pudding is in the eating. Select a YouTube video, click on “pause” if you do not want to play it in the embedded video frame. Then, click on the bookmark you created and the video will start downloading. It will (always) be saved with the name “video.mp4” so you will have to rename it after the download finishes.

Have fun! Eric

© 2024 Alien Pastures

Theme by Anders NorenUp ↑