Skip to content

Commit

Permalink
Fixed Logic for GetFrame
Browse files Browse the repository at this point in the history
Android - It takes Microsecond, so multiplying milliseconds with 1000
iOS, CMTime ticks in 1000's
  • Loading branch information
muhaym committed Apr 15, 2020
1 parent 5038344 commit 743a030
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public Task<object> ProvideVideoFrame(IMediaItem mediaItem, TimeSpan timeFromSta
{
var metadataRetriever = CreateMediaRetriever(mediaItem);

var bitmap = metadataRetriever.GetFrameAtTime((long)timeFromStart.TotalMilliseconds);
var bitmap = metadataRetriever.GetFrameAtTime((long)(timeFromStart.TotalMilliseconds * 1000));

metadataRetriever.Release();
return Task.FromResult(bitmap as object);
Expand Down
2 changes: 1 addition & 1 deletion MediaManager/Platforms/Android/Media/ID3Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async Task<object> ProvideVideoFrame(IMediaItem mediaItem, TimeSpan timeF
{
var metadataRetriever = await CreateMediaRetriever(mediaItem).ConfigureAwait(false);

image = metadataRetriever.GetFrameAtTime((long)timeFromStart.TotalMilliseconds);
image = metadataRetriever.GetFrameAtTime((long)(timeFromStart.TotalMilliseconds*1000));

metadataRetriever.Release();
}
Expand Down
2 changes: 1 addition & 1 deletion MediaManager/Platforms/Apple/Media/AVAssetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Task<object> ProvideVideoFrame(IMediaItem mediaItem, TimeSpan timeFromSta
var url = mediaItem.GetNSUrl();
var imageGenerator = new AVAssetImageGenerator(AVAsset.FromUrl(url));
imageGenerator.AppliesPreferredTrackTransform = true;
var cgImage = imageGenerator.CopyCGImageAtTime(new CMTime((long)timeFromStart.TotalMilliseconds, 1000000), out var actualTime, out var error);
var cgImage = imageGenerator.CopyCGImageAtTime(new CMTime((long)timeFromStart.TotalMilliseconds, 1000), out var actualTime, out var error);
return Task.FromResult(cgImage as object);
}
}
Expand Down

0 comments on commit 743a030

Please sign in to comment.