Ruben Laguna's blog

Mar 17, 2007 - 1 minute read - macro macros microsoft select tables windows word

How to select all tables in a Microsoft Word Document

It seems it’s impossible to do it from the user interface. But I found here that it could be done using a VB Macro:

Sub ChangeAllTablesToNormal()
Dim myTable As Table
For Each myTable In ActiveDocument.Tables
myTable.Select
Selection.Style = ActiveDocument.Styles("Normal")
Next myTable
ActiveDocument.Repaginate
End Sub

You may try to change ActiveDocument.Styles("Normal") to ActiveDocument.Styles("Tables Normal") as suggested by Abhishek if it doesn’t work for you.

Mar 10, 2007 - 4 minute read - files http psp rss server tranfer Uncategorized wifi wireless

Perl RSS server for the Sony PSP

I created this little perl program that creates an RSS feed from a set of video files (.mp4). This is useful to wirelessly transfer files to the PSP. The files will be saved in the VIDEO folder of the PSP.

You’ll need to install MP4::Info and HTTP::Daemon from CPAN first.

#!/usr/bin/perl -w
# this small program starts a http daeomon listening on port 1111 and provides a RSS feed
# to all .mp4 files stored in the 'videos' folder.
# This program is intended to transfer movie files via wireless. Using the sony psp RSS feed utility
# 1. Start the server with ./rssstandaloneserver.pl
# 2. Copy some video files on videos subfolder
# 3. Point you PSP browser to the http://<address> :<port>/ and the psp browser will display a page to # 1.  subscribe to the feed.
# 4. Go to Psp~~<span style="text-align:right;">Network</span>~~>RSS Channel and select the new feed
# 5. A list of items should appear and pressing X will download the video files to your VIDEO folder
#     on the PSP memory stick
#     Please note that depending of your firmware and the encoder you used on your files PSP may refuse
#     to play those files from the VIDEO folder. The VIDEO folder is not just like the MP_ROOT/100ANV01
#     folder, it behaves a different way. So please first check and transfer some of your files via USB to the
#     VIDEO folder and check that the PSP is able to play them from there.
#     If you encode your files using the Media Manager for PSP software then those files will work in any folder.
#     If you use 3GP encoder and QVGA MPEG-4 then those also will work in the VIDEO folder. but if you use
#     another resolution or AVC codec then it won't work.

use HTTP::Daemon;
use HTTP::Status;
use XML::RSS;
use MP4::Info;
use File::stat;
use Time::localtime;
use URI::Escape;
use Encode;
use LWP::MediaTypes;

#configuration
my $feedtitle = "Perl Video Feed";
my $feeddesc = "ecerulm perl video feed";
my $hostname = "192.168.1.3";
my $port = 1111;
my $debug = 1;
#end of configuration

my $rootaddr="http://" . $hostname . ":" . $port;
my $ct = "video/m4v";

LWP::MediaTypes::add_type($ct => qw(mp4 MP4));

my $d = HTTP::Daemon->new(LocalPort => $port) || die;

print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept) {
while (my $r = $c->get_request) {

my $url = URI::Escape::uri_unescape($r~~<span style="text-align:right;">url</span>~~>path);
print $r->method . " " . "$url\n" if $debug;
if ($r->method eq 'GET' and $url eq "/") {
print "sending index.htm\n";
$c->send_file_response("index.htm");
} elsif ($url eq "/index.rss") {
print "generating RSS content\n";
my $rss = new XML::RSS (version => '2.0');
$rss->channel(title => $feedtitle,
link => $rootaddr,
description => $feeddesc,
);

$rss->image(title => 'Perl video feed',
url => $rootaddr . "/images/feedimage.jpg",
link => $rootaddr,
width => 88,
height => 115,
description => 'feed logo'
);

# videos
my `fileList = <videos/*.MP4>;
         foreach $file (`fileList) {
my $tag = get_mp4tag($file) or die "No TAG info";
$date_string = ctime(stat($file)->mtime);

#my $enclosurelink = "http://192.168.1.3:1111/" . URI::Escape::uri_escape_utf8($file);
my $enclosurelink = $rootaddr . "/" . URI::Escape::uri_escape_utf8($tag->{NAM}) . ".MP4";
#my $enclosurelink =~ s/videos%2F/videos\//;
$rss~~<span style="text-align:right;">add_item(title => $tag</span>~~>{NAM},
enclosure => {
url=>$enclosurelink,
type=>$ct,
},
description => $tag->{NAM},
pubDate=>$date_string

);
}
# or save it to a file
my $rs = new HTTP::Response(RC_OK);
$rs->header('Content-type', "application/rss+xml");
$rs~~<span style="text-align:right;">content($rss</span>~~>as_string) if $r->method eq 'GET';
$c->send_response($rs);
print "RSS content sent\n" if $debug;

} elsif (-e "." . $url) {
print "the $url maps directly to a file in the filesystem\n" if $debug;
if ($r->method eq 'GET') {
print "sending " . $r->method . " " . $url . "\n";
$c~~<span style="text-align:right;">send_file_response("." . $url) if $r</span>~~>method eq 'GET';
} else {
print "sending HEAD " . $url . "\n";
$c->send_basic_header;
print $c "Content-type: $ct\n\n";
}
} else {
print "$url doesn't map to file directly. We assume the url is the movie title\n" if $debug;
my $t = $url;
$t = Encode::decode("UTF-8", $t);
$t = substr($t,1,-4); #remove the ".mp4" part.
print "looking for a file with movie title: $t\n" if $debug;

my `files = <videos/*.MP4>;
        my $found = 0;
        foreach $f (`files) {
my $tag = get_mp4tag($f) or next;
if ($tag->{NAM} eq $t) {
print "sending " . $f . " file\n";
$c->send_file_response($f);
$found = 1;
last;
}
}
unless ($found) {
print "cannot find " . $url . " using method " . $r->method . "\n";
$c->send_error(RC_NOT_FOUND);
}
}
}
$c->close;
undef($c);
}

The code is also available as a gist

Mar 10, 2007 - 1 minute read - 3gp avc converter folder manager media mp4 mpeg4 psp pss video

Sony PSP mpeg-4, avc and the video folder

I realized that the PSP refuses to play all my .MP4 files from the root VIDEO folder. If I move them to MP_ROOT/100ANV01 it will work but if I put them in the VIDEO folder PSP says that they are not compatible data. After investigating a little bit, it seems that it only refuses to play AVC encoded files all other are fine. Well, if fact only MPEG-4 320x240 files can be played from the video folder whereas AVC 480x272 is fine if I put them in MP_ROOT/100ANV01. Another interesting fact is that if I encode the files using Media Manager for PSP 2 instead of 3GP converter then I can play AVC files from the VIDEO folder.

Mar 7, 2007 - 1 minute read - 503 propfind proxy service subversion svn troubleshooting unavailable windows

Subversion error: 503 Service unavailable

If you faced the following subversion message in windows:

svn: PROPFIND request failed on '/repos/demosystemeic'
svn: PROPFIND of '/repos/demosystemeic': 503 Service Unavailable (http://x.x.x.x)

Probably the problem is caused because you are proxying your request via a proxy that doesn’t support HTTP methods like PROPFIND, etc.

If you don’t really need the proxy to access the repository edit the file c:\Documents and Settings_username_\Application Data\Subversion\servers (Note: Subversion directory is hidden)

and comment out the following items

Feb 28, 2007 - 1 minute read - encoder info mp4 perl psp sony tag title Uncategorized

MP4::Info fixed

Jonathan Harris has just released a new version of MP4::Info adding support for Sony PSP title and encoder.

Movie title and the encoder used are now accessible under $tag->{NAM} and $tag->{TOO}

use MP4::Info;
my $file = 'MAQ12331.MP4';

my $tag = get_mp4tag($file) or die "No TAG info";
printf "$file title:%s encoder: %s\n", $tag~~<span style="NAM;text-align:right;">, $tag</span>~~>{TOO};

see my related post

Feb 27, 2007 - 1 minute read - mp4 mtdt psp sony tag title Uncategorized usmt uuid

Support for Sony PSP format in MP4::Info

Today I opened a new feature request ( http://rt.cpan.org/Ticket/Display.html?id=25178) on MP4::Info perl module to include my patch to read the title in a Sony PSP files. Read this post to know more about the way title is encoded in PSP Mp4 files. With the following patch mp4infopatch.txt (applied to Info.pm) you can read the title of an PSP MP4 file using the following code snippet:

use MP4::Info;
my $file = 'MAQ12033.MP4';

my $tag = get_mp4tag($file) or die "No TAG info";
printf "$file title is %s\n", $tag->{NAM};

my $info = get_mp4info($file);
printf "$file title is %s\n", $info->{NAM};

my $mp4 = new MP4::Info $file;
printf "$file title is %s\n", $mp4->title;

UPDATE: Jonathan Harris has released a new version of MP4::Info with support for Sony’s PSP files. more info

Feb 25, 2007 - 2 minute read - example mp4 mtdt psp sony title usmt

Example of title encoded in a Sony PSP MP4 file

Here I included an example of a custom uuid USMT->MTDT block in a Sony PSP MP4 file

06A55450   75 75 69 64  55 53 4D 54  21 D2 4F CE  BB 88 69 5C  uuidUSMT!.O...i\
06A55460   FA C9 C7 40  00 00 00 90  4D 54 44 54  00 04 00 0C  ...@....MTDT....
06A55470   00 00 00 0B  55 C4 00 00  02 1C 00 22  00 00 00 04  ....U......"....
06A55480   15 C7 00 01  00 50 00 53  00 50 00 20  00 56 00 69  .....P.S.P. .V.i
06A55490   00 64 00 65  00 6F 00 20  00 39 00 00  00 26 00 00  .d.e.o. .9...&..
06A554A0   00 01 2A 0E  00 01 00 54  00 68 00 65  00 20 00 67  ..*....T.h.e. .g
06A554B0   00 6F 00 64  00 66 00 61  00 74 00 68  00 65 00 72  .o.d.f.a.t.h.e.r
06A554C0   00 00 00 32  00 00 00 03  55 C4 00 01  00 32 00 30  ...2....U....2.0
06A554D0   00 30 00 37  00 2F 00 30  00 32 00 2F  00 32 00 33  .0.7./.0.2./.2.3
06A554E0   00 20 00 32  00 30 00 3A  00 33 00 31  00 3A 00 33  . .2.0.:.3.1.:.3
06A554F0   00 34 00 00                                         .4..

The title “The godfather” is encoded in UTF-16 at position 06A554A7. To know a little bit more about the Sony PSP way of storing titles read this.

Feb 25, 2007 - 2 minute read - metadata mp4 mpeg-4 mtdt NAM psp sony tag title usmt

How to read title in Sony PSP MP4 files

If you had tried to read the title of a Sony PSP MP4 file with Ruby’s mp4info or Perl’s MP4::Info you probably noticed that the title is not stored in the NAM tag where it should be.

Those two libraries cannot access the title info in Sony PSP files because title info is stored in a propierary way in a custom uuid atom called USMT (User Media Tags).

Inside this atom there is child atom called MTDT (Meta Data) that lists meta data entries, one of them is the title. I found all this information in the movenc.c file from ffmpeg

Feb 25, 2007 - 1 minute read - avc filename memory mp4 mpeg-4 ms playstation portable psp sony stick

Sony PSP MP4 filenames

If you’re new to the PSP you must remember when copying files video files (created with 3GP converter or PSP Video 9) to your PSP that M4Vxxxxx.MP4 files go to the MP_ROOT/100MNV01 dir of the Memory Stick and the MAQxxxxx.MP4 files go to MP_ROOT/101ANV01 dir.

M4Vxxxxx files are conventional MPEG-4 files and MAQxxxxx are MPEG-4 files using AVC codec (recommended).