Fuze+ Avidemux Video Conversion Script

I wanted to share a script i made to convert videos so they will play on my Fuze+

You would need Avidemux installed to use the script.

Here is a brief explanation what Avidemux is…

This program rocks ! been using it for a couple years now and dont need anything else.

Its simple to use but advanced if you want it to be.

And its truely free as in no pop ups to ask you if you wanna buy it to get additional profiles /etc

(like some other program mentioned in here)

ok so i created the script to convert to MP4 320x240 / AAC 192

but you can set the audio bitrate to whatever you want, i tested it as high 384 and it worked fine on the Fuze+

I also set the video bitrate to 1 pass @ 1,000 kbit/s but you can over-ride the scipt settings afterward

and increase the video bitrate up to 2,000 kbit/s (tested ok) and make it a 2 pass encode for better quality, in other words,

Average Bitrate (2 pass) or Constant Bitrate (single pass) the script setting default.

There is a lot more options beyond that aswell…

This will auto resize and add black borders for you but it can be easily overridden. Avidemux comes with a lot of good filters.

Its as simple as loading your video and selecting the scipt in the gui and selecting “Save Video”

The trick to this was making the encoder settings good enough but still H.264 Baseline Level 2.0 compliant

Level 2.0 means no higher than 352×288 @ 30fps and VBV maximum bit rate = 2000 & VBV buffer size = 2000

So… don’t set your video dimensions higher than that or the video bitrate higher than 2000.

anyway here is the script, save it to a file with the .js extention and put it into the scripts/auto folder in the Avidemux Install folder, without the [script] and [/script] lines.

[script]

//AD  <- Needed to identify//

// Sansa Fuze+ MP4 H.264 Baseline Level 2.0 Video Conversion Script by xpmule 01/02/2011
// Script is designed for Avidemux - http://avidemux.org
// Created for the Fuze+ community - http://forums.sandisk.com/t5/Fuze/bd-p/Fuzeplus

include(“video/autoWizard.js”);
include(“video/filter.js”);

var app = new Avidemux();

if (app.video == null)
    displayError(“Please open a video first”);
else
{
    var result = videoAutoWizard(“Dimensions”, [[320, 240], [352, 288]]);

    if (result)
    {
        var targetX = result[0][0];
        var targetY = result[0][1];
        var sourceRatio = result[1][0] + “:” + result[1][1];
        var destinationRatio = result[2][0] + “:” + result[2][1];

        resizeAndFillVideo(targetX, targetY, sourceRatio, destinationRatio);

//** Video Codec conf **
app.video.codecPlugin(“32BCB447-21C9-4210-AE9A-4FCE6C8588AE”, “x264”, “CBR=1000”, “<?xml version=‘1.0’?><x264Config><presetConfiguration><name>x264_Fuze</name><type>user</type></presetConfiguration><x264Options><fastFirstPass>true</fastFirstPass><threads>0</threads><deterministic>true</deterministic><sliceThreading>false</sliceThreading><threadedLookahead>-1</threadedLookahead><idcLevel>20</idcLevel><vui><sarAsInput>false</sarAsInput><sarHeight>1</sarHeight><sarWidth>1</sarWidth><overscan>undefined</overscan><videoFormat>undefined</videoFormat><fullRangeSamples>false</fullRangeSamples><colorPrimaries>undefined</colorPrimaries><transfer>undefined</transfer><colorMatrix>undefined</colorMatrix><chromaSampleLocation>0</chromaSampleLocation></vui><referenceFrames>1</referenceFrames><gopMaximumSize>250</gopMaximumSize><gopMinimumSize>0</gopMinimumSize><scenecutThreshold>40</scenecutThreshold><periodicIntraRefresh>false</periodicIntraRefresh><bFrames>0</bFrames><adaptiveBframeDecision>1</adaptiveBframeDecision><bFrameBias>0</bFrameBias><bFrameReferences>normal</bFrameReferences><loopFilter>true</loopFilter><loopFilterAlphaC0>0</loopFilterAlphaC0><loopFilterBeta>0</loopFilterBeta><cabac>false</cabac><openGop>disabled</openGop><interlaced>disabled</interlaced><constrainedIntraPrediction>false</constrainedIntraPrediction><cqmPreset>flat</cqmPreset><intra4x4Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intra4x4Luma><intraChroma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intraChroma><inter4x4Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></inter4x4Luma><interChroma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></interChroma><intra8x8Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intra8x8Luma><inter8x8Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></inter8x8Luma><analyse><partitionI4x4>true</partitionI4x4><partitionI8x8>false</partitionI8x8><partitionP8x8>true</partitionP8x8><partitionP4x4>true</partitionP4x4><partitionB8x8>false</partitionB8x8><dct8x8>false</dct8x8><weightedPredictionPframes>none</weightedPredictionPframes><weightedPrediction>true</weightedPrediction><directPredictionMode>spatial</directPredictionMode><chromaLumaQuantiserDifference>0</chromaLumaQuantiserDifference><motionEstimationMethod>hexagonal</motionEstimationMethod><motionVectorSearchRange>12</motionVectorSearchRange><motionVectorLength>-1</motionVectorLength><motionVectorThreadBuffer>-1</motionVectorThreadBuffer><subpixelRefinement>7</subpixelRefinement><chromaMotionEstimation>true</chromaMotionEstimation><mixedReferences>true</mixedReferences><trellis>disabled</trellis><fastPSkip>true</fastPSkip><dctDecimate>true</dctDecimate><psychoRdo>1</psychoRdo><noiseReduction>0</noiseReduction><interLumaDeadzone>21</interLumaDeadzone><intraLumaDeadzone>11</intraLumaDeadzone></analyse><rateControl><quantiserMinimum>16</quantiserMinimum><quantiserMaximum>51</quantiserMaximum><quantiserStep>4</quantiserStep><maximumConstantRateFactor>0</maximumConstantRateFactor><averageBitrateTolerance>1</averageBitrateTolerance><vbvMaximumBitrate>2000</vbvMaximumBitrate><vbvBufferSize>2000</vbvBufferSize><vbvInitialOccupancy>0.9</vbvInitialOccupancy><ipFrameQuantiser>1.4</ipFrameQuantiser><pbFrameQuantiser>1.3</pbFrameQuantiser><adaptiveQuantiserMode>variance</adaptiveQuantiserMode><adaptiveQuantiserStrength>1</adaptiveQuantiserStrength><mbTree>true</mbTree><frametypeLookahead>40</frametypeLookahead><quantiserCurveCompression>0.6</quantiserCurveCompression><reduceFluxBeforeCurveCompression>20</reduceFluxBeforeCurveCompression><reduceFluxAfterCurveCompression>0.5</reduceFluxAfterCurveCompression></rateControl><accessUnitDelimiters>false</accessUnitDelimiters><spsIdentifier>0</spsIdentifier><sliceMaxSize>0</sliceMaxSize><sliceMaxMacroblocks>0</sliceMaxMacroblocks><sliceCount>0</sliceCount><hrd>none</hrd></x264Options></x264Config>”);

        if (app.audio.targetTrackInfo.length > 0)
        {
            if (app.audio.targetTrackInfo[0].codec != “AAC” || app.audio.targetTrackInfo[0].channelCount != 2)
            {
                app.audio.codec(“Faac”, 192, 4, "c0 00 00 00 ");

                if (app.audio.targetTrackInfo[0].channelCount == 2)
                    app.audio.mixer = “NONE”;
                else
                    app.audio.mixer = “STEREO”;
            }
        }

        app.setContainer(“MP4”);
    }
}

[/script]

If anyone is interested, I have created a “profile” for the Fuze+ to be used with XMedia-Recode. I have tested it, and it works fine. It also has the several good options to use, such as automatically adding black borders (if necessary), auto resizing to 320x240 (or, you can set it to 224x174, which the old Fuze uses), a choice between codecs (X.264, XviD, Mpeg-4), and lots of manual options for advanced users, such as denoising, switching resize methods (bicubic, bilinear, ect.), X.264 noise reduction, two-pass encoding, ect.

Please note that there is a small bug in the program (at least with 2.2.9.7, possibly other versions), with the X.264 encoder. It will say it is encoding with the “Baseline” profile, but the output file will use the “Main” profile, which will be unplayable on the Fuze+. A good workaround, which I have discovered is to manually  the profile to “Main”, and then change it back to “Baseline”. IKD why this works, but it does. Or, you can just select another codec.

Anyway to use this profile, just go into the XMedia-Recode installation directory, find the folder called “Profile”, and create a new text document (I recommend calling it “Sandisk_Sansa_Fuze+_(mp4)”), and rename it as an *.ini file. The open it and copy/paste the following:

[Main]
Name=SanDisk Sansa Fuze+ (mp4)
Manufacturer=SanDisk
Format=mp4
ExtName=mp4

ZoomDefault=fittoscreen

V1Codec=libx264
V1GOPSize=250
V1MinGOPSize=15
V1Bitrate=1000
V1Profile=0
V1Level=20
V1NbBFrames=0
V1BframeMode=0
V1AdaptiveBFrames=0
V1BRDO=0
V1WeightedBPrediction=0
V1BiDirectionalME=0
V1BFramePyramid=0
V1BframeBias=0
V1AdaptiveDCT=0
V1I8x8=0
V1I4x4=1
V1P8x8=1
V1P4x4=1
V1B8x8=1
V1MaxBitrate=768
V1VBVBuffer=768
V1VBVInitialBuffer=0.9
V1BitrateVariance=1.0
V1QuantCompression=0.6
V1MERange=12
V1SCDSensitivity=40
V1MEAlgorithm=2
V1SubPelRefinement=10
V1ChromaME=1
V1MaxQuant=51
V1MinQuant=10
V1MaxQuantDelta=4
V1IPFactor=1.4
V1PBFactor=1.3
V1DeadZoneInter=21
V1DeadZoneIntra=11
V1AQmode=1
V1AQstrength=1.0
V1Trellis=0
V1NbRefFrames=1
V1MixedRefs=0
V1Cabac=0
V1NoDCTDecimate=0
V1NoFastPSkip=0
V1TrellisStrenght=0.0
V1RDStrenght=1.0
V1Deblock=0
V1AlphaDeblock=0
V1BetaDeblock=0
V1Lookahead=40
V1MBTree=1
V1NoPsy=0
V1SlicesNb=0
V1MaxSliceSizeBytes=0
V1MaxSliceSizeMBs=0
V1WeightedPFrame=0

v2Codec=libxvid
v2Bitrate=536
v2VBVBuffer=2500000
v2MaxBitrate=2500
v2Level=15
v2GOPSize=15
v2NbBFrames=0
v2Cartoon=0
v2ClosedGOP=1
v2PackedBitstream=0
v2VHQBframes=0
v2VHQMode=4
v2MotionSearchPrecision=6
v2QPel=0
v2GMC=0
v2ChromaME=1
v2MinIQuant=2
v2MaxIQuant=31
v2MinPQuant=2
v2MaxPQuant=31
v2MinBQuant=2
v2MaxBQuant=31
v2BQuantRatio=150
v2BQuantOffset=100
v2QuantType=0
v2AdaptiveQuant=0
v2Trellis=1
v2KeyFrameBoost=100
v2KeyframeThreshold=1
v2KeyframeReduction=20
v2OverflowControlStrength=5
v2MaxOverflowImprovement=5
v2MaxOverflowDegradation=5
v2HighBitrateDegradation=0
v2LowBitrateImprovement=0
v2ReactionDelayFactor=16
v2AveragingPeriod=100
v2RateControlBuffer=100

V3Codec=mpeg4
V3Bitrate=536

A1Codec=libfaac
A1ObjectType=lc
A1MpegVersion=mpeg-4
A1Channels1=stereo
A1SampleRateDefault=44100
A1BitrateDefault=128000

ResDefault=320x240
Res1=320x240
Res2=224x176

Aspect1=4:3

never heard of that program but im curious and maybe have to track it down and try it out some time.

and good post thanks for sharing

@xpmule wrote:

never heard of that program but im curious and maybe have to track it down and try it out some time.

Which Program? AviDemux? or XMedia-Recode?