header={ "recipe_version": "1.13", "title": "Trim Video Black Detect", "description": "detect if the video has black frames at the beginning and remove them", "tags": "video", "chef": "BeatRig", "spice": "BQ==:G+Hy36kJcnQQYYavb/JV2Il6eCYr6h4hRJHCF9rRbhX5BcazL6cuTgUMdz0xA50VWA5PmmV0Q7aWkiUtNFtbk991l+t0e8IBXMReMIT1GNjnZZDv7n2YRAo0xcSQbY0ixjG6LLH4wGKnspKAoA/v69iLn6N2IH0XzIZwTGdHSo4=", "palette": "Clean Slate", "flavour": "exWHg9kyjzN6iWg9D9qSAfZ5TMR+hXYQUZgYzHNxPnlrQG29hkF/ABj8JeezKTv4Fb22dl85XNQGL7O1kgRTnxiZE4liFhSRys6Tu84j2cOUxowyrOc0MUb2Pje74M0HZkgwTflTdZJUlJwcTN24NbrAeHIZOuF6jvGnM1ZOGX0=", "time": 1674549224, "core_version": "0.4.0", "magnetron_version": "1.0.138", "dependencies": "ffprobe,ffmpeg", "type": "default", "os": "windows,macOS", "functions": "main", "uuid": "afc871158af44535830b64de1bc88dac", "instructions": "Drop file(s) here" }; // ============================================================================= // GLOBALS var framecount = 0; // ============================================================================= function main() { // MESSAGE setMainMessage("preparing"); // CHECK VALID FILES validateInputFile(); // GET ALL FILES var files = getFiles(); // LOOP FILES for (i=0;i 0.) { setMainMessage("trimming file"); var ffmpeg = cmd("ffmpeg", [ '-i',infile, '-ss',blackEnd, '-vcodec','copy', '-acodec','copy', vidout, '-y', ]); } // --------------------------------------------------------------------- // THIS FILE IS DONE setProgress(100); setMainMessage("file done"); // SET STATUS files[i]['file_icon'] = "CheckSquare"; files[i]['file_icon_color'] = "FF00aa00"; files[i]['file_status'] = 'DONE'; setFiles(files); // --------------------------------------------------------------------- } // ALL IS DONE setMainMessage("all done"); } // ============================================================================= function validateInputFile() { var files = getFiles(); var valid = []; setProgress(101); for (i=0;i 0; valid.push({ index: i, path: files[i].path, idpath: files[i].idpath, file_icon: (isVideo ? 'square' : 'Exclamation'), file_icon_color: (isVideo ? 'FFdddddd' : 'FFff0000'), file_status: (isVideo ? '' : 'Not a valid video file'), file_tooltip: '', skip: (isVideo ? false : true), }); } // UPDATE FILES LIST setFiles(valid); setMainMessage("getting ready"); } // ============================================================================= // FFMPEG PROCESS STATUS function cmd_callback(cmd_name, cmd_output){ if(cmd_name=="ffmpeg" && cmd_output.length > 0 && framecount > 0){ var progress = searchRegEx(cmd_output, "(?:frame=)(.*?)(?:fps=)", "i", 1); progress = parseInt (progress[progress.length-1] ); progress = Math.round( progress/framecount* 100 ); setProgress(progress); setMainMessage("processing "+progress+"%"); } }