-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain original color space when encoding, cache ffmpeg/ffprobe outputs
- Loading branch information
Showing
11 changed files
with
274 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Flowframes.Data | ||
{ | ||
class ColorInfo | ||
{ | ||
public string colorSpace; | ||
public string colorRange; | ||
public string colorTransfer; | ||
public string colorPrimaries; | ||
|
||
public ColorInfo(string ffprobeOutput) | ||
{ | ||
string[] lines = ffprobeOutput.SplitIntoLines(); | ||
|
||
foreach (string line in lines) | ||
{ | ||
if (line.Contains("color_range")) | ||
{ | ||
colorRange = line.Split('=').LastOrDefault(); | ||
continue; | ||
} | ||
|
||
if (line.Contains("color_space")) | ||
{ | ||
colorSpace = line.Split('=').LastOrDefault(); | ||
continue; | ||
} | ||
|
||
if (line.Contains("color_transfer")) | ||
{ | ||
colorTransfer = line.Split('=').LastOrDefault(); | ||
continue; | ||
} | ||
|
||
if (line.Contains("color_primaries")) | ||
{ | ||
colorPrimaries = line.Split('=').LastOrDefault(); | ||
continue; | ||
} | ||
} | ||
|
||
if (colorSpace.Trim() == "unknown") | ||
colorSpace = ""; | ||
|
||
if (colorRange.Trim() == "unknown") | ||
colorRange = ""; | ||
|
||
if (colorTransfer.Trim() == "unknown") | ||
colorTransfer = ""; | ||
|
||
if (colorPrimaries.Trim() == "unknown") | ||
colorPrimaries = ""; | ||
} | ||
|
||
public bool HasAnyValues () | ||
{ | ||
if (!string.IsNullOrWhiteSpace(colorSpace)) | ||
return true; | ||
|
||
if (!string.IsNullOrWhiteSpace(colorRange)) | ||
return true; | ||
|
||
if (!string.IsNullOrWhiteSpace(colorTransfer)) | ||
return true; | ||
|
||
if (!string.IsNullOrWhiteSpace(colorPrimaries)) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public bool HasAllValues() | ||
{ | ||
if (string.IsNullOrWhiteSpace(colorSpace)) | ||
return false; | ||
|
||
if (string.IsNullOrWhiteSpace(colorRange)) | ||
return false; | ||
|
||
if (string.IsNullOrWhiteSpace(colorTransfer)) | ||
return false; | ||
|
||
if (string.IsNullOrWhiteSpace(colorPrimaries)) | ||
return false; | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.