Thursday, 27 July 2023

Photoshop Script Returning Error 8800 when exporting video

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;
}
};


from Photoshop Script Returning Error 8800 when exporting video

No comments:

Post a Comment