http://www.perlmonks.org?node_id=813031


in reply to Convert videos for my iPhone

I was asked privately whether this could be used to convert RealVideo to mp4 without losing resolution. Rather than try to fit my answer into a private /msg, I'm posting here.

Whether this converts RealVideo at all depends on the mencoder tool that it uses to do the conversion. I see .rm is a supported extension, so I'm guessing it does, but YMMV.

If it will do the conversion, it will try to reduce the resolution to that of an iPhone. If you want to change that, look in sub convert, which composes a big command line and executes it with system. In the snippet below, I've bolded the (hard coded) resolution constraints.

    my $cmd = join q{ },
        qq{mencoder $src_file_quoted -o $new_file_quoted},
        qq{-vf dsize=480:320:0,scale=0:0,expand -noautoexpand},
        qq{-oac faac -faacopts mpeg=4:object=2:raw:br=$OPT{abits}},

I've since forgotten exactly what that all does or exactly how to change it to keep the original resolution, but I found the mencoder documentation good enough to figure it out. What I remember is that the code, as written, fits the input video into the constraints given while retaining the aspect ratio (so a tall image will fit into the screen with black boxes at the sides instead of being stretched into a too-wide image).

The whole program could be seen as a really overblown wrapper around that one big command line. Changing what it does with videos you hand it depends on changing the command that it builds.

I hope this helps.