Skip to content

Commit

Permalink
Optimized video metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
usercode committed Feb 11, 2024
1 parent 5eb2350 commit 5941212
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
7 changes: 4 additions & 3 deletions src/DragonFly.AspNetCore/Assets/VideoProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public async Task<bool> OnAssetChangedAsync(IAssetProcessingContext context)

VideoMetadata metadata = new VideoMetadata();

metadata.FormatName = mediaInfo.Format.FormatLongName;
metadata.Duration = mediaInfo.Duration;

//video
if (mediaInfo.PrimaryVideoStream != null)
{
Expand All @@ -38,7 +41,6 @@ public async Task<bool> OnAssetChangedAsync(IAssetProcessingContext context)
Codec = mediaInfo.PrimaryVideoStream.CodecLongName,
Width = mediaInfo.PrimaryVideoStream.Width,
Height = mediaInfo.PrimaryVideoStream.Height,
Duration = mediaInfo.PrimaryVideoStream.Duration,
Fps = (int)mediaInfo.PrimaryVideoStream.FrameRate
};
}
Expand All @@ -50,8 +52,7 @@ public async Task<bool> OnAssetChangedAsync(IAssetProcessingContext context)
{
Codec = mediaInfo.PrimaryAudioStream.CodecLongName,
ChannelLayout = mediaInfo.PrimaryAudioStream.ChannelLayout,
Channels = mediaInfo.PrimaryAudioStream.Channels,
Duration = mediaInfo.PrimaryAudioStream.Duration
Channels = mediaInfo.PrimaryAudioStream.Channels
};
}

Expand Down
46 changes: 23 additions & 23 deletions src/DragonFly.Client/Pages/Assets/Metadata/VideoMetadataView.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
@inherits AssetMetadataComponent<VideoMetadata>

<div class="form-group">
<BSRow>
<BSLabel class="col-sm-2 col-form-label">
Format
</BSLabel>
<div class="col-sm-10">
<input type="text" class="form-control" @bind-value="@Metadata.FormatName" readonly />
</div>
</BSRow>
</div>

<div class="form-group">
<BSRow>
<BSLabel class="col-sm-2 col-form-label">
Duration
</BSLabel>
<div class="col-sm-10">
<input type="text" class="form-control" @bind-value="@Metadata.Duration" readonly />
</div>
</BSRow>
</div>

@if (Metadata.VideoInfo != null)
{
<h4>Primary video stream</h4>
Expand All @@ -12,18 +34,7 @@
<input type="text" class="form-control" @bind-value="@Metadata.VideoInfo.Codec" readonly />
</div>
</BSRow>
</div>

<div class="form-group">
<BSRow>
<BSLabel class="col-sm-2 col-form-label">
Duration
</BSLabel>
<div class="col-sm-10">
<input type="text" class="form-control" @bind-value="@Metadata.VideoInfo.Duration" readonly />
</div>
</BSRow>
</div>
</div>

<div class="form-group">
<BSRow>
Expand Down Expand Up @@ -73,17 +84,6 @@
</BSRow>
</div>

<div class="form-group">
<BSRow>
<BSLabel class="col-sm-2 col-form-label">
Duration
</BSLabel>
<div class="col-sm-10">
<input type="text" class="form-control" @bind-value="@Metadata.AudioInfo.Duration" readonly />
</div>
</BSRow>
</div>

<div class="form-group">
<BSRow>
<BSLabel class="col-sm-2 col-form-label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ public class AudioInfo
/// Channels
/// </summary>
public int? Channels { get; set; }

/// <summary>
/// DUration in ms.
/// </summary>
public TimeSpan? Duration { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public class VideoInfo
/// </summary>
public int? Height { get; set; }

/// <summary>
/// DUration in ms.
/// </summary>
public TimeSpan? Duration { get; set; }

/// <summary>
/// Frames per Second
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions src/DragonFly.Core/Modules/Assets/Metadatas/VideoMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ namespace DragonFly;
/// </summary>
public class VideoMetadata : AssetMetadata
{
/// <summary>
/// FormatName
/// </summary>
public string? FormatName { get; set; }

/// <summary>
/// Duration
/// </summary>
public TimeSpan Duration { get; set; }

/// <summary>
/// VideoInfo
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ public Type GetMetadataType(string name)

throw new Exception();
}

}

0 comments on commit 5941212

Please sign in to comment.