greatseth / mediainfo

Ruby wrapper for the mediainfo CLI. http://mediainfo.sourceforge.net
MIT License
73 stars 46 forks source link

Handling an encoding date which can not be parsed #60

Open s-dousse opened 1 year ago

s-dousse commented 1 year ago

Hello, we encountered some issues with the MediaInfo.from(file. path) files submitted by our users have all zeros as an encoding date

Could MediaInfo handle the encoding date if it's not able to be parsed instead of throwing the error:

ArgumentError: mon out of range
a-mellor commented 1 year ago

Example:

[3] pry(#<MediaInfo::Tracks>)> converted_xml.elements.each('//track') { |t| puts t }
<track type='General'>
<VideoCount>1</VideoCount>
<OtherCount>3</OtherCount>
<FileExtension>mxf</FileExtension>
<Format>MXF</Format>
<Format_Commercial_IfAny>XDCAM HD422</Format_Commercial_IfAny>
<Format_Version>1.3</Format_Version>
<Format_Profile>OP-1a</Format_Profile>
<Format_Settings>Closed / Complete</Format_Settings>
<FileSize>188166189</FileSize>
<Duration>30.000</Duration>
<OverallBitRate>50177650</OverallBitRate>
<FrameRate>25.000</FrameRate>
<FrameCount>750</FrameCount>
<StreamSize>7501</StreamSize>
<FooterSize>557</FooterSize>
<Encoded_Date>0-00-00 00:00:00.000</Encoded_Date>
<File_Modified_Date>UTC 2023-01-18 17:31:12</File_Modified_Date>
<File_Modified_Date_Local>2023-01-18 17:31:12</File_Modified_Date_Local>
<Encoded_Application_CompanyName>FFmpeg</Encoded_Application_CompanyName>
<Encoded_Application_Name>OP1a Muxer</Encoded_Application_Name>
<Encoded_Application_Version>58.24.100.0.0</Encoded_Application_Version>
<Encoded_Library_Version>58.24.100.0.0</Encoded_Library_Version>
</track>
<track type='Video'>
<ID>2</ID>
<Format>MPEG Video</Format>
<Format_Commercial_IfAny>XDCAM HD422</Format_Commercial_IfAny>
<Format_Version>2</Format_Version>
<Format_Profile>4:2:2</Format_Profile>
<Format_Level>Main</Format_Level>
<Format_Settings_BVOP>No</Format_Settings_BVOP>
<Format_Settings_Matrix>Default</Format_Settings_Matrix>
<Format_Settings_GOP>N=12</Format_Settings_GOP>
<Format_Settings_Wrapping>Frame (D-10)</Format_Settings_Wrapping>
<CodecID>0D01030102010101-0401020201020101</CodecID>
<Duration>30.000</Duration>
<BitRate_Mode>CBR</BitRate_Mode>
<BitRate>50000000</BitRate>
<Width>720</Width>
<Height>576</Height>
<Height_Offset>32</Height_Offset>
<Height_Original>608</Height_Original>
<Sampled_Width>720</Sampled_Width>
<Sampled_Height>608</Sampled_Height>
<PixelAspectRatio>1.000</PixelAspectRatio>
<PixelAspectRatio_Original>1.501</PixelAspectRatio_Original>
<DisplayAspectRatio>1.778</DisplayAspectRatio>
<FrameRate>25.000</FrameRate>
<FrameCount>750</FrameCount>
<Standard>PAL</Standard>
<ColorSpace>YUV</ColorSpace>
<ChromaSubsampling>4:2:2</ChromaSubsampling>
<BitDepth>8</BitDepth>
<ScanType>Progressive</ScanType>
<Compression_Mode>Lossy</Compression_Mode>
<Delay>0.000</Delay>
<Delay_Original>0.000</Delay_Original>
<TimeCode_FirstFrame>00:00:00:00</TimeCode_FirstFrame>
<TimeCode_Source>Group of pictures header</TimeCode_Source>
<Gop_OpenClosed>Open</Gop_OpenClosed>
<Gop_OpenClosed_FirstFrame>Closed</Gop_OpenClosed_FirstFrame>
<StreamSize>188158688</StreamSize>
<BufferSize>251904</BufferSize>
<colour_description_present>Yes</colour_description_present>
<colour_description_present_Source>Stream</colour_description_present_Source>
<colour_primaries>BT.709</colour_primaries>
<colour_primaries_Source>Stream</colour_primaries_Source>
<transfer_characteristics>BT.709</transfer_characteristics>
<transfer_characteristics_Source>Container / Stream</transfer_characteristics_Source>
<matrix_coefficients>BT.709</matrix_coefficients>
<matrix_coefficients_Source>Stream</matrix_coefficients_Source>
<extra>
<Delay_SDTI>0</Delay_SDTI>
<intra_dc_precision>8</intra_dc_precision>
</extra>
</track>
<track type='Other' typeorder='1'>
<ID>1-Material</ID>
<Type>Time code</Type>
<Format>MXF TC</Format>
<FrameRate>25.000</FrameRate>
<FrameCount>750</FrameCount>
<TimeCode_FirstFrame>00:00:00:00</TimeCode_FirstFrame>
<TimeCode_LastFrame>00:00:29:24</TimeCode_LastFrame>
<TimeCode_Settings>Material Package</TimeCode_Settings>
<TimeCode_Striped>Yes</TimeCode_Striped>
</track>
<track type='Other' typeorder='2'>
<ID>1-Source</ID>
<Type>Time code</Type>
<Format>MXF TC</Format>
<FrameRate>25.000</FrameRate>
<FrameCount>750</FrameCount>
<TimeCode_FirstFrame>00:00:00:00</TimeCode_FirstFrame>
<TimeCode_LastFrame>00:00:29:24</TimeCode_LastFrame>
<TimeCode_Settings>Source Package</TimeCode_Settings>
<TimeCode_Striped>Yes</TimeCode_Striped>
</track>
<track type='Other' typeorder='3'>
<Type>Time code</Type>
<Format>SMPTE TC</Format>
<MuxingMode>SDTI</MuxingMode>
<FrameRate>25.000</FrameRate>
<TimeCode_FirstFrame>00:00:00:00</TimeCode_FirstFrame>
</track>