wsegatto

Tdarr Closed Captions Will

Nov 13th, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable */
  2. function details() {
  3.   return {
  4.     id: "Tdarr_Plugin_WS_Remove_Closed_Captions",
  5.     Stage: "Pre-processing",
  6.     Name: "Remove burned closed captions",
  7.     Type: "Video",
  8.     Operation: "Remux",
  9.     Description:
  10.       "[Contains built-in filter] If detected, closed captions (XDS,608,708) will be removed. Derived from x7ac Closed Captions plugin.",
  11.     Version: "1.00",
  12.     Link:
  13.       "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/",
  14.     Tags: "pre-processing,ffmpeg,subtitle only",
  15.   };
  16. }
  17.  
  18. function plugin(file) {
  19.   //Must return this object
  20.  
  21.   var response = {
  22.     processFile: false,
  23.     preset: "",
  24.     container: ".mp4",
  25.     handBrakeMode: false,
  26.     FFmpegMode: false,
  27.     reQueueAfter: true,
  28.     infoLog: "",
  29.   };
  30.  
  31.   if (file.fileMedium !== "video") {
  32.     console.log("File is not video");
  33.  
  34.     response.infoLog += "☒File is not video \n";
  35.     response.processFile = false;
  36.  
  37.     return response;
  38.   }
  39.  
  40.   //Check if there Closed Captions are set at file level
  41.   if (file.hasClosedCaptions === true) {
  42.       response = {
  43.         processFile: true,
  44.         preset: ',-map 0 -codec copy -bsf:v "filter_units=remove_types=6"',
  45.         container: "." + file.container,
  46.         handBrakeMode: false,
  47.         FFmpegMode: true,
  48.         reQueueAfter: true,
  49.         infoLog: "☒This file has closed captions \n",
  50.       };
  51.  
  52.       return response;
  53.   }
  54.   // Now go through each stream in the file
  55.   for (var i = 0; i < file.ffProbeData.streams.length; i++) {
  56.     var stream = file.ffProbeData.streams[i]
  57.     //Check if there are burned Closed Captions
  58.     if (stream.closed_captions === 1) {
  59.       response = {
  60.       processFile: true,
  61.       preset: ',-map 0 -codec copy -bsf:v "filter_units=remove_types=6"',
  62.       container: "." + file.container,
  63.       handBrakeMode: false,
  64.       FFmpegMode: true,
  65.       reQueueAfter: true,
  66.       infoLog: "☒This file has burned closed captions \n",
  67.       };
  68.       return response;
  69.     }
  70.   }
  71.   //Nothing detected
  72.   response.infoLog += "☑Closed captions have not been detected on this file \n";
  73.   response.processFile = false;
  74.   return response;
  75. }
  76.  
  77. module.exports.details = details;
  78. module.exports.plugin = plugin;
  79.  
Add Comment
Please, Sign In to add comment