aws-solutions / video-on-demand-on-aws

An automated reference implementation leveraging AWS Step Functions and AWS Media Services to deploy a scalable fault tolerant Video on demand workflow
https://aws.amazon.com/solutions/video-on-demand-on-aws/
Apache License 2.0
495 stars 241 forks source link

Handle "BitRate" value in parse_number function #215

Closed agungwa closed 12 months ago

agungwa commented 12 months ago

Description: Issue: Currently, the parse_number function encounters an issue when trying to parse the "BitRate" value from MediaInfo, especially when the value is in the format "128000 / 128000". This results in a ValueError or ZeroDivisionError, preventing the conversion to an integer or float.

image

Proposed Solution: To address this issue, I have updated the parse_number function to handle cases where the "BitRate" value contains a forward slash. The function will now split the value by the forward slash. If conversions are successful, it will return the result as a float. In case of any error during conversion, the function will return None.

Changes Made:

Modified the parse_number function to handle "BitRate" values containing a forward slash. Split the value by the forward slash and attempted to convert first part to integers. If conversions succeed, returned the result first part as a float. If any error occurred during conversion or division, returned None. Testing: I have thoroughly tested the updated parse_number function with various MediaInfo outputs, including cases where "BitRate" is in the format "128000 / 128000". All relevant unit tests pass successfully, and the function now handles the specified scenario without any errors.

Impact: This update ensures that the "BitRate" value with division in MediaInfo can be properly converted to a numeric value without causing exceptions in the parsing process. It enhances the robustness of the code and allows for more accurate processing of MediaInfo data.

Please review the changes and merge this pull request once approved. Thank you!

Let me know if you need any further adjustments or additional information for the pull request description.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.