FFmpeg convert 3D Video for Nintendo 3DS

Декабрь 9th, 2011

There’s already manuals, but either they aren’t splitting, or splitting and «forgetting» about 2nd Video, or they producing files which Nintendo 3DS not seeing.

I’m proposing here short info about how to make 3D Video for Nintendo 3DS :)

1. First of all, you get somewhere 3d-video file, open it, and look, if it top/bottom or left/right. Anaglyph variants are not supposed to be splitted, so dump them.

2. Supposing you got «super-video-3d.mkv», and it’s top-bottom variant. First step – convert it to required size:

ffmpeg -y -i «super-video-3d.mkv» -s 400×480 -r 20 -aspect 10:6 -vcodec mjpeg -qscale 1 -vf crop=400:240:0:0 -acodec pcm_s16le -ac 2 «new_l.avi»
ffmpeg -y -i «super-video-3d.mkv» -s 400×480 -r 20 -aspect 10:6 -vcodec mjpeg -qscale 1 -vf crop=400:240:0:240 -an «new_r.avi»

If you have side-by-side video, then you need to run these commands:

ffmpeg -y -i «super-video-3d.mkv» -s 800×240 -r 20 -aspect 10:6 -vcodec mjpeg -qscale 1 -vf crop=400:240:0:0 -acodec pcm_s16le -ac 2 «new_l.avi»
ffmpeg -y -i «super-video-3d.mkv» -s 800×240 -r 20 -aspect 10:6 -vcodec mjpeg -qscale 1 -vf crop=400:240:400:0 -an «new_r.avi»

If you need mirror left-right videos, simply exchange «new_l.avi» and »new_r.avi».

Explaining parameters. -i specified input file; -s specified rescale size;  -r 20 meant that video must be 20 FPS (3DS doesn’t support more than that)

-vcodec mjpeg -qscale 1 specifies that video stream will be recoded with best quality. You can change quality here (1=best, 31=worst).

-vf  crop specified part of screen that need to be cuted (to get needed frame). Audio converted to PCM format (which is pretty big), but it’s better to have it, than to have some weird problems with audio (For example, if you recode video, and copy aac audio, you pretty sure will have broken file). And also make 2 channels with -ac 2 (If there 5.1 or more)

3. After we got two files  «new_l.avi» and «new_r.avi», we need to find out how many parts we need: simply divide length of movie by 10 minutes. For example, you need 10 parts.

4. Splitting + converting is as simple as cuting, here’s command example:

ffmpeg -y -i «new_l.avi» -i «new_r.avi » -vcodec copy -acodec adpcm_ima_wav -ar 22050 -ab 32 -ac 2 -vcodec copy -map 0:0 -map 0:1 -map 1:0 -ss 00:00:00 -t 00:09:59.90 «HTD_0001.AVI»
ffmpeg -y -i «new_l.avi» -i «new_r.avi » -vcodec copy -acodec adpcm_ima_wav -ar 22050 -ab 32 -ac 2 -vcodec copy -map 0:0 -map 0:1 -map 1:0 -ss 00:10:00 -t 00:09:59.90 «HTD_0002.AVI»

ffmpeg -y -i «new_l.avi» -i «new_r.avi » -vcodec copy -acodec adpcm_ima_wav -ar 22050 -ab 32 -ac 2 -vcodec copy -map 0:0 -map 0:1 -map 1:0 -ss 01:30:00 -t 00:09:59.90 «HTD_0010.AVI»

5. In this example, I’ve got encoded How To Train Your Dragon 3D for mine Nintendo 3DS. Totally cool picture, maybe not so cool in dark places (strong banding), but looks great with scenes with tiny details, and/or with fresh colors.

Cheers!

P.S. I updated this post, to cover side-to-side video as well.

Residual with Russian Grim Fandango

Август 20th, 2011

If you want to play Grim Fandango with russian subtitles (this is not about horrible voice, available in internet, only translation), then you need get latest Residual, and two more files.

Here, you can download archive with translation file GRIM.TAB and font file, you need to extract it where your GRIM.TAB placed. This translation made by well-known group, Enpy, kudos and credits to them!

After this, you need to get Residual, either download from their site, or build from git.

Git way:

git clone https://github.com/residual/residual.git

cd residual

./configure

gmake

After you built residual executable, you should try to add your game directory and play. If all went good, you can enjoy one of the greatest games ever with Russian translation, and great original voices :)

FreeBSD Java Plugin x64

Январь 28th, 2011

Here’s manual how to make installed diablo java x64 work in browsers, like in Opera for example.

If you installed JDK or JRE via PC-BSD PBI, then you should make soft-links

/usr/Programs/JavaJDK/diablo-jdk1.6.0 -> /usr/local/diablo-jdk1.6.0

Also, you need create additional link:

/usr/local/diablo-jdk1.6.0/jre/lib/amd64/server -> /usr/local/diablo-jdk1.6.0/jre/lib/amd64/client

After this, Opera will find installed JRE automatically, and enable it.

To play some games/launch some apps, you need to tweak java permissions (to allow sound, graphics, filesystem access, etc).

For Opera:

edit (under root) file /…. opera.policy

and add there some of this lines (the choice is yours!):

grant {

permission java.net.SocketPermission  #to allow applets access whole internet

permission java.awt.AWTPermission «accessClipboard»;

permission java.net.SocketPermission «localhost:5577″ ,  «accept, connect, listen»;

permission java.lang.RuntimePermission «loadLibrary.<library name>»;

permission javax.sound.sampled.AudioPermission «play»

permission java.security.AllPermission; #Not recommended at all ;)

}

How’s there FreeBSD

Январь 26th, 2011

FreeBSD Quarterly Status Report is out – now it’s time to check what’s new in Q4 2010 happened.

BSDInstall is on going – not rewritten sysinstall, but new program to replace it. It’s pretty good with advanced features, like gpt, PXE install, live CD as installation media, etc.

In few weeks from Jan 2011, Chromium could conquer FreeBSD’s minds as well as other OSes. Great work, porters!

ZFS v28 which will bring a lot of use, and probably a lot of license problems, almost done. Eager to wait for it :)

Also, I glad that FreeBSD is on it’s way for wider audience - FreeBSD as Home Theater PC will be GGrrreat feature as for me.

And of course, EC2 ans PS3 platforms. One of them is for fun, while other – for mature and efficient products. Honestly, I’m lacking of some FreeBSD solution like DRBD, Heartbeat or whatever. Or maybe it’s just me.

Resource containers, interesting project which is very close to its release, will bring to platform even more stability, allowing to give some level of access to untrusted users. Or to unexperienced ones :)

Many, many other small things which maybe didn’t even mentioned in report are important too. The rain it’s not a ten big or cool drops, it’s all of them.

FreeBSD Rocks! Go, Beastie, Go!

JDBC replicating tool from scratch

Август 6th, 2010

I had simple task to perform – I need to replicate DB from one server to other.

Quite simple, as I thought :)

Let’s take some tool, which can handle all actions I need. And which can be configured as I need.

But, really, I don’t need at #slave all tables. I have to replicate only few tables.  Actually, I need to replicate part of data from #master tables, according to specific requirements.  And in one table I need replication to do only insert but not modify/delete records. And table names in #master and #slave not necessarily must be equals. Oh, almost forget, #master is PostgreSQL, and #slave is MySQL. And #slave in near future could be replaced by either PostgreSQL or Oracle.

Well, I was in need of pretty smart replication tool, which have to be able to do all tasks.  No tool available in world (which I searched) doesn’t met all of the requirements. So, I had to write one.

1. Technology. I’ve chose plain JDBC, because of good support by DB makers, and because my tool doesn’t really care which exactly type is there Database. I can easily replicate from PostgreSQL,MySQL,Oracle, etc. to any of these without changing single line in code, only change meta-info in configuration file.

2. Caveat: MySQL column names.  My config file contains info about type of DB, mainly because of MySQL. In PostgreSQL I can write such queries:

SELECT COST FROM SOME_TABLE;

Without worrying that cost is reserved word. But in MySQL, I should escape column names:

INSERT INTO `COST` …

3. Caveat: MySQL Timestamp which can be ’0000-00-00 00:00:00′. Normal bases and programs knew sane dates, NULL dates. MySQL knew one more – it’s Jesus birthday I assume, ’0000-00-00 00:00:00′. This is crazy and should be avoided.  For Java application, add such string to connection URL:

?zeroDateTimeBehavior=convertToNull

This caveat contains one more bug, even with this fix. Select from table with timestamps returns all rows, for example 5 of them. 3 of them contains valid timestamps (2014-…), and 2 more contains zero dates, which converts to NULL.  Most horrible thing is count(*) returns 3, not 5 :(

I hope this behavior will get fix soon.

4. Caveat: MySQL timestamps ot like to be NULL. When table created, if not specified, Timestamp fields get default properties: Not Null, default value current_timestamp for first, and zero timestamp to all others timestamps. If you want to replicate to MySQL, you should mark all timestamps as nullable (of course, if your application required this).

5. Caveat:  Boolean mapping in MySQL. It’s mapped only to Tinyint(1). If you create tinyint without size, you’ll get Tinyint(4), which is not treated as Boolean.

6. Features: JDBC allowed me create simple ways to replicate data, even not knowing column types, sizes of tables. Of course, order and types of tables must be synced while #slave will be created. But anyway, it’s pretty flexible:

preparedStatement = connection.prepareStatement(«select * from » + name);
preparedStatement.execute();

ResultSetMetaData setMetaData = resultSet.getMetaData();

PreparedStatement statement = connection2.prepareStatement(«Insert into » + name + »  values (?,?,?,?,?)»);

/* count of question marks = setMetaData.getColumnCount() */

resultSet = preparedStatement.getResultSet();

while (resultSet.next())
{

for (int i = 1; i <= setMetaData.getColumnCount(); i++)
{
Object o = resultSet.getObject(i);

statement.setObject(i, o); // yes, that simple.
}

With JDBC you don’t have to worry about any types of SQL Injections – they are simply not working. More, you don’t have to bother escaping string, because you can use code statement.setObject(1, «Any » / \ ‘ \ » ‘.;’; line»);

Of course real replication tool not as trivial as example, it checked for exists data, deleted from master data, need for update, additional conditions.

Anyway, JDBC provides very good and solid ways to interchange data between any types of databases.