video without SMC - first success + tutorial for linux and windows

Tutorial on

How to create video for the Sansa Fuze without using SMC.

(version 1.1)

Contents:

  1. Fuze video format specifications

  2. Video Processing on Linux

  3. Video Processing on Windows

  4. Alternatives

  5. Conclusion

1. Fuze video format specifications

Video

  • codecs: according to the MPEG-4 Part 2 (Visual) Standard ( required ), e.g. ffmpeg’s mpeg4, Xvid and possibly others
  • video frame size: 224x176 pixel ( required )
  • frame rate: 20 fps ( required )
  • video keyframe interval: 15 frames
  • video bit rate: 500-700 kbps
  • non-interlaced, non-anamorphic

Audio

  • codecs: constant bitrate MPEG-1 Part 3 Layer 3, known as MP3 ( required )
  • audio channels: 2 that is to say stereo ( required )
  • audio sampling rate: 44100 Hz ( required )
  • audio bitrate: 128 kbps

AVI Container

  • OpenDML index: standard indexes every 4000 video frames ( required )
  • Audio alignment: align on interleaves ( required )
  • Interleave interval: every 2 video frames
  • legacy index is beeing ignored by the Fuze
  • RIFF-AVIX extensions are ignored too

2. Video processing on Linux

Let me start with some Linux related instructions because linux folks did not yet have any chance to use videos on their Fuze. This was the main motivation for me to find an alternative to the Sansa Media Converter windows software.

2.1 Software requirements

The following instructions are somewhat Debian - centric because that is the system I run with. Anyway, users of other Linux distributions should not have problems to translate them.

I prefer the mencoder software for the video conversion part but there are certainly other possible solutions to reach the goals.

Add the following package repository to your /etc/apt/sources.list file:

deb http://www.debian-multimedia.org lenny main

Install packages by

apt-get update
apt-get install mencoder wine ttf-mscorefonts-installer

If you never used it before you might want to configure your wine settings by
running

winecfg

Get the AVI-Mux GUI windows software. Create a directory under your wine program folder (note that I run a german desktop) and unpack the software, e.g.

mkdir ~/.wine/drive_c/Programme/avimux
cd ~/.wine/drive_c/Programme/avimux
unzip <path_to>/AVI-Mux_GUI-1.17.8.zip   # MUST replace <path_to>!

2.2 Basic Step-by-step Procedure

Although there exist an easy to use shell script (see 2.3 below) to achieve both video conversion and AVI remuxing by a single shot I’d like to show the underlying steps first. You can savely skip this chapter if you like to go on quickly.

2.2.1 Video Conversion

I have choosen to run a 2-pass conversion with mencoder. You can simply
run the following looooong commands directly from a Linux shell (bash in my case):

srcvideo=<myvideo>    # MUST edit! e.g. “/data/user/myvideo.mkv” or: “dvd://1”
outfile=my.avi        # MUST edit!

mencoder -ffourcc DX50 -ofps 20 -vf pp=li,expand=:::::224/176,scale=224:176,harddup </font>
    -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=650:vmax_b_frames=0:keyint=15:turbo:vpass=1 </font>
    -srate 44100 -af resample=44100:0:1,format=s16le -oac mp3lame -lameopts cbr:br=128 </font>
    “$srcvideo” -o “$outfile”
mencoder -ffourcc DX50 -ofps 20 -vf pp=li,expand=:::::224/176,scale=224:176,harddup </font>
    -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=650:vmax_b_frames=0:keyint=15:vpass=2 </font>
    -srate 44100 -af resample=44100:0:1,format=s16le -oac mp3lame -lameopts cbr:br=128 </font>
    “$srcvideo” -o “$outfile”

If you look at the two menconder commands you will notice that I use the mpeg4 codec from libavcodec library which in turn is part of the ffmpeg project. The Xvid encoder works as well but you need different options (-ovc xvid -xvidencopts …). I’ll skip the full command lines here.

2.2.2 AVI Remuxing

The AVI Container has to be rebuild with some specific settings. I could not find any native Linux software to achieve this. Therefore I have choosen to use the excellent AVI-Mux GUI software under wine. You can run it like this:

WINEPREFIX=“$HOME/.wine” wine “C:\Programme\avimux\AVIMux_GUI.exe” &

You need to adjust some settings. Press the “settings” button. In the “Input/output settings” window press the “AVI file structure” button in the Output button group. Adjust the values to match the following screenshot:

Click “OK” to proceed. This will save the new settings as default for later runs.

Load the video file generated by the video conversion procedure (right mouse click in the “open files” entry widget). You must click on this video file to highlight the entry and now you can press the “generate data source from files” button. Finally you press the “start” button, choose an output file name and let the program finish.

2.3 All-in-One Shell Script

I wrote a little shell script pvc.sh ( P ortable media players V ideo C onverter) to ease video processing in particular for the SanDisk Sansa Fuze. Download link and most up-to-date information is provided on this post.

Running all the steps described under 2.2 above - including the setup of AVI-Mux GUI options and executing under wine - is as simple as running the command

pvc.sh sourcevideo.mpeg fuzevideo.avi

2.4 Copy video to Fuze

Well, that is simple. Connect your Fuze in MSC mode to the computer. Drag and drop the processed and remuxed video file into the VIDEO folder on internal storage or SDHC card.

You don’t need a .thm file which is nothing else but a JPEG image to serve as a thumbnail.

Disconnect your Fuze, wait for database refresh and ENJOY !

3. Video processing on Windows

3.1 Software requirements

Obviously you need a video conversion software. You could install the windows executable of MEncoder and run it from command line but most users would prefer a comfortable GUI application. I recommend the free MediaCoder which is a nice GUI around many open source projects applications, including mencoder, ffmpeg, xvid and many others. It runs on Linux boxes under wine too.

The second part of required software is the AVI-Mux GUI. Get it from the given site and extract/install it.

3.2 Video Conversion

The specific settings for MediaCoder can be saved in preset files. For the Fuze you can add the following code to a new file called Fuze.xml into the MediaCoder directory tree (…\Programme\MediaCoder\Presets\Video or similar folder name)

\<?xml version="1.0" encoding="iso8859-1"?\>  
\<MediaCoderPrefs\>  
 \<node key="overall.ui.optionTab"\>5\</node\>  
 \<node key="overall.video.mode"\>Two-Pass\</node\>  
 \<node key="overall.video.bitrate"\>650\</node\>  
 \<node key="overall.video.format"\>MPEG4\</node\>  
 \<node key="overall.container.format"\>AVI\</node\>  
 \<node key="audiofilter.resample.samplerate"\>44100\</node\>  
 \<node key="videofilter.scale.enabled"\>true\</node\>  
 \<node key="videofilter.scale.width"\>224\</node\>  
 \<node key="videofilter.scale.height"\>176\</node\>  
 \<node key="videofilter.frame.enabled"\>true\</node\>  
 \<node key="videofilter.frame.fps"\>20\</node\>  
\</MediaCoderPrefs\>

Simply start MediaCoder, choose the Fuze’s presets (menu File/Load Preset), load your video file and convert it.

Small bug I notized with MediaCoder 0.7.1.4490 (at least under wine in Linux): The Summary tab contents does not alway update. If you encounter the same oddity then change to another tab and back to Summary and everything is fine.

3.3 AVI Remuxing

Run AVI-Mux GUI with the settings as described above (see screenshot provided in 2.2.2).

3.4 Copy video to Fuze

See above (2.4).

4. Alternatives

Certainly there exist alternative solutions which you could try out, e.g. look at this thread about video4fuze for a cross-platform GUI approach.

5. Conclusion

With the given example procedures it should hopefully be easy for the average user to accomplish video conversion for the Fuze without a need for the Sansa Media Converter.

The results are quite usable by now. I know there is still room for video quality improvements but I consider this mostly off-topic and you should better consult a specialized video forum for help and discussion.

Any feedback is very welcome!
Good luck and ENJOY your Fuze!

ChangeLog:

version 1.1

  • added info about new shell script solution on Linux

Message Edited by ewelot on 08-25-2009 09:28 PM

Message Edited by ewelot on 08-25-2009 10:19 PM

Great post! I think you should mark it as the solution, so it can be quickly accessed from the first one.

Good point. Thanks!

Great job @ewelot and @ssorgatem.  I have been having all sorts of trouble with SMC.  Now I don’t need it anymore.

Thanks for all your hard work.

Well done, ewelot! Video from Linux to Fuze is huge!

 

I wish that there was native Linux software that could do the AVI-Mux GUI step, but I looked too and no, there really isn’t one. If only there were secret undocumented lavcopts that would do the whole process with mencoder…well, a girl can dream, anyway. Kudos for finding a GPL’d app, at least :slight_smile:

avi-mux GUI could be ported. It’s written in c++ I think. First, you should port it to mingw, and when it compiles  in windows with mingw, then i would be able to compile in any unix with winelib. Then, stripping the ui and replacing any resting win32 calls should get rid of the winelib dependency.

It doesn’t seem a very difficult process… but avi-mux GUI pretty large, I don’t know how well commented is it’s code, and it wouldn’t be very funny to do, all of the above.

Or maybe it would be easier to reimplement what avimux-GUI does. My c++ skills are reduced to being able to red *some* code snippets, but maybe there’s some else out there who could be interested in it.

Big thanks for the tutorial. Converted one test file and it works great. This really opens up a whole new world for me to use sansa fuze, since I don’t have windows and thus haven’t used the video playback before :slight_smile:

@ewelot wrote:

Tutorial on

How to create video for the Sansa Fuze without using SMC.

(version 1.0)

 

 

1. Fuze video format specifications

AVI Container

  • legacy index is beeing ignored by the Fuze

 

 

 

One question comes to my mind after reading this: If the legacy index is ignored by the Fuze, why is ‘create legacy index’ turned on?

If I understand it right, the fuze needs open-dml muxing with special parameters. In other forums I read, that mencoder by default uses open-dml output. Is this correct? And if so, what are the problematic muxing parameters that cannot be fulfilled by mencoder?

Although your proposed procedure works very nice (excelent work!), it would be even nicer if mencoder could be used for muxing also.

struct

Linux folks: Here is a bash script to ease video conversion for the Fuze! It does everything in one call from the command line. You don’t need any special setup. Just have mencoder installed and AVI-Mux GUI unpacked. It should run on any Linux distribution.

Installation:

Download my script pvc.sh and save it to disk with unix line endings. Verify file integrity by running

md5sum pvc.sh

which must print the following hash value:

d9b3efdec6a32f1853f59784101d8503  pvc.sh

Install as root in appropriate place, e.g.

install -p pvc.sh /usr/local/bin

Usage examples:

  • show some help for available options (which are rarely used anyway):

pvc.sh -h

  • convert a video file for the Fuze:

pvc.sh anyvideo.mkv file.avi

  • convert chapters 3 to 5 of title 2 from an anamorpic 16:9 DVD:

pvc.sh -x dvd://2:3-5 dvdchapter.avi

  • get youtube video ready for the Fuze (using youtube-dl)

youtube-dl “http://www.youtube.com/watch?v=HvZNg_lv33o
pvc.sh HvZNg_lv33o.flv sansa.avi

Have fun!

Edit: I had to upload my script to an external location because I couldn’t use the internal message editor to copy the script content. It would be messed up with several smileys added in upon posting. Strange.

Edit: The script has been upgraded to version 1.1 (new link and md5sum).

Message Edited by ewelot on 09-03-2009 10:04 PM

@struct wrote:

One question comes to my mind after reading this: If the legacy index is ignored by the Fuze, why is ‘create legacy index’ turned on?

 

If I understand it right, the fuze needs open-dml muxing with special parameters. In other forums I read, that mencoder by default uses open-dml output. Is this correct? And if so, what are the problematic muxing parameters that cannot be fulfilled by mencoder?

 

Although your proposed procedure works very nice (excelent work!), it would be even nicer if mencoder could be used for muxing also.

 

struct

I’d recommend to keep the legacy index just for compatibility with players/devices other than the Fuze which rely on this index.

Mencoder and almost any other encoding software will write OpenDML indexes on AVI files > 1GB only. No way to force these indexes on smaller files, unfortunately.

@ssorgatem wrote:
avi-mux GUI could be ported. It’s written in c++ I think. First, you should port it to mingw, and when it compiles  in windows with mingw, then i would be able to compile in any unix with winelib. Then, stripping the ui and replacing any resting win32 calls should get rid of the winelib dependency.

It doesn’t seem a very difficult process… but avi-mux GUI pretty large, I don’t know how well commented is it’s code, and it wouldn’t be very funny to do, all of the above.

Or maybe it would be easier to reimplement what avimux-GUI does. My c++ skills are reduced to being able to red *some* code snippets, but maybe there’s some else out there who could be interested in it.

In theory, no, it shouldn’t be hard to port to C on *nix. In practice, maybe not. I found a project page that was started in 2008 where the plan was to port AVI-mux GUI to Linux, but it hadn’t been updated beyond that; there must be a reason they gave up. I’m in no position to complain, though, since I don’t have time to port it myself.

I find it hard to believe that nobody else has written code that does this. I mean, Linux has at least two implementations of almost everything from system commands to entire environments, and I suspect this is also true for open source Windows apps, but only one person has ever written code to let you put an OpenDML index every 4000 frames? Well, besides Sandisk. To be fair, I’m not all that familiar with video specs, so it’s possible that someone has and I’m not searching for the right jargon.

Message Edited by Peach on 08-26-2009 06:07 AM

This thread wins my approval. Very good stuff!

No more faulty, buggy SMC for me!!! No more having to convert Youtube videos to a SMC-supported format, just to convert them again!!!  Well done, bro.  :smileyvery-happy:

Message Edited by halonachos117 on 08-31-2009 08:07 PM

ewelot wrote: 

 

Mencoder and almost any other encoding software will write OpenDML indexes on AVI files > 1GB only. No way to force these indexes on smaller files, unfortunately.

Maybe a feature request to the mplayer team could do the trick?

Tried both the deb installer as well as the universal distribution under Ubuntu 9.04 and I can’t get the deb version to work but running the universal works perfectly!

When I press convert, the terminal flashes up for just a split second and then wine comes up with an error saying that it basically crashed. Great tool though! I’ve been wanting to get video on this thing since I got it a couple months ago!

@bassmannate wrote:

Tried both the deb installer as well as the universal distribution under Ubuntu 9.04 and I can’t get the deb version to work but running the universal works perfectly!

 

When I press convert, the terminal flashes up for just a split second and then wine comes up with an error saying that it basically crashed. Great tool though! I’ve been wanting to get video on this thing since I got it a couple months ago!

Are you talking about video4fuze? It has its own dedicated thread. Maybe you should post there if you want to get help or discuss things related to this GUI application. If you like to report/discuss issues with the underlying applications (mencoder, AVI-Mux GUI) or the command line conversion tool pvc.sh you are welcome to continue posting here, of course.

A new version 1.1 of the P ortable Media Player V ideo C onverter for Linux (pvc.sh) has been uploaded here (md5sum d9b3efdec6a32f1853f59784101d8503). Thanks to Jeff Ammons for his bug report!

For more information read the related post.

Message Edited by ewelot on 09-03-2009 10:17 PM

Great tutorial! With my version of mencoder (dev-SVN-r27637-4.3-openSUSE) the mencoder command will hang indefinitely and a little spelunking has shown that that is because of the -af resample paramer. It turns out, however, that you can do away with resampling (according to the manpage it is default if needed) so taking just -af format=s16le will do the trick.

Regards, Jos.

@vankan wrote:

Great tutorial! With my version of mencoder (dev-SVN-r27637-4.3-openSUSE) the mencoder command will hang indefinitely and a little spelunking has shown that that is because of the -af resample paramer. It turns out, however, that you can do away with resampling (according to the manpage it is default if needed) so taking just -af format=s16le will do the trick.

 

Regards, Jos.

Thanks for your feedback. The resample filter is automatically enabled upon playback only! That means for example if you try to play 48000Hz audio on a 41000Hz sound card mplayer does the necessary conversion by default. On the other hand it you encode audio to a new file - using mencoder in this case - it does apply any conversion upon request only. You see the difference?

In our case where we try to convert video/audio for the fuze it is required to create audio at 44100Hz. At least that is the only accepted value for sample rate which I know of. If the audio stream of your source video is already at 44100Hz then you are fine and could savely skip the resample filter. If the source audio is at 48000Hz then you must apply the ‘-af resample=44100:0:1,format=s16le’ filter.

I’d like you to check your source videos. If you find one having audio sample rate at 48000Hz and therefore needs to be resampled you have two possibilities: The first one is coded in my current pvc.sh shell script and works with my versions of mencoder (Debian Lenny: dev-SVN-r26940, Ubuntu Jaunty:?). The second choice is to replace mencoders resample filter with the lavcresample filter ‘-af lavcresample=44100,format=s16le’. Wonder if that works better for you?

Please let me know.

Yes, I see the difference. Yet the following happened

(mencoder  version dev-SVN-r27637-4.3-openSUSE , openSUSE 11.0)

  vankan@pavilion102:~/video/danielle> file al_desio.avi
al_desio.avi: RIFF (little-endian) data, AVI, 720 x 576, 25.00 fps, video: FFMpeg MPEG-4, audio: Dolby AC3 (stereo, 48000 Hz)

  vankan@pavilion102:~/video/danielle> srcvideo=al_desio.avi
  vankan@pavilion102:~/video/danielle> outfile=al_desio_fuze2.avi
  vankan@pavilion102:~/video/danielle> mencoder -ffourcc DX50 -ofps 20 -vf \ pp=li,expand=:::::224/176,scale=224:176,harddup -ovc lavc -lavcopts \ vcodec=mpeg4:vbitrate=650:vmax_b_frames=0:keyint=15:turbo:vpass=1 -srate 44100 -af </font> format=s16le -oac mp3lame -lameopts cbr:br=128 $srcvideo -o $outfile 

(snip mega output mencoder)

  vankan@pavilion102:~/video/danielle> file al_desio_fuze2.avi
al_desio_fuze2.avi: RIFF (little-endian) data, AVI, 224 x 176, 20.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 44100 Hz)

Curious isn’t it? You’d say it takes the resample frequency from -srate.  BTW taking -af lavcresample=44100,format=s16le also works fine and gives a file of exactly the same size…

Regards,  Jos.