View Single Post
Old 09.12.2019, 15:42
Tom Tom is offline
Giga Loader
Join Date: Jun 2018
Posts: 94
Default High CPU usage while using ffmpeg in eventscripter.

script my mgpai uses ffmpeg 90% cpu usage and converting takes hours

running ffmpeg with same commands in windows cmd, cpu usage is 30% and converting takes some minutes

cpu usage is normal when converting same file using same parameters in 'cmd' window.

// Convert dts to ac3 and create new video file
// Trigger Required: A new file has been created
// Forum Topic:

var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
var ffprobe = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypathprobe");

files.forEach(function(file) {
    if (["mkv", "mp4"].indexOf(getPath(file).getExtension()) == -1) return;
    var meta = callSync(ffprobe, "-i", file);
    var ac3 = meta.indexOf("Stream #0:1(ger): Audio: ac3") > -1;
    var dts = meta.indexOf("Stream #0:1(ger): Audio: dts") > -1;

    if (ac3 || dts) {
        var ext = getPath(file).getExtension();
        var ac3Command = ["cmd", "/k", ffmpeg, "-i", file, "-map", "0:0", "-map", "0:m:language:ger", "-c:s", "copy", "-c:a", "copy", file.replace(ext, "_ac3." + ext)];
        var dtsCommand = ["cmd", "/k", ffmpeg, "-i", file, "-map", "0:0", "-map", "0:m:language:ger", "-c:s", "copy", "-c:a", "ac3", "-b:a", "640k", file.replace(ext, "_ac3." + ext)];

        callAsync(function(error) {
            if (!error) getPath(file).delete();
        }, ac3 ? ac3Command : dtsCommand);

Last edited by raztoki; 10.12.2019 at 03:23.
Reply With Quote