2008-08-02

Video on SanDisk Sansa Fuze

I recently wrote a post about my SanDisk Sansa Fuze mp3 player, especially on getting it to work on Linux. This post is about a specific issue with it, namely video. (Executive summary: it doesn't work.)

The Problem

Getting video working on the Sansa is ridiculously difficult if you are not able to use their archaic Sansa Media Converter Windows software, regardless of your own OS. The Sansa Fuze is in theory a pretty nice media player, which (again in theory) can play mpeg videos in an avi container. In practise, the Sansa expects this video to be in a absurdly specific format. For everything else it displays an error message. To get video into the correct format you must use the converter they have provided.

Sansa Media Converter

Sansa Media Converter is a horrible little video converting program, a true nightmare to use, and the only supported way of getting video to play on the player. It seems to be a rebranded Intervision product, which converts some common video formats to the format used by the Sansa Fuze. It is naturally Windows only and even on Windows it requires the player to be plugged in for conversion to be possible. It doesn't even load on Wine. On a virtual Windows machine it starts but refuses to convert as it can't see the player even if it's plugged in. Also on my old Windows machine it refuses to see the player. Sansa Media Converter represents everything that is wrong in today's computing, and does that faithfully. The pox on the people who wrote it.

Working Example

On the Sansa there is a preloaded video file, which can be used to investigate the format accepted by the player. Also, I have converted some other examples with the Sansa converter on a machine it actually accepted. I have loaded the files into a Windows program abcAvi Tag Editor (works under Wine), which displays a lot of information on avi files. Here's what it has to say about the preloaded example:

[RIFF AVI 20988512]: Audio/Video Interleaved File
[LIST hdrl 64638]: Format Definition Chunk
[avih 56]: Main AVI Header
[dwMicroSecPerFrame]: Microseconds Per Frame: 50000
[dwMaxBytesPerSec]: Maximum Bytes Per Second: 101885
[dwPaddingGranularity]: Padding Granularity (bytes): 1
[dwFlags]: Flags 0x00000810
[AVIF_HASINDEX]: AVI file has 'idx1' chunk
[AVIF_TRUSTCKTYPE]: use chunk type to find key frames
[dwTotalFrames]: Number Of Frames: 4137
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwStreams]: Number Of Streams: 2
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15237
[dwWidth]: Image Width (pixels): 224
[dwHeight]: Image Height (pixels): 176
[LIST strl 32148]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: vids (Video Data)
[fccHandler]: Handler: 0x00000000 (No Compression <0x00000000>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 500000
[dwRate]: Stream Rate: 10000000
[dwStart]: Stream Start: 0
[dwLength]: Stream Duration: 4137
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15237
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 0
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 40]: Video Stream Format
[biSize]: Header Size (bytes): 40
[biWidth]: Image Width (pixels): 224
[biHeight]: Image Height (pixels): 176
[biPlanes]: Number Of Planes: 1
[biBitCount]: Number Of Bits Per Pixel: 32
[biCompression]: Compression Algorithm: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[biSizeImage]: Image Size (bytes, 0 = uncompressed): 230400
[biXPelsPerMeter]: Horizontal resolution of target device: 0
[biYPelsPerMeter]: Vertical resolution of target device: 0
[biClrUsed]: Number of colors used (0 = maximum): 0
[biClrImportant]: Number of important colors (0 = all): 0
[indx 32024]: AVI2 (OpenDML) Super Index Chunk
[LIST strl 32138]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: auds (Audio Data)
[fccHandler]: Handler: 0x00000000 (No Compression <0x00000000>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 16000
[dwStart]: Stream Start: 417
[dwLength]: Stream Duration: 3309595
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 2008
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 1
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 30]: Audio Stream Format
[wFormatTag]: Audio Format: 0x0055 (MPEG-1 Layer 3 (MP3) <0x0055>)
[nChannels]: Number of channels: 2
[nSamplesPerSec]: Frequency of the sample rate (Hz): 44100
[nAvgBytesPerSec]: Average data rate (byte/s): 16000
[nBlockAlign]: Block alignment of the data (bytes): 1
[wBitsPerSample]: Number of bits per sample (0 = undefined): 0
[cbSize]: Size of extra information (bytes): 12
[wID]: Type: 0x0002 (Constant frame size)
[fwFlags]: Flags: 0x0000 (ISO Padding)
[nBlockSize]: Block size (bytes): 417
[nFramesPerBlock]: Number of frames per block: 1
[nCodecDelay]: Codec delay (ms): 0
[indx 32024]: AVI2 (OpenDML) Super Index Chunk
[LIST odml 260]: AVI2 (OpenDML) Format Definition Chunk
[dmlh 248]: Total Number Of Frames AVI2 (OpenDML) 4137
[JUNK 34]: Padding
[LIST movi 20824326]: Audio/Video Data
Skipped
[idx1 99312]: AVI Index Chunk
[LIST INFO 92]: RIFF Textual Informative Details
[ILNG 10]: Language: Undefined
[IRTD 8]: Rating: Unrated
[INAM 12]: Title: sansatesti
[IPRD 6]: Product: Movie
[ISFT 12]: Software Used: IntraAudio
[LIST MID 58]: Movie IDentifier Tags
[TITL 12]: Title: sansatesti
[AGES 8]: Rating: Unrated
[LANG 10]: Language: Undefined
[IDVX 128]: Unknown Tag
[LIST DIVXTAG 128]: IDivX tags
[Movie 32]: Title: sansatest
[Author 28]: Director:
[Year 4]: Creation Date Of Subject:
[Comment 48]: Comments:
[Genre 00000003]: IDivX Genre: 017 (Movie)
[Rated 00000001]: IDivX Rating: 0 (Unrated)


My attempts

I attempted to reproduce a working file with mencoder. I used the following command on the example file. The command does not produce a file acceptable to Sansa.
mencoder -ofps 20 -vf scale=224:176 -ni -noidx -nocache -ovc copy -oac copy -ffourcc DX50 -of avi infile.avi -o outfile.avi

The command does nothing to the audio and video streams, it just copies them to a new file. Only thing that changes is the container part of the file. I manually set the resolution, frame rate and FourCC code for this file. (The noidx option is actually not actually needed, as the example file has an index. That's just something I forgot there.) This resulted in a file described below

[RIFF AVI 20719086]: Audio/Video Interleaved File
[LIST hdrl 306]: Format Definition Chunk
[avih 56]: Main AVI Header
[dwMicroSecPerFrame]: Microseconds Per Frame: 50000
[dwMaxBytesPerSec]: Maximum Bytes Per Second: 0
[dwPaddingGranularity]: Padding Granularity (bytes): 0
[dwFlags]: Flags 0x00000900
[AVIF_ISINTERLEAVED]: AVI file is interleaved
[AVIF_TRUSTCKTYPE]: use chunk type to find key frames
[dwTotalFrames]: Number Of Frames: 0
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwStreams]: Number Of Streams: 2
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 0
[dwWidth]: Image Width (pixels): 224
[dwHeight]: Image Height (pixels): 176
[LIST strl 116]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: vids (Video Data)
[fccHandler]: Handler: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 20
[dwStart]: Stream Start: 0
[dwLength]: Stream Duration: 4137
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15229
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 0
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 224
[wY2]: Right: 176
[strf 40]: Video Stream Format
[biSize]: Header Size (bytes): 40
[biWidth]: Image Width (pixels): 224
[biHeight]: Image Height (pixels): 176
[biPlanes]: Number Of Planes: 1
[biBitCount]: Number Of Bits Per Pixel: 32
[biCompression]: Compression Algorithm: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[biSizeImage]: Image Size (bytes, 0 = uncompressed): 230400
[biXPelsPerMeter]: Horizontal resolution of target device: 0
[biYPelsPerMeter]: Vertical resolution of target device: 0
[biClrUsed]: Number of colors used (0 = maximum): 0
[biClrImportant]: Number of important colors (0 = all): 0
[LIST strl 106]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: auds (Audio Data)
[fccHandler]: Handler: U (Unknown Four Character Code 'U' <0x00000055>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 16000
[dwStart]: Stream Start: 417
[dwLength]: Stream Duration: 3309595
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 8000
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 1
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 30]: Audio Stream Format
[wFormatTag]: Audio Format: 0x0055 (MPEG-1 Layer 3 (MP3) <0x0055>)
[nChannels]: Number of channels: 2
[nSamplesPerSec]: Frequency of the sample rate (Hz): 44100
[nAvgBytesPerSec]: Average data rate (byte/s): 16000
[nBlockAlign]: Block alignment of the data (bytes): 1
[wBitsPerSample]: Number of bits per sample (0 = undefined): 0
[cbSize]: Size of extra information (bytes): 12
[wID]: Type: 0x0002 (Constant frame size)
[fwFlags]: Flags: 0x0000 (ISO Padding)
[nBlockSize]: Block size (bytes): 417
[nFramesPerBlock]: Number of frames per block: 1
[nCodecDelay]: Codec delay (ms): 0
[LIST INFO 42]: RIFF Textual Informative Details
[ISFT 30]: Software Used: MEncoder 2:1.0~rc2-0ubuntu13
[JUNK 3712]: Padding
[LIST movi 20714990]: Audio/Video Data
Skipped


There are some notable differences to the working example file. I suspect the most important one is "AVIF_ISINTERLEAVED" flag, which means that this avi file has interleaved video and audio. It is possible that this may be too much for the Sansa Fuze to handle.

Mencoder/Mplayer has, by the way, an option called -ni, which forces non-interleaved mode for reading files. Unfortunately it doesn's seem to affect decoding.

It is worth mentioning that the Sansa isn't picky about every little detail. I changed the FourCC code, for instance, on the preloaded clip to some false value and the clip still played.

VirtualDub

There is this Windows program called VirtualDub, which has an option for turning of interleaving avi files. I tried it under Wine. The program worked, but unfortunately, the file it produced had other differences to the examples. I haven't found options to fix those differences in the program

Possible Solutions

I'm no expert when it comes to video encoding, so currently I have no ideas how to move forward. I guess there might be some program somewhere that can reproduce Sansa's format, or perhaps it could be possible to make a non-interleaved version of avi codecs and try those.

For reference you might want to see further information on the video clip and this discussion.

Any help with this would be appreciated.

28 comments:

bla said...

I am trying to do the same thing as you with the Super video converter. I am also not having any luck. I'm trying to get some help on the anythingbutipod forums.

olli said...

Have you had any success in getting the suspend to work? As just about everything works quite perfectly now in Ubuntu 8.04, including webcam and memory card reader, it really annoys me having to shut down the computer for power saving. Decent power management is such a crucial thing on a laptop.

spicifer said...

Hello Olli,

Unfortunately I've had no progress on this front. And frankly, I'm not holding my breath that it will work in 8.10 either...

geeklawyer said...

I'm glad it wasn't just me who couldnt get it working! Tried everything like you to no avail. Keep us up to speed if you have success.

Richard Ayotte said...

Here's my latest attempt that still does not work! I'm being as explicit as I can with the information provided. What's missing?

mencoder -ffourcc DX50 -af resample=44100 -ofps 20 -vf palette,scale=224:-3 -oac lavc -lavcopts acodec=libmp3lame:abitrate=128 -ovc lavc -lavcopts vbitrate=512:vcodec=mpeg4 movie.avi -o sansa.avi

I'm not impressed. If I can't get this to work, I will seriously reconsider buying a Sansa again.

spicifer said...

Hi Richard,

Are you trying to re-encode an already working video example with mencoder or convert some other video clip to Sansa's format? I've been trying to do the former, mostly, as I suspect it's the first step to getting the conversion working.

I tried your command on the example file provided by Sansa and then opened it in the abcAvi Tag Editor to see what had actually happened. The interesting part (I think) is the dwFlags structure:

[dwFlags]: Flags 0x00000910
[AVIF_HASINDEX]: AVI file has 'idx1' chunk
[AVIF_ISINTERLEAVED]: AVI file is interleaved
[AVIF_TRUSTCKTYPE]: use chunk type to find key frames

It seems to me that there is an extra attribute set here. The working example file is not interleaved, ie. the AVIF_ISINTERLEAVED attribute is not set. In your file this attribute is set. Unfortunately, I have had the exact same problem with my own attempts. AFAIK mencoder cannot encode non interleaved avi files. (Mplayer sure can play them, though.)

I suspect we need an encoder that can encode an avi container with dwFlags set to 0x810.

Anonymous said...

anyone try this?

http://www.any-video-converter.com/convert-videos-for-sansa-fuze.php

just about to download, will update afterwards.

HDK

carbonunit said...

So you were going to try and then comment back? Heart attack?
I went to
http://www.any-video-converter.com/convert-videos-for-sansa-fuze.php

I followed the tutorial exactly and it doesn't work. I'm on windows vista. Nothing works except for the sansa media encoder. I wouldn't mind if they would allow some change in the settings.

felipenavas said...

SMC doesn't work.
Any Video Converter doesn't work.
I'm running windows Vista.
My codecs are from CCCP.

You could send you attempt?

khankhanister at gmail dot com

I will investigate it with a hexaeditor. Try do some kind of DIFF with the files to find the difference. I want to help.



Could somebody make a single frame full black video and me send the both SMC converted video and the original ?

Conor O'Brien said...

sorry, xmas got in the way...
yup,AVC does not work, with the instructions given on the site.

To solve this might need some dicking around with the settings within the Fuze itself...not sure its worth it!

Anonymous said...
This comment has been removed by a blog administrator.
Metalliham said...

I got one of these for my son for Christmas and I can get the Sansa Media Converter working on my Vista Ultimate 64-bit.

However, it will not convert certain files, (such as MP4), even though I have the proper codecs on my PC.

It will, however, pretty much convert any AVI, so I would suggest this: http://rapidshare.com/files/178317243/PocketDivXEncoder_0.3.96.exe.html

I used to to take an Xvid of one of my movies and convert it to an AVI which is easily convertable with the Sansa program.

I even dropped the quality to help manage the size better, and even adjusted the resolution to fit the Sansa Fuze, which is 220x176.

Hope this helps.

Metalliham said...

Sorry tried to post a direct link to the program from my own account.

You can find the program called PocketDivXEncoder.

glass.dimly said...

I've installed Media Converter in XP in a VirtualBox under Linux, but Media Converter won't allow you to convert a file unless your Fuze is connected, and I haven't gotten USB working yet with VirtualBox. It's sort of a pain, and I couldn't get USB working under Ubuntu Hardy.

So I'm still video-less, for the moment.

For those that want an open source video conversion utility that rocks, Handbrake is the best for all platforms. The latest version is really, really great.

Michael said...

I have a working xp guest in virtualbox with a working sansa media converter and have successfully converted and uploaded full featured films. But even the smc fails unless the video is the same frame rate and resolution. So I have used avidemux to produce a file as close as possible to the sansa fuze video specs. then used smc to do the final conversion and upload. But this is ridiculous, shouldn't have to got through all this.

Mike said...

The WinAVI Converter http://www.winavi.com/en/video-converter/video-converter.htm works. But I would love to get a OSS or free tool to do this task. Handbrake is very close to working but it appears that regardless of what settings I use, it wont record the video in 20fps. Handbrake can create a file that matches in all other attributes.

Anonymous said...

The Rhapsody client is reported to be fully compatible for video conversion for the FUZE (as an alternate to SMC)

Anonymous said...

I have been using FFMpegX on Mac OS X and Handbrake, both on OS X and Ubuntu 8.10. I tried numerous setting and attempts with both, but have yet to produce a file that will work on the Fuze. I would load the details here if I thought they would help. I will keep trying for a bit and if I can find the correct combination, I will report back.

However, I also have VMFusion running on the MAC and have have loaded SMC under XP and can get it to convert and place videos on the Fuse for playback. in both. There are several things that I noticed with the output of this process: of course it an AVI file, but when I go to play it with VLC, I get an error suggesting that the AVI is damaged and asks whether I would like to repair it.

Paul said...

Thanks for the help. I've been able to figure the process out on Win XP but a friend using Linux was having problems.

Pablo Lobo said...

Having the same issues, worked my butt off with Handbrake to no avail.

Following this thread.

noookaaa said...

You may try Nidesoft Sansa video converter. this converter can convert all videos into sansa format in high quality at fast speed. you may get it here: http://www.nidesoft.com/sansa-video-converter.html
and get step by step guide on my blog:
http://bestvideoconvertersoftware.blogspot.com/2009/02/sansa-guide-how-to-get-videos-and-songs.html

Chris said...

@noookaaa: Why would you pay for a third-party Windows-only converter when Sandisk makes a free Windows-only converter? This post is about getting video onto the Fuze in Linux.

Anonymous said...

Just so that you know there is now a tutorial at fuze forums how to convert the video in linux: http://forums.sandisk.com/sansa/board/message?board.id=sansafuse&message.id=31558&jump=true#M31558

blue.monkey said...

I know this blog is a bit old, but thought I would just mention this in case others stumble across it looking for a solution.
The opensource software Video4Fuze works perfectly.
http://code.google.com/p/video4fuze/
You just point it to any video file, give it an output directory, and it encodes it for you using mencoder.
You can look at the settings it uses for mencoder in case you wanted to do it manually from the command line. But the interface is simple and quick.

Richard Ayotte said...

@blue.monkey: Fantastic find! It works beautifully. Thank you for posting.

Anonymous said...

how to for Video4Fuze:
http://www.youtube.com/watch?v=m4-jt3B3Bag

SolidX said...

A quick glance at the source code suggests that the settings are:


mencoderpass1 = "mencoder -msglevel all=0:statusline=5 -ffourcc DX50 -ofps 20 -vf pp=li,expand=:::::224/176,scale=224:176,harddup -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=683:vmax_b_frames=0:keyint=15:turbo:vpass=1 -srate 44100 -af resample=44100:0:1,format=s16le -oac mp3lame -lameopts cbr:br=128"

mencoderpass2 = "mencoder -msglevel all=0:statusline=5 -ffourcc DX50 -ofps 20 -vf pp=li,expand=:::::224/176,scale=224:176,harddup -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=683:vmax_b_frames=0:keyint=15:vpass=2 -srate 44100 -af resample=44100:0:1,format=s16le -oac mp3lame -lameopts cbr:br=128"

mencodersinglepass = "mencoder -msglevel all=0:statusline=5 -ofps 20 -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:keyint=15 -vf field,expand=:::::224/176,scale=224:176,harddup -srate 44100 -af resample=44100:0:1,format=s16le -oac mp3lame -lameopts cbr:br=128"
pass2 = False

Anonymous said...

Thank you so much blue.monkey for your post. I almost gave up on the video function of my fuze. I was going to give it one last try and found your post. Absolutely awesome.