Madsdyd’s Weblog

June 18, 2009

Encoding for a no-name mp4 player

Filed under: Uncategorized — madsdyd @ 7:51 pm

My kid just got a used AtiPix mp4 player 1GB. It only supports playback of “avi” videos in 320×240. Took a lot of fiddling around, running the windows program in wine, and help from Dark_Shikari in #ffmpeg on irc.freenode.org to figure this ffmpeg command line out:

ffmpeg -i input.mpeg -vcodec libxvid -s 320x240 -b 528000 -aspect 4:3 -r 20 -vtag XVID -acodec mp2 -ab 128000 output.avi

The key would seem to be -vcodec libxvid AND -vtag XVID.

Its a sucky player, but whatever it takes to make the kid happy…

May 26, 2009

KDE 4.2: love/hate & konqueror bugs

Filed under: Uncategorized — Tags: — madsdyd @ 6:03 am

There are tons of great things about kde 4.2 especially for the developers. But there are still lots of features missing, and bugs, some of them glaring. I was hit by one of the more subtle bugs today; konqueror would start with two windows, and then crash. There was no way I could get it running, which was a pain.

Turns out that the file $HOME/.kde/share/apps/konqueror/closeditems_saved was corrupted. Deleting this file fixed everything up.

Now, I really look forward to a new release that fixes the krunner problems and adds dbus functionality to konsole. Then perhaps at some point, an inclusion in ubuntu of the kpilot and a finished akonadi. Then we are about where kde 3.5.9 was when I left it. Especially if I get the apt: io slave back. Sorely missing that one, I am.

March 9, 2009

The magic of C++ templates

Filed under: Uncategorized — Tags: — madsdyd @ 8:57 am

Yesterday I went and wanted to convert a function into a templated function in C++. No big deal, but one of my constructs gave me some problems. I’ll illustrate with an example function, that contains the problem I had

void myfunc( int a ) {
some_class::some_method<some_class>( a );
}

There are good reasons for some_method to be templated with some_class, which has to do with the fact that some_method is static and needs to interface to some C code, that expects static callbacks, and what not.
I wanted to make this work for both some_class, and some_other_class. Here is my first try:

template <class T>
void myfunc( int a ) {
T::some_method<T>( a );
}

This declaration/definition does not work. The compiler wants a primary expression before the first >,and complains about the “,” operator ignoring its first argument.
I was a bit stumped by this, but got some help from ##c++ on irc.freenode.net.
Here is the right way to write it:

template <class T>
void myfunc( int a ) {
T::template some_method<T>( a );
}

Turns out, that when the compiler needs to figure out what some_method is, it can not look in T for help. So, it assumes that some_method is not a templated function, and the first ‘<’ is interprented as operator<. This also explains why it want a primary expression, and why it complains about operator,.

The solution: Let the compiler know that some_method is templated, by inserting “template ” before the method call.

March 7, 2009

Kontact can post to wordpress

Filed under: Uncategorized — madsdyd @ 9:00 pm

Read on userbase.kde.org that kontact can be used to post blog entries, and behold! It works.

March 3, 2009

Exim4 and max size of received messages in kubuntu/debian

Filed under: Uncategorized — Tags: — madsdyd @ 8:24 am

Turns out exim3/4 at some point introduced a max size for messages it wants to receive.

If you have not changed anything, exim will refuse to accept messages larger than 50MB. I need to be able to receive mails larger than this.

Figuring out how to change it under Kubuntu/debian was a bit harder than I thought, but I got some help on irc. First of all, debian allows to configure in two “modes”: split and non-split. This assumes split, which I believe is the default:


sudo echo MESSAGE_SIZE_LIMIT=2000M >> /etc//exim4/conf.d/main/00_exim4-config_localmacrodefs
sudo update-exim4.conf
sudo /etc/init.d/exim4 restart

You can then check that the new size is set with


sudo exim4 -bP message_size_limit

Thanks to valdyn and petemc on irc.freenode.net for helping me out.

October 5, 2008

Boost unit testing strings

Filed under: Uncategorized — Tags: — madsdyd @ 4:28 pm

If you use the boost unit test framework, you probably have a need to test the string output of a function once in a while. If you use BOOST_CHECK_EQUAL Boost kindly reports string differences, by listing the input and output. Then you can start comparing. Not very usefull.

Instead you can use something like this:

boost::test_tools::predicate_result
compare_qstrings( QString const & actual, QString const & expected )
{
// Lets get the trivial case out of the way.
if ( actual == expected ) {
return true;
}
// We want output like this:
// boost_extract_xml_from_es_task_package.cc(106): error in "itemorder":
// check "todo" ==
// output_24575997 failed
// output differs at position 42
// expected ...ISO-8859-1"?>todo
// ^

boost::test_tools::predicate_result res( false );
int i = 0;
int actual_l = actual.size();
int expected_l = expected.size();
int max_l = actual_l < expected_l ? actual_l : expected_l;
if ( actual_l < expected_l ) {
max_l = actual_l;
res.message() << "actual is shorter than expected\n"; // < expected_l ) {
max_l = expected_l;
res.message() << "actual is longer than expected\n"; // << std::endl;
}
while( i < max_l && actual.at( i ) == expected.at( i ) ) {
++i;
}
res.message() << "actual and expected differs at position " << i < 20) ? (i - 20) : 0;
const char * prefix = begin > 0 ? "..." : "";
res.message() << "expected: " << prefix << expected.mid( begin, 70 )
<< ( begin + 70 < expected_l ? "..." : "" ) << "\n"; // std::endl;
res.message() << "actual: " << prefix << actual.mid( begin, 70 )
<< ( begin + 70 < actual_l ? "..." : "" ) << "\n"; // std::endl;
res.message() << " " << QString( ( i - begin ) + QString( prefix ).size(), ' ' ).toStdString()
<< "^"; // << std::endl;
return res;
}

And, call it like this:

BOOST_CHECK( compare_qstrings( "string a", "string b" ) )

and then you will get output like this:


boost_extract_xml_from_es_task_package.cc(470): error in "itemorder": check compare_qstrings( extract.extractXml( input_24229551 ), output_24229551 ) failed. actual is shorter than expected
actual and expected differs at position 23
expected: <ill5:ILL-APDU xmlns:ill5="...
actual: <ill5:ILL-APDU xmlns:ill5="...
^

which is way more useful in my opinion.

Of course, wordpress formats it so it is totally unreadable – so you just have to take my word for it :-)

The above uses QString, but it is of course trivial to change it to use std::string.

August 15, 2008

How to build kdenlive for KDE4 yourself

Filed under: Uncategorized — Tags: , , , — madsdyd @ 7:06 pm

I just updated my wizard that builds Kdenlive for KDE4 on Linux.

It should now be easier than ever (perhaps unless your hobby is tweaking linux video libraries) to get the development version of kdenlive to run on your system.

Get it here – and remember to vote “good” for it :-) .

August 14, 2008

Kinetic Typography

Filed under: Uncategorized — Tags: , — madsdyd @ 4:31 pm

Yesterday, while looking for an answer to a problem with synfig on irv, pixelgeek pointed out Kinetic Typography to me. That is some really cool stuff they do. Be sure to follow the links and watch the videos with sound.

How to use synfig for titles in kdenlive

Filed under: Uncategorized — Tags: , , , , , , , , , — madsdyd @ 4:16 pm

I finally figured out how to use synfig to create titles for inclusing in a video with non-square pixels, such as PAL DV or similar.

Use synfig as normally, then when rendering, check out this page on synfig.org, note 6. This will allow you to render a number of pngs.

You can now use kdenlive to import these, using the slideshow command and overlay them on something else. If this does not succed for you, you can export your clip to pngs (perhaps kino is easier to use for this, or mlt or ffmpeg). You can then overlay your background and foreground clips, using

composite -compose src-over $FOREGROUND $BACKGROUND -depth 8 $OUTPUT

Note that the -depth 8 is important if you wish to use them with kdenlive and ffmpeg, as composite will use 16 bits by default, and this does not appear to work with kdenlive/ffmpeg.

Finally, if the slideshow import fails for you, you can create a clip using ffmpeg, something like this:

ffmpeg -i Output/output%03d.png -aspect 16:9 file-169.dv

where you replace your aspect and %03d as needed.

If you are interessted in titles, make sure to also check out titles for OpenMovie with inkscape. Note, that synfig should be able to import svg’s from inkscape, so you can create in inkscape, then animate in synfig.

Hello world!

Filed under: Uncategorized — Tags: , , , — madsdyd @ 3:05 pm

Welcome to my new blog.

I am starting this, because I need a place to put all kind of small notes, that are mostly related to free/open software, such as kdenlive which I am trying (hard) to use for editing videos of my family. Perhaps someone ends up here when googling for solutions to problems.

Other than that, I might rant about books or stuff that interests me.

Blog at WordPress.com.