Monday, October 18, 2010

make auto play dvd (pictures and movies) for windows in linux

Ah, every time I have to use windows, my head starts hurting just with the thought of it...
But when you have friends/relatives who don't know/want to use real computers, what can you do.

I burned a dvd with an Autorun.inf file (to auto play in windows) that runs a batch file to:
  1. View all pictures in the disk
  2. Play all the movies in the disk
In linux,
 find . -name "*jpg" -print0 | xargs -0 xzgv ; find . -name "*avi" -print0 | xargs -0 mplayer -fs
would have been pretty much all what I'd need.
Yeah, I know, blaming windows for not having a pipe (or a decent set of commands...) wouldn't be too fair, being that only unix type operating systems do and all... But you can guess how annoying it is when you are used to something this simple.

Anyway, this is what I did:
  1. Output all the picture files (including subdirectories) in a file, and change the "/"s to "\"s so windows can read it...
     find * -name "*JPG" -o -name "*jpg"|sed 's/\//\\/g' > pics_list.txt
  2. Do the same with the video files (3g2 is a cell phone format... apparently not many windows players can play it, so I ended up using linux's mplayer program's windows' version)
    find * -name "*3[Gg]2"|sed 's/\//\\/g' > vids_list.txt
  3. Got IrfanView (a picture/video viewer), because it can accept input from a file (step 1 can be used as a list for the files to view).
    You'll have to do this in windows... zip the IrfanView's directory and use ftp or something to get it into your linux computer.

    IrfanView can also be used to create a binary (a program) of a slideshow of all the pictures you choose in case you want a simple way. However doing this won't allow you to rotate/zoom the picture, etc.

  4. Got SMplayer (a video player---this has to be done in windows too...) but didn't work, so I ended up using the binaries of mplayer that came with that annoying GUI, and using it just like in linux. As above, put it in the directory you are creating the disk.

  5. With all this done I can write the batch file:
    set FILES=%CD%\pics_list.txt
    IrfanView\i_view32.exe /filelist=%FILES%
    mplayer\mplayer.exe -fs -vf scale=320:240 -playlist vids_list.txt
  6. Then make an icon file (optional). Use Gimp to resize any picture to 16x16 pixels, and save it as png.
    Use pngtopnm to change the file's format png->ppm.
    Use ppmtowinicon to make the .ico file.
     pngtopnm file.png > file.ppm
    ppmtowinicon file.ppm >file.ico
    #rm file.png file.ppm
  7. Write the Autorun.inf file with the name of the batch file to run, and the icon file as icon. This file has to be at the top of burned DVD's directory tree.
     [autorun]
    open=playme.bat
    icon=icon.ico
  8. Change all the text files written in windows to a DOS format. If you don't understand why, read here.
     #in the directory where all the text files are
    #Autorun.inf =auto play file
    # playme.bat =the file containing the viewer to view pictures and the player to play the movies.
    # pics_list.txt =list of pictures made by linux' find and sed
    # vids_list.txt =list of vids made by same as above
    for FILE in Autorun.inf pics_list.txt vids_list.txt playme.bat ; do unix2dos $FILE; done
  9. Burn the disk with your favorite program. growisofs example:
     #in the wanted to be top of the dvd's tree structure (where Autorun.inf is)
    growisofs -Z /dev/scd0 -R -J -V "pics2010" .
I did change the scale in order to be able to view some vids with very small screens, but that's about it.
The directory tree would result something like:
  • Autorun.inf
  • pics_list.txt
  • vids_list.txt
  • icon.ico
  • playme.bat
  • IrfanView #the directory containing IrfanView (viewer program)
  • mplayer #the directory containing windows version of mplayer (vid player)
  • pics #the directory containing the pictures
  • vids #the directory containing the vids
At least, after doing all this, there's like no way the person you want the contents to see is not going to be able to!
I think you can just let the OS to kinda guess the dvd's contents, and choose a program to read it. But having strange formats (like 3G2, I don't know if it's a world-wide thing, but in Japan all cell phones use this annoying format, and having so much of them using mencoder to change them to avi wasn't a good option) putting a player in the same dvd needs to be done.

No comments:

Post a Comment

Sociable