Photoshop Script Returning Error 8800 when exporting video

111 Views Asked by At

I am having an issue with exporting video on photoshop as .mp4 and its throwing this error after trying to save.

enter image description here

I don't see an Issue anywhere on my code as to why it would be giving me this error. Here is my code the export and input folder paths are the same. it seems to grab the png files from the input folder fine.

var inputF = Folder('D:/START/');
var sav = Folder('D:/START/');
var alpha = 'F';

if (app.documents.length) {
var doc = activeDocument;
doc.activeLayer = doc.layers.getByName("Design");
var al = doc.activeLayer;
if (al.kind == LayerKind.SMARTOBJECT) {
    if (inputF.exists) {
        var img = inputF.getFiles(/\.(png|jpg)$/i);
        if (img.length > 0) {
            if (sav.exists) {
                for (i = 0; i < img.length; i++) {
                    var imgF = img[i];
                    var imgNm = imgF.displayName.split('.').slice(0, -1).join('.');
                    if (imgNm[imgNm.length - 1] == 'C') {
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        var layers = activeDocument.layers;
                        if (layers) {
                            activeDocument.activeLayer = layers[0];
                            replaceeWithImage(imgF);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            savVideo(sav, imgNm + '-' + alpha + '.mp4');

                        } else {
                            activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                            alert("No Smart Object Layer Found Inside The Smart Object Layer");
                            break;
                        }
                    }
                }
                alert("Images processed successfully!");
                $.sleep(4000);
                doc.close(SaveOptions.DONOTSAVECHANGES);
            }
        }
    }
} else {
    alert("Select The Smart Object Layer Befor Running the script", "Smart Object Layer")
}
} else {
alert("Open a Template First", "Template")
}

function savVideo(outPath, fileName) {
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putPath(stringIDToTypeID("directory"), new File(outPath));
desc2.putString(charIDToTypeID('Nm  '), fileName);
desc2.putString(stringIDToTypeID("ameFormatName"), "H.264");
desc2.putString(stringIDToTypeID("amePresetName"), "2_Medium Quality.epr");
desc2.putBoolean(stringIDToTypeID("useDocumentSize"), true);
desc2.putBoolean(stringIDToTypeID("useDocumentFrameRate"), true);
desc2.putEnumerated(stringIDToTypeID("pixelAspectRatio"), stringIDToTypeID("pixelAspectRatio"), charIDToTypeID('Dcmn'));
desc2.putEnumerated(stringIDToTypeID("fieldOrder"), stringIDToTypeID("videoField"), stringIDToTypeID("preset"));
desc2.putBoolean(stringIDToTypeID("manage"), true);
desc2.putBoolean(stringIDToTypeID("allFrames"), true);
desc2.putEnumerated(stringIDToTypeID("renderAlpha"), stringIDToTypeID("alphaRendering"), charIDToTypeID('None'));
desc2.putInteger(charIDToTypeID('Qlty'), 1);
desc2.putInteger(stringIDToTypeID("Z3DPrefHighQualityErrorThreshold"), 5);
desc1.putObject(charIDToTypeID('Usng'), stringIDToTypeID("videoExport"), desc2);
executeAction(charIDToTypeID('Expr'), desc1, DialogModes.NO);
};

function replaceeWithImage(filePath) {
try {
    var desc1 = new ActionDescriptor();
    desc1.putPath(charIDToTypeID('null'), new File(filePath));
    executeAction(stringIDToTypeID('placedLayerReplaceContents'), desc1, DialogModes.NO);
    return true;
} catch (e) {
    return false;
}
};

PSD FILE I AM USING: removed

EDIT HERE IS THE WORKING CODE:

var inputF = Folder('D:/START/');
var sav =  Folder('D:/START/');
var alpha = '-B';
if (app.documents.length) {
var doc = activeDocument;
doc.activeLayer = doc.layers.getByName("Design");
var docH=doc.height.as('px');
if(docH>2304)doc.resizeImage (null, UnitValue(docH,'px'), doc.resolution, ResampleMethod.AUTOMATIC);
var al = doc.activeLayer;
if (al.kind == LayerKind.SMARTOBJECT) {
    if (inputF.exists) {
        var img = inputF.getFiles(/\.(png|jpg)$/i);
        if (img.length > 0) {
            if (sav.exists) {
                for (i = 0; i < img.length; i++) {
                    var imgF = img[i];
                    var imgNm = imgF.displayName.split('.').slice(0, -1).join('.');
                    if (imgNm[imgNm.length - 1] == 'X') {
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        var layers = activeDocument.layers;
                        if (layers) {
                            activeDocument.activeLayer = layers[0];
                            replaceeWithImage(imgF);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            saveAllFrame(sav, imgNm.replace ('-X', alpha) + '.mp4');
                        } else {
                            activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                            alert("No Smart Object Layer Found Inside The Smart Object Layer");
                            break;
                        }
                    }
                }
                alert("Images processed successfully!");
                $.sleep(4000);
                doc.close(SaveOptions.DONOTSAVECHANGES);
            }
        }
    }
} else {
    alert("Select The Smart Object Layer Befor Running the script", "Smart Object Layer")
}
} else {
alert("Open a Template First", "Template")
}

function saveAllFrame(pth, nm) {
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putPath(stringIDToTypeID("directory"), new File(pth));
desc2.putString(charIDToTypeID('Nm  '), nm);
desc2.putString(stringIDToTypeID("ameFormatName"), "H.264");
desc2.putString(stringIDToTypeID("amePresetName"), "1_High Quality.epr");
desc2.putInteger(charIDToTypeID('Wdth'), 3500);
desc2.putInteger(charIDToTypeID('Hght'), 2304);
desc2.putBoolean(stringIDToTypeID("useDocumentFrameRate"), true);
desc2.putEnumerated(stringIDToTypeID("pixelAspectRatio"), stringIDToTypeID("pixelAspectRatio"), charIDToTypeID('Dcmn'));
desc2.putEnumerated(stringIDToTypeID("fieldOrder"), stringIDToTypeID("videoField"), stringIDToTypeID("preset"));
desc2.putBoolean(stringIDToTypeID("manage"), true);
desc2.putBoolean(stringIDToTypeID("allFrames"), true);
desc2.putEnumerated(stringIDToTypeID("renderAlpha"), stringIDToTypeID("alphaRendering"), charIDToTypeID('None'));
desc2.putInteger(charIDToTypeID('Qlty'), 1);
desc1.putObject(charIDToTypeID('Usng'), stringIDToTypeID("videoExport"), desc2);
executeAction(charIDToTypeID('Expr'), desc1, DialogModes.NO);
};

function replaceeWithImage(filePath) {
try {
    var desc1 = new ActionDescriptor();
    desc1.putPath(charIDToTypeID('null'), new File(filePath));
    executeAction(stringIDToTypeID('placedLayerReplaceContents'), desc1, DialogModes.NO);
    return true;
} catch (e) {
    return false;
}
};
1

There are 1 best solutions below

13
Ghoul Fool On

Best guess - You're closing the jpg/png twice - which will close the source image

Also executeAction(stringIDToTypeID('placedLayerEditContents' down twice. I had to replace with app.runMenuItem(stringIDToTypeID('placedLayerEditContents')); as that wasn't working for me.

if (imgNm[imgNm.length - 1] == 'C')
{
    app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
    //executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
    //executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO); //Why twice??
    var layers = activeDocument.layers;
    if (layers)
    {
        activeDocument.activeLayer = layers[0];
        replaceeWithImage(imgF);
        activeDocument.close(SaveOptions.SAVECHANGES);
        // activeDocument.close(SaveOptions.SAVECHANGES); // Why twice??
        savVideo(sav, imgNm + '-' + alpha + '.mp4');

    }
    else
    {
      activeDocument.close(SaveOptions.DONOTSAVECHANGES);
      alert("No Smart Object Layer Found Inside The Smart Object Layer");
      break;
    }
}