Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, 6 February 2015

Making custom versions of packages in Ubuntu/Debian

Had to make some changes in the source code of a couple of packages on my system and decided to document the process for future reference. Surprisingly, it's way easier than I thought it would be.

As an example, suppose we want to make the default graphical viewer Eye of Gnome not jump back to the first picture after the last one in a directory (and, similarly, not jump in the opposite direction, either).

First, we need to get the source code for the program
$ mkdir eog; cd eog; apt-get source eog

Then let's install all the needed dependencies to compile the package:
$ sudo apt-get install build-dep eog

All right, time to make the changes we need. In this case, we need to slightly modify the corresponding part in eog_thumb_view_select_single() in src/eog-thumb-view.c to look like this:

        case EOG_THUMB_VIEW_SELECT_LEFT:
            gtk_tree_path_prev (path);
            break;
        case EOG_THUMB_VIEW_SELECT_RIGHT:
            if (gtk_tree_path_get_indices (path) [0] != n_items - 1)
                gtk_tree_path_next (path);
            break;

Now that we've made the changes, let's make our custom package:
$ dpkg-buildpackage -b

The program has been compiled and assembled in one neat package. All that is left is to install it, replacing the standard version:
$ sudo debi

Hooray, we have our custom version of Eye of Gnome installed and operational!

Now if I only knew a way to apply patches and rebuild the packages automatically every time they get an update..

Tuesday, 6 May 2014

Baloo a shit

A truly deserving successor of nedopuk that reeks of shit just as much.
Gee, let's force a mostly meaningless and redundant feature on the users' head. And let's fucking lie that they won't even notice the performance impact as the reason for enabling it. Surely they won't! Because really, who would notice something that hogs 100% of I/O and quadruples loading times! I didn't mean to sign for an alpha when I decided to use a mainstream Linux distro or KDE!
Oh, and there is no official way to disable it.

Saturday, 3 May 2014

Capturing video in Ubuntu 14.04

(Disclamer: never captured video before, must be missing a whole lot of things and optimizations).

The following line will capture 1920x1080 screen at 30 frames per second and is suitable for taking video game footage.

avconv -f x11grab -r 30 -s hd1080 -i :0.0 -f pulse -name 'screencap -> system audio' -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -map 0 -map 1  -codec:v libx264 -pre:v lossless_ultrafast -codec:a libmp3lame -threads auto -y captured.avi

If audio & video are out of sync, chances are you have run into yet another bug in Ubuntu.

http://askubuntu.com/questions/336747/audio-and-video-auto-of-sync-when-streaming
https://github.com/MaartenBaert/ssr/issues/16

To fix that, set the 2 following values in  /etc/pulse/daemon.conf:
does storing
default-sample-rate = 44100
alternate-sample-rate = 44100
To get window geometry if you're capturing a window, you can use xwininfo and then change the resolution (-s WxH) and offset (-i :0.0+x_off,y_off) accordingly.

Expect that 1 minute of stream will hog roughly 1GB with these settings for 1080p.

When the capture is done, compress & (optionally)cut:
avconv -i captured.avi -ss FROM_TIME -t LENGTH -vcodec libx264 -pre:v veryslow -acodec libmp3lame result.avi

So why is GNU/Linux not a popular platform for gaming and streaming? Anyone?

Update as of August 22, 2014 (still needs some polish):

The following line allows for real-time capture AND encoding. The line gives a 50 MB/min output and looks like a full replacement to the old one.
avconv -f x11grab -s hd1080 -i :0.0 -f pulse -name 'screencap -> system audio' -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -map 0 -map 1  -codec:v libx264 -pre:v ultrafast -codec:a libmp3lame -af asyncts -threads auto -y captured.mkv

add -filter:v scale=960:-1 (or whatever size you prefer) to record downscaled video. Reduces video size and some CPU power (obviously) at the cost of lower resolution.

Seems like the -r parameter specified earlier may actually cause audio/video desync when the encoder cannot keep up with the input. If there is still desync, try loading the game and THEN starting the capture (still don't know what's causing this).

Update as of May 05, 2015:

OBS now natively supports Linux. The up-to-date version that I tried was a bit buggy, but it was still a great improvement over what I had been dealing with before. One small caveat is that it needs ffmpeg instead of avconv, and those two hate each other with passion. It IS possible to install ffmpeg locally in your home directory (without removing avconv) and make OBS use it from there, though you'll probably need to compile ffmpeg and OBS manually to do that (which is fairly straightforward regardless, I must add).

Monday, 11 October 2010

Running Tsukihime on Ubuntu Linux.

Late yesterday evening, when I was heading home, pondering whatever people usually ponder in cold dark evenings, I saw the moon. It is quite rare to see it so clear in the town where I live, but there it was, big, incredibly beautiful, with a tinge of blue. Long story short, that hit the trigger in my head and I got a strong urge to play the Moon Princess again.

There is one problem, though: my desktop PC is running Linux. Actually, the problem is not that big, because the English translation of Tsukihime uses the ONScripter engine, which is open source and multi-platform. And although Mirror Moon, the folks who translated Tsukihime, did not release a separate set of binaries for Linux, they were very kind to provide their patch for Onscripter-en to make things work.
http://mirrormoon.org/news/2007-01-15-tsukihime_english_for_linux_and_osx

Just as it is always happening, the actual process is harder than it is supposed to be and has a couple of unexpected caveats. To begin with, you may have discovered that the Ubuntu repo actually has the Onscripter package. Well, surprise! It won't work with the game, because it does not have the patch! So let's compile the game from the source instead.

Let's get these two files:
$ ls
onscripter-20060724-insani.src.zip  onscripter-20060724-insani-zalas.patch2

Then unzip onscripter:
$ unzip onscripter-20060724-insani.src.zip ; cd onscripter-20060724-insani

Now let's apply the patch:
$ patch -p1 < ../onscripter-20060724-insani-zalas.patch2

After that, install all the dependences mentioned in the README file. You will know you're missing something if the compilation fails saying there is no header file.

Now, after these steps we WERE supposed to get a working binary by just running:
$ make -f Makefile.Linux.insani


However, there is a problem:


...
ONScripterLabel_command.cpp: In member function ‘int ONScripterLabel::savescreenshotCommand()’:
ONScripterLabel_command.cpp:861: error: invalid conversion from ‘const char*’ to ‘char*’
ONScripterLabel_command.cpp: In member function ‘int ONScripterLabel::exbtnCommand()’:
ONScripterLabel_command.cpp:2225: warning: suggest parentheses around ‘&&’ within ‘||’
make: *** [ONScripterLabel_command.o] Error 1



This is simple. GCC has become more strict since the time this code was written, so we need to re-declare *ext on line 861 from char * to const char *. Now, can we have the working program?

$ make -f Makefile.Linux.insani
...
/usr/bin/ld: cannot find -lartsc
collect2: ld returned 1 exit status
make: *** [onscripter] Error 1



Not yet! The Arts sound library which we are missing here is outdated, and it's not available in the modern Ubuntu distros. Instead, a compatible sound interface is provided through PulseAudio, which is default nowadays. After a lot of googling, I finally figured out the solution: you should substitute -lartsc with -lpulse inside Makefile.Linux.insani in the uncommented "LIBS = ..." string. In addition, you must get rid of "-static", because there is no static version of libpulse-simple which you will need. (Actually, I have no idea why static linking was enabled in the first place). After these changes, LIBS should look like this:

LIBS = -z muldefs -Wl,--start-group `sdl-config --static-libs` `smpeg-config --libs` -lSDL_ttf -lfreetype -lSDL_image -ltiff -lpng -lSDL_mixer -lbz2 -lz -ljpeg -lm -lvorbis -lvorbisenc -lvorbisfile -logg -lgpm -lncurses -lslang -ldirectfb -lfusion -ldirect -lvga -ldl -lesd -lpulse -lasound -lX11 -laa -Wl,--end-group

$ make -f Makefile.Linux.insani

Finally, the binary is ready! After copying it to the game dir (or vice versa), all the preparations have been made, and we can enjoy the game:

$ ./onscripter
ONScripter version 20060724-insani(2.55)
Autodetect: insanity spirit detected!
Display: 640 x 480 (32 bpp)
Audio: 44100 Hz 16 bit stereo


P.S. The steps above were valid for Ubuntu 9.10 Karmic Koala. Chances are very high that the steps for 10.04 and 10.10 will be exactly the same.