Azure-Samples / azure-video-indexer-samples

Contains the Azure Media Services Video Indexer samples
MIT License
141 stars 112 forks source link

Custom Insights Example incorrect. #79

Closed Nico-VanHaaster closed 1 year ago

Nico-VanHaaster commented 1 year ago

The linked sample does not work correctly. When looking at the custom insights the Insights tab bar graph does not show correctly as times are showing as "NaN:NaN:NaN". Following through the examples the duration is expected as number as seconds. (ie 634)

https://github.com/Azure-Samples/media-services-video-indexer/blob/eea7f3fe72bf21e5fbda55800dc93361bb3d0b1f/Embedding%20widgets/widget-customization/custom-insight-widget/custom-insights-widget-with-raw-insight-data-and-controls.html

Digging through the minified js the method 'generateBasicIndexObject' is actually passing in the duration as seconds and then try to generate a string of "hh:mm:ss". However the function implementation is then returning a string formatted as "634:undefined:undefined". This is then being passed to the graph which is failing to parse.

Is there a work around for this?

nofaredanoren commented 1 year ago

Hey @Nico-VanHaaster We found the bug and working on a fix. Will update you once resolved.

Thanks for letting us know!

Nico-VanHaaster commented 1 year ago

@nofaredanoren Thanks for the update. Do you have any estimated timeframe for the fix?

nofaredanoren commented 1 year ago

You're welcome @Nico-VanHaaster The fix was deployed, can you please verify from your side?

Thanks

Nico-VanHaaster commented 1 year ago

@nofaredanoren Thanks again for the update and although the NaN:NaN:NaN is resolved I dont believe its actually correct. Looking at the new minified code it is handling the undefined correctly however now the video duration is now returning (from the example of duration: 634 duration in seconds) the value "634:00:00" which would indicate the video is 634 hours not 10 mins 34 seconds.

Code like below should solve this.

const duration = 634;
const hour = Math.floor(duration / (3600));
const minutes = Math.floor(duration / 60) % 60;
const seconds = duration % 60;

const durString = [hour, minutes, seconds]
  .map(t => String(!isNaN(t) ? t : 0).padStart(2, "0"))
  .join(":");

console.log(durString);

image

nofaredanoren commented 1 year ago

Thanks @Nico-VanHaaster for the suggestion! The widgets works a bit different and I appreciate your help. Another fix was deployed, can you check again? Thanks

Nico-VanHaaster commented 1 year ago

@nofaredanoren Great thank you very much. I just tested the sample and our own usage of custom insights and this seems to be resolved. I really appreciate your quick turn around on these fixes.

I will close this for bug report.