1. Andrew's Corner »
  2. Linux Explorations... :

Encoding Video for the iRiver X20

I rescued this page from the fabulous WayBackMachine after I saw a few failed searches for it in my server logs. I have tidied the page up, sourced the X20 data sheet and stored it on my site and slightly modernised the FFmpeg syntax. I no longer have the device and I believe the iRiver company has been subsumed into a larger organisation. But here is the original page and I would be tickled pink if anybody uses it to create usable video on the fabulous iRiver X20!

Some time ago I acquired an iRiver X20 which I have been using to store my music collection in Ogg Vorbis format. This little player also does a fairly spectacular job playing video, despite having only a 320:240 screen, so I set myself the task of converting various family videos to a suitable format for such a player and such a screen. I quickly found that the Internet was littered with misinformation and so I have battled through with my two best friends Trial and Error until I produced a more than acceptable result. This small page contains the techniques that I eventually used and it is my hope that any readers will profit by my work.

Technical Specifications

There are many different iRiver media players and it seems obvious to me that many people have been copying and pasting encoding "recipes" suitable to a particular player and claiming some sort of universal recipe. My point is that the technique I will describe here is suitable for this iRiver device and should be modified to use with a different player. For the record I include some specifications of the iRiver X20:

iRiver X20 Specifications
Excerpts from the iRiver X20 datasheet.
Display 2.2inch QVGA TFT LCD (320x240)
Video Support MPEG4 SP, WMV SP / 320x240 / 15-30fps / Video Bitrate:32-512kbps / Audio Bitrate:8-320kbps
Audio Support MP3 : 5kbps ~ 320kbps / WMA : 8kbps ~ 320kbps / OGG : Up to Q10
Playback Time 22 hours (MP3, 128kbps, 44.1kHz,EQ Normal, Vol 20, LCD Off)
6 hours (avi, 320x240@30fps, video : 512kbps, Audio : MP3, 128kbps, 44.1kHz)
Capacity 2GB, 4GB, 8GB
Headphone Output 13mW + 13mW

The model I have is the 8GB one and I fitted the microSD expansion slot with another 2GB. It really is made for music playback not video playback with that tiny screen, and before you get your calculator out I will tell you that 320x240 is a 4:3 ratio screen as well. So I would definitely not recommend watching a feature movie on this screen, perhaps extracts from DVDs, home movies and the like?

Encoding the Video

To encode the video I am using FFmpeg, if you have only Windows at your disposal you have my sympathy but note that you too can use FFmpeg. For this particular example I am encoding a beautiful little video of my new grandchild Hannah taken from one of those cheap digital cameras that also take short movies. Key points of this encoding are:

  1. I use FFmpeg's native mpeg4 encoder rather than libxvid but take a bet both ways by changing the fourcc from FMP4 to XVID.
  2. Use of the avi container seems mandatory so that is what I have to use although there are much better containers available.
  3. Care must be taken with both audio and video bitrates so as not to exceed the iRiver's specifications. Frame rate I believe should not exceed 25fps.

Vital to produce quality video is 2 pass encoding and my first pass runs as follows

ffmpeg -i hannah.mov -vf scale=320:-1 -r 25 -pass 1 -an \
       -c:v mpeg4 -vtag XVID -b 512k -bf 0 \
       -mbd rd -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 \
       -f avi /dev/null

The magic setting, which was also required when I used Mencoder for this task, is eliminating B-frames completely. I have no idea why but it appears to be mandatory for video encoding to this little player. Now for the second pass where I also add in the sound:

ffmpeg -i hannah.mov -vf scale=320:-1 -r 25 -pass 2 \
       -c:v mpeg4 -vtag XVID -b:v 512k -bf 0 \
       -mbd rd -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 \
       -c:a libmp3lame -ar 44100 -b:a 128k -ac 2 \
       -f avi hannah.avi

These options are severely constrained by the requirements of the iRiver and sometimes in my experimentation a small deviation from these settings resulted in a file that is unplayable. Nevertheless playback is perfectly acceptable unless like me you are a purist and you think " What if I try ... "

Technology has moved on..

Since I started experimenting with this page technology has moved on somewhat and the new generation of media players are much more flexible than the X20. They can play aac sound, flac, h264 video and much, much more as well as use better containers like matroska and mp4. And so I will not develop this little page any further but I will leave it in place for anybody who may profit from the experimentation I have done with this wonderful little player. Now if I could only afford one of those amazing new Cowan players ...