导出视频时 Photoshop 脚本返回错误 8800

问题描述 投票:0回答:1

我在 Photoshop 上将视频导出为 .mp4 时遇到问题,并在尝试保存后抛出此错误。

我在我的代码中没有看到任何问题来解释为什么它会给我这个错误。这是我的代码,导出和输入文件夹路径是相同的。它似乎可以很好地从输入文件夹中获取 png 文件。

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;
}
};
javascript typescript photoshop psd
1个回答
0
投票

最佳猜测 - 您将关闭 jpg/png 两次 - 这将关闭源图像

还有

executeAction(stringIDToTypeID('placedLayerEditContents'
下降两次。我不得不用
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
替换,因为这对我不起作用。

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;
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.