Hack 64. Create Archos-Compatible Video
Use transcode to convert video files so that they work with the Archos line of video players.
The company Archos (http://www.archos.com) has released a number of portable media players over the past few years that play not only audio but also video files. The main problem with the video playback is that these video players can be rather choosy when it comes to which video formats they accept. The video must be within a certain resolution, have CBR MP3 audio, and use the MPEG4 video codec. Archos includes a Windows utility with the player that you can use to convert video files to a compatible format, but that isn't much help under Linux. In this hack I will describe how to use transcode to convert a video into a format compatible with the Archos line of video players.
I use transcode for this conversion because I've found that many of its default settings work well with Archos players. [Hack #63] provides an introduction to installing and using transcode.
While you can pass a number of options to transcode to specify input and output formats for videos, I've found in the case of the XviD video output format that transcode creates Archos-compatible videos without any tweaking. Even though the codec works, Archos video players can play back video only up to a certain resolution at a certain rate of frames per second, which varies for each player, but the AV400 series and the PMA400 series can play back up to 704 x 480 at 30 fps, and the AV300 series can play back up to 640 x 368 at 25 fps. So when converting a video, you first need to probe the video to see whether it fits within the specs, using the tcprobe utility [Hack #57]. Here's some sample output:
$ tcprobe -i sample.mpg [tcprobe] MPEG program stream (PS) [tcprobe] summary for sample.mpg, (*) = not default, 0 = not detected import frame size: -g 480x576 [720x576] (*) aspect ratio: 4:3 (*) frame rate: -f 25.000 [25.000] frc=3 PTS=0.8233, frame_time=40 ms, bitrate=2530 kbps audio track: -a 0  -e 44100,16,2 [48000,16,2] -n 0x50 [0x2000] (*) PTS=0.8233, bitrate=224 kbps -D 0 --av_fine_ms 0 (frames & ms)  
This video has a resolution of 480 x 576 and a frame rate of 25 fps, so it's well within the specs of both Archos series. To convert this, I just need to specify the input and output files, and which codec to encode to:
$ transcode -i sample.mpg -o sample-archos.avi -y xvid
Replace sample.mpg and sample-archos.avi with the input and output files you are going to use, respectively. transcode will convert the input file, and once it is finished, you can copy it directly to the Archos and play it back.
This works fine for videos that are within spec, but for videos that are outside of spec you need to add extra arguments so that transcode can change it for you. For instance, if the resolution of the file is within spec, but the frame rate is too high, use the --export_fps argument to bring it within spec:
$ transcode -i sample.mpg -o sample-archos.avi -y xvid \ --export_fps 25
If the input video's resolution is outside of spec, you will need to resize the video. Refer to [Hack #68] for more in-depth information on transcode's image resizing options. It's best in these cases to specify either the width or the height for the resize to ensure you keep the same aspect ratio on the video. Be sure to figure out beforehand what the final resolution will be, though, so you can make sure it is within spec. So, if I wanted to convert an MPEG video and resize it so that the width was 640 pixels with transcode's fast encoding, I would type:
$ transcode -i sample.mpg -o sample-archos.avi -y xvid -Z 640x,fast