-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Checks if a file is larger than 1 GB | ||
* @revision 1 | ||
* @outputs 2 | ||
* @minimumVersion 24.08.1.3441 | ||
*/ | ||
|
||
if(Variables.TryGetValue("file.Size", out var oSize) == false || oSize is long size == false) | ||
{ | ||
Flow.FailureReason = "file.Size not set in variables"; | ||
Logger.ELog(Flow.FailureReason); | ||
return -1; | ||
} | ||
if(size > 1_000_000_000) | ||
return 1; | ||
return 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Checks if a video files bitrate is greater than a specific bitrate | ||
* @revision 1 | ||
* @outputs 2 | ||
* @minimumVersion 24.08.1.3441 | ||
*/ | ||
|
||
// check if the bitrate for a video is over a certain amount | ||
var MAX_BITRATE = 3_000_000; // bitrate is 3,000 KBps | ||
|
||
if(Variables.TryGetValue("vi.VideoInfo", out var oVideoInfo) == false || oVideoInfo is FileFlows.VideoNodes.VideoInfo videoInfo == false) | ||
{ | ||
Logger.ILog("Failed to locate VideoInformation in variables"); | ||
return -1; | ||
} | ||
Logger.ILog("Got video information."); | ||
|
||
var video = videoInfo.VideoStreams.FirstOrDefault(); | ||
if(video == null) | ||
{ | ||
Logger.ILog("No video streams detected."); | ||
return -1; | ||
} | ||
|
||
// get the video stream | ||
var bitrate = video.Bitrate; | ||
|
||
if(bitrate < 1) | ||
{ | ||
// video stream doesn't have bitrate information | ||
// need to use the overall bitrate | ||
var overall = videoInfo.Bitrate; | ||
if(overall < 1) | ||
return 0; // couldn't get overall bitrate either | ||
|
||
// overall bitrate includes all audio streams, so we try and subtract those | ||
var calculated = overall; | ||
if(videoInfo.AudioStreams.Count > 0) // check there are audio streams | ||
{ | ||
foreach(var audio in videoInfo.AudioStreams) | ||
{ | ||
if(audio.Bitrate > 0) | ||
calculated -= audio.Bitrate; | ||
else{ | ||
// audio doesn't have bitrate either, so we just subtract 5% of the original bitrate | ||
// this is a guess, but it should get us close | ||
calculated -= (overall * 0.05f); | ||
} | ||
} | ||
} | ||
bitrate = calculated; | ||
} | ||
|
||
// check if the bitrate is over the maximum bitrate | ||
if(bitrate > MAX_BITRATE) | ||
return 1; // it is, so call output 1 | ||
return 2; // it isn't so call output 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* A switch statement for video resolution | ||
* @revision 1 | ||
* @outputs 4 | ||
* @minimumVersion 24.08.1.3441 | ||
*/ | ||
|
||
// get the first video stream, likely the only one | ||
if(Variables.TryGetValue("vi.VideoInfo", out var oVideoInfo) == false || oVideoInfo is FileFlows.VideoNodes.VideoInfo videoInfo == false) | ||
{ | ||
Logger.ILog("Failed to locate VideoInformation in variables"); | ||
return -1; | ||
} | ||
Logger.ILog("Got video information."); | ||
var video = videoInfo.VideoStreams.FirstOrDefault(); | ||
if(video == null) | ||
{ | ||
Logger.ILog("No video streams detected."); | ||
return -1; | ||
} | ||
|
||
Logger.ILog("Video stream detected."); | ||
if(video.Width > 3700) | ||
return 1; // 4k | ||
if(video.Width > 1800) | ||
return 2; // 1080p | ||
if(video.Width > 1200) | ||
return 3; // 720p | ||
return 4; // SD |