added overall bitrate to video info

This commit is contained in:
reven
2022-01-14 11:50:02 +13:00
parent 1bab3a0252
commit faf15a7be3
5 changed files with 17 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ namespace FileFlows.VideoNodes
{ "vi.Duration", 1800 },
{ "vi.VideoInfo", new VideoInfo()
{
Bitrate = 10_000_000,
VideoStreams = new List<VideoStream> {
new VideoStream { }
},

View File

@@ -17,7 +17,8 @@ namespace VideoNodes.Tests
public void VideoInfoTest_JudgeDreed()
{
var vi = new VideoInfoHelper(@"C:\utils\ffmpeg\ffmpeg.exe", new TestLogger());
vi.Read(@"D:\videos\unprocessed\Hellboy 2019 Bluray-1080p.mp4");
var info = vi.Read(@"D:\videos\unprocessed\Injustice.mkv");
Assert.IsNotNull(info);
}

View File

@@ -3,6 +3,10 @@ namespace FileFlows.VideoNodes
public class VideoInfo
{
public string FileName { get; set; }
/// <summary>
/// Gets or sets the bitrate in bytes per second
/// </summary>
public float Bitrate { get; set; }
public List<VideoStream> VideoStreams { get; set; } = new List<VideoStream>();
public List<AudioStream> AudioStreams { get; set; } = new List<AudioStream>();
public List<SubtitleStream> SubtitleStreams { get; set; } = new List<SubtitleStream>();
@@ -24,7 +28,7 @@ namespace FileFlows.VideoNodes
public string Title { get; set; } = "";
/// <summary>
/// The bitrate(BPS) of the video stream
/// The bitrate(BPS) of the video stream in bytes per second
/// </summary>
public float Bitrate { get; set; }

View File

@@ -67,6 +67,15 @@ namespace FileFlows.VideoNodes
var streamMatches = rgxStreams.Matches(output);
int streamIndex = 0;
// get a rough estimate, bitrate: 346 kb/s
var rgxBitrate = new Regex(@"(?<=(bitrate: ))[\d\.]+(?!=( kb/s))");
var brMatch = rgxBitrate.Match(output);
if (brMatch.Success)
{
vi.Bitrate = float.Parse(brMatch.Value) * 1_000; // to convert to b/s
}
int subtitleIndex = 1;
foreach (Match sm in streamMatches)
{

Binary file not shown.