Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. function details() {
  2. return {
  3. id: "Custom",
  4. Name: "Tiered Custom",
  5. Type: "Video",
  6. Operation:"Transcode",
  7. Description: `[Contains built-in filter] This plugin uses different Handbrake transcoding settings for 480p,576p,720p and 1080p. If files are not in hevc they will be transcoded. The output container is mkv. \n\n`,
  8. Version: "1.01",
  9. Link: ""
  10. }
  11. }
  12.  
  13. function plugin(file) {
  14. var transcode = 0; //if this var changes to 1 the file will be transcoded
  15.  
  16. //default values that will be returned
  17. var response = {
  18. processFile: false,
  19. preset: '',
  20. container: '.mkv',
  21. handBrakeMode: false,
  22. FFmpegMode: true,
  23. reQueueAfter: true,
  24. infoLog: ''
  25. }
  26.  
  27. //check if the file is a video, if not the function will be stopped immediately
  28. if (file.fileMedium !== "video") {
  29. response.processFile = false
  30. response.infoLog += "☒File is not a video! \n"
  31. return response
  32. } else {
  33. response.infoLog += "☑File is a video! \n"
  34. }
  35.  
  36. //check if the file is already hevc, it will not be transcoded if true and the function will be stopped immediately
  37. if (file.ffProbeData.streams[0].codec_name == 'hevc') {
  38. response.processFile = false
  39. response.infoLog += "☒File is already in hevc! \n"
  40. return response
  41. }
  42.  
  43. //file will be encoded if the resolution is 480p or 576p
  44. //codec will be checked so it can be transcoded correctly
  45. if(file.video_resolution === "480p" || file.video_resolution === "576p" ) {
  46. if (file.video_codec_name == 'h263') {
  47. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  48. }
  49. else if (file.video_codec_name == 'h264') {
  50. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  51. }
  52. else if (file.video_codec_name == 'mjpeg') {
  53. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  54. }
  55. else if (file.video_codec_name == 'mpeg1') {
  56. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  57. }
  58. else if (file.video_codec_name == 'mpeg2') {
  59. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  60. }
  61. else if (file.video_codec_name == 'mpeg4') {
  62. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  63. }
  64. else if (file.video_codec_name == 'vc1') {
  65. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  66. }
  67. else if (file.video_codec_name == 'vp8') {
  68. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  69. }
  70. else if (file.video_codec_name == 'vp9') {
  71. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  72. }
  73. else {
  74. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 27'
  75. }
  76.  
  77. transcode = 1;
  78. }
  79.  
  80. //file will be encoded if the resolution is 720p
  81. //codec will be checked so it can be transcoded correctly
  82. if(file.video_resolution === "720p") {
  83. if (file.video_codec_name == 'h263') {
  84. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  85. }
  86. else if (file.video_codec_name == 'h264') {
  87. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  88. }
  89. else if (file.video_codec_name == 'mjpeg') {
  90. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  91. }
  92. else if (file.video_codec_name == 'mpeg1') {
  93. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  94. }
  95. else if (file.video_codec_name == 'mpeg2') {
  96. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  97. }
  98. else if (file.video_codec_name == 'mpeg4') {
  99. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  100. }
  101. else if (file.video_codec_name == 'vc1') {
  102. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  103. }
  104. else if (file.video_codec_name == 'vp8') {
  105. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  106. }
  107. else if (file.video_codec_name == 'vp9') {
  108. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  109. }
  110. else {
  111. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 25'
  112. }
  113.  
  114. transcode = 1;
  115. }
  116.  
  117. //file will be encoded if the resolution is 1080p
  118. //codec will be checked so it can be transcoded correctly
  119. if(file.video_resolution === "1080p") {
  120. if (file.video_codec_name == 'h263') {
  121. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  122. }
  123. else if (file.video_codec_name == 'h264') {
  124. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  125. }
  126. else if (file.video_codec_name == 'mjpeg') {
  127. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  128. }
  129. else if (file.video_codec_name == 'mpeg1') {
  130. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  131. }
  132. else if (file.video_codec_name == 'mpeg2') {
  133. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  134. }
  135. else if (file.video_codec_name == 'mpeg4') {
  136. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  137. }
  138. else if (file.video_codec_name == 'vc1') {
  139. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  140. }
  141. else if (file.video_codec_name == 'vp8') {
  142. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  143. }
  144. else if (file.video_codec_name == 'vp9') {
  145. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  146. }
  147. else {
  148. response.preset = ',-map 0:v -map 0:s? -c:s srt -map 0:a -c copy -c:v:0 libx265 -preset fast -crf 23'
  149. }
  150.  
  151. transcode = 1;
  152. }
  153.  
  154. //check if the file is eligible for transcoding
  155. //if true the neccessary response values will be changed
  156. if (transcode == 1) {
  157. response.processFile = true;
  158. response.FFmpegMode = true
  159. response.reQueueAfter = true;
  160. response.infoLog += `☒File is ${file.video_resolution} but is not hevc!\n`
  161. response.infoLog += `☒File will be transcoded!\n`
  162. }
  163.  
  164. return response
  165. }
  166.  
  167. module.exports.details = details;
  168.  
  169. module.exports.plugin = plugin;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement