Ruben Laguna’s blog

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:

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
<span class='line'>Sub ChangeAllTablesToNormal()
</span><span class='line'>Dim myTable As Table
</span><span class='line'>   For Each myTable In ActiveDocument.Tables
</span><span class='line'>      myTable.Select
</span><span class='line'>      Selection.Style = ActiveDocument.Styles("Normal")
</span><span class='line'>   Next myTable
</span><span class='line'>   ActiveDocument.Repaginate       
</span><span class='line'>End Sub</span>

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

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 320×240 files can be played from the video folder whereas AVC 480×272 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.

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<span class='line'>#!/usr/bin/perl -w
</span><span class='line'>
</span><span class='line'># this small program starts a http daeomon listening on port 1111 and provides a RSS feed
</span><span class='line'># to all .mp4 files stored in the 'videos' folder. 
</span><span class='line'># This program is intended to transfer movie files via wireless. Using the sony psp RSS feed utility
</span><span class='line'># 1. Start the server with ./rssstandaloneserver.pl 
</span><span class='line'># 2. Copy some video files on videos subfolder
</span><span class='line'># 3. Point you PSP browser to the http://&lt;address>:&lt;port>/ and the psp browser will display a page to
</span><span class='line'># subscribe to the feed. 
</span><span class='line'># 4. Go to Psp->Network->RSS Channel and select the new feed 
</span><span class='line'># 5. A list of items should appear and pressing X will download the video files to your VIDEO folder
</span><span class='line'>#     on the PSP memory stick
</span><span class='line'># Please note that depending of your firmware and the encoder you used on your files PSP may refuse
</span><span class='line'># to play those files from the VIDEO folder. The VIDEO folder is not just like the MP_ROOT/100ANV01 
</span><span class='line'># folder, it behaves a different way. So please first check and transfer some of your files via USB to the 
</span><span class='line'># VIDEO folder and check that the PSP is able to play them from there. 
</span><span class='line'># If you encode your files using the Media Manager for PSP software then those files will work in any folder. 
</span><span class='line'># If you use 3GP encoder and QVGA MPEG-4 then those also will work in the VIDEO folder. but if you use 
</span><span class='line'># another resolution or AVC codec then it won't work. 
</span><span class='line'>use HTTP::Daemon;
</span><span class='line'>use HTTP::Status;
</span><span class='line'>use XML::RSS;
</span><span class='line'>use MP4::Info;
</span><span class='line'>use File::stat;
</span><span class='line'>use Time::localtime;
</span><span class='line'>use URI::Escape;
</span><span class='line'>use Encode;
</span><span class='line'>use LWP::MediaTypes;
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>#configuration
</span><span class='line'>my $feedtitle = "Perl Video Feed";
</span><span class='line'>my $feeddesc = "ecerulm perl video feed";
</span><span class='line'>my $hostname = "192.168.1.3";
</span><span class='line'>my $port = 1111;
</span><span class='line'>my $debug = 1;
</span><span class='line'>#end of configuration
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>my $rootaddr="http://" . $hostname . ":" . $port;
</span><span class='line'>my $ct = "video/m4v";
</span><span class='line'>
</span><span class='line'>LWP::MediaTypes::add_type($ct => qw(mp4 MP4));
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>my $d = HTTP::Daemon->new(LocalPort => $port) || die;
</span><span class='line'>
</span><span class='line'>print "Please contact me at: &lt;URL:", $d->url, ">\n";
</span><span class='line'>while (my $c = $d->accept) {
</span><span class='line'>      while (my $r = $c->get_request) {       
</span><span class='line'>        
</span><span class='line'>        my $url = URI::Escape::uri_unescape($r->url->path);
</span><span class='line'>      print $r->method . " " . "$url\n" if $debug;        
</span><span class='line'>          if ($r->method eq 'GET' and $url eq "/") {
</span><span class='line'>          print "sending index.htm\n";              
</span><span class='line'>              $c->send_file_response("index.htm");
</span><span class='line'>          } elsif ($url eq "/index.rss") {
</span><span class='line'>             print "generating RSS content\n";
</span><span class='line'>               my $rss = new XML::RSS (version => '2.0');
</span><span class='line'>         $rss->channel(title          => $feedtitle,
</span><span class='line'>                       link           => $rootaddr,
</span><span class='line'>                       description    => $feeddesc,
</span><span class='line'>                       );
</span><span class='line'>
</span><span class='line'>         $rss->image(title       => 'Perl video feed',
</span><span class='line'>                     url         => $rootaddr . "/images/feedimage.jpg",
</span><span class='line'>                     link        => $rootaddr,
</span><span class='line'>                     width       => 88,
</span><span class='line'>                     height      => 115,
</span><span class='line'>                     description => 'feed logo'
</span><span class='line'>                     );
</span><span class='line'>
</span><span class='line'>               
</span><span class='line'>         # videos
</span><span class='line'>         my @fileList = &lt;videos/*.MP4>;
</span><span class='line'>         foreach $file (@fileList) {   
</span><span class='line'>            my $tag = get_mp4tag($file) or die "No TAG info";
</span><span class='line'>            $date_string = ctime(stat($file)->mtime);
</span><span class='line'>          
</span><span class='line'>          #my $enclosurelink = "http://192.168.1.3:1111/" . URI::Escape::uri_escape_utf8($file);
</span><span class='line'>          my $enclosurelink = $rootaddr . "/" . URI::Escape::uri_escape_utf8($tag->{NAM}) . ".MP4";
</span><span class='line'>          #my $enclosurelink =~ s/videos%2F/videos\//;
</span><span class='line'>            $rss->add_item(title => $tag->{NAM},
</span><span class='line'>                  enclosure   => { 
</span><span class='line'>                  url=>$enclosurelink,                
</span><span class='line'>                type=>$ct,                
</span><span class='line'>                },
</span><span class='line'>                  description => $tag->{NAM},
</span><span class='line'>                  pubDate=>$date_string
</span><span class='line'>              
</span><span class='line'>                    );
</span><span class='line'>                } 
</span><span class='line'>         # or save it to a file
</span><span class='line'>         my $rs = new HTTP::Response(RC_OK);
</span><span class='line'>         $rs->header('Content-type', "application/rss+xml");
</span><span class='line'>         $rs->content($rss->as_string) if $r->method eq 'GET';         
</span><span class='line'>         $c->send_response($rs);
</span><span class='line'>         print "RSS content sent\n" if $debug;
</span><span class='line'>                 
</span><span class='line'>      } elsif (-e "." . $url) {
</span><span class='line'>                print "the $url maps directly to a file in the filesystem\n" if $debug;     
</span><span class='line'>            if ($r->method eq 'GET') {
</span><span class='line'>          print  "sending " . $r->method . " " . $url . "\n";                 
</span><span class='line'>              $c->send_file_response("." . $url) if $r->method eq 'GET';
</span><span class='line'>        } else {
</span><span class='line'>          print "sending HEAD " . $url . "\n";
</span><span class='line'>          $c->send_basic_header;
</span><span class='line'>                  print $c "Content-type: $ct\n\n";
</span><span class='line'>        } 
</span><span class='line'>      } else {
</span><span class='line'>          print "$url doesn't map to file directly. We assume the url is the movie title\n" if $debug;
</span><span class='line'>          my $t = $url;       
</span><span class='line'>        $t = Encode::decode("UTF-8", $t);       
</span><span class='line'>              $t = substr($t,1,-4); #remove the ".mp4" part. 
</span><span class='line'>        print "looking for a file with movie title: $t\n" if $debug;
</span><span class='line'>        
</span><span class='line'>        
</span><span class='line'>              my @files = &lt;videos/*.MP4>;
</span><span class='line'>        my $found = 0;
</span><span class='line'>        foreach $f (@files) {  
</span><span class='line'>           my $tag = get_mp4tag($f) or next;         
</span><span class='line'>         if ($tag->{NAM} eq $t) {
</span><span class='line'>          print  "sending " . $f . " file\n";                 
</span><span class='line'>            $c->send_file_response($f);
</span><span class='line'>          $found = 1;
</span><span class='line'>          last;
</span><span class='line'>         }         
</span><span class='line'>        }
</span><span class='line'>        unless ($found) {
</span><span class='line'>            print "cannot find " . $url . " using method " . $r->method . "\n";
</span><span class='line'>                $c->send_error(RC_NOT_FOUND);
</span><span class='line'>        }
</span><span class='line'>          }
</span><span class='line'>      }
</span><span class='line'>      $c->close;
</span><span class='line'>      undef($c);
</span><span class='line'>}</span>

The code is also available as a gist

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

http-proxy-host=xxx
http-proxy-port=xxx

NOTE: In linux the file is located at ~/.subversion/servers+

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}

1
2
3
4
5

1
2
3
4
5
<span class='line'>use MP4::Info;
</span><span class='line'>my $file = 'MAQ12331.MP4';
</span><span class='line'>
</span><span class='line'>my $tag = get_mp4tag($file) or die "No TAG info";
</span><span class='line'>printf "$file title:%s encoder: %s\n", $tag->{NAM}, $tag->{TOO};</span>

see my related post

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:

1
2
3
4
5
6
7
8
9
10
11

1
2
3
4
5
6
7
8
9
10
11
<span class='line'>use MP4::Info;
</span><span class='line'>my $file = 'MAQ12033.MP4';
</span><span class='line'>
</span><span class='line'>my $tag = get_mp4tag($file) or die "No TAG info";
</span><span class='line'>printf "$file title is %s\n", $tag->{NAM};
</span><span class='line'>
</span><span class='line'>my $info = get_mp4info($file);
</span><span class='line'>printf "$file title is %s\n", $info->{NAM};
</span><span class='line'>
</span><span class='line'>my $mp4 = new MP4::Info $file;
</span><span class='line'>printf "$file title is %s\n", $mp4->title;</span>

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

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).

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

+/*********
+
+     PSP USMT->MTDT meta info block format  (some guessing)
+     
+        - Note that clips play fine without this block.
+     
+     int32    : size of MTDT block
+     char[4]  : "MTDT"
+     int16    : Number of sub-data blocks (payloads)
+                    0x0001 EOT markers have 1 block
+                    0x0004 is the most I've seen in an information block (title, date, etc)
+     
+     Some number of data blocks, which take the form of:
+     
+        int16   : size of sub-data block
+        int32   : block type ID  (possibly 2 int16s:  unk & type )
+                    0x01 = Title
+                    0x03 = Timestamp (date format = "+%Y-%m-%d %k:%M:%S")
+                    0x04 = Creator Name
+                    0x0A = End of Track Marker
+                    0x0B = UNKNOWN (appears in info MTDT blocks)
+        int16   : ?flags? - generally 0x55c4 or 0x15c7, seen 0x2a0e, possibly font or language?)
+                    - Timestamp seems to always have 0x55c4
+        int16   : type of payload that follows?  (int, string, etc..?)
+                    - Unicode strings have 0x0001
+                    - short[] data has 0x0000
+        data[]  : Payload (strings are UTF16-BE short[] with 0x0000 terminator)
+        
+        
+        BLOCK IDs
+        
+           0x000A - Appear at end of tracks
+                
+                - flags always = 0x55c4
+                - Payload looks like: 0x0000 0x0100 0x0000 0x0000
+                
+           0x000B - Appears in meta data
+                - Payload looks like: 0x0000 0x?????  
+                - (0x???? probably flags- seen 0x1c02, 0x5cfe.  Maybe something with aspect ratio or frame rate?)
+        
+********/

Currently neither mp4info nor MP4::Info are capable of decoding this USMTMTDT block. I’m looking into MP4::Info in order to add support for it. I will post something here if I got it working.UPDATE: I got it working read post

Example of Title Encoded in a Sony PSP MP4 File

Here I included an example of a custom uuid USMTMTDT 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.

Copyright © 2015 - Ruben Laguna - Powered by Octopress