@@ -646,6 +646,12 @@ def decoder_info(name):
646646 return _getCodecInfo (name , False )
647647
648648
649+ _re_layouts = re .compile (
650+ re .sub (r"([().])" , r"\\\1" , "|" .join (layouts ()["layouts" ]))
651+ + r"|\d+ channels \(.+?\)"
652+ )
653+
654+
649655def _getCodecInfo (name , encoder ):
650656 stdout , data = __ ("encoder" if encoder else "decoder" , name )
651657 if data :
@@ -668,20 +674,20 @@ def _getCodecInfo(name, encoder):
668674 )
669675
670676 def resolveFs (s ):
671- m = re .match (r"(\d+)\/ (\d+)" , s )
672- return [ int (m [0 ]), int (m [1 ])]
677+ m = re .match (r"(\d+)\/(\d+)" , s )
678+ return fractions . Fraction ( int (m [1 ]),int (m [2 ]))
673679
674680 data = {
675681 "name" : m [1 ],
676682 "long_name" : m [2 ],
677683 "capabilities" : m [3 ].split (" " ) if m [3 ] and m [3 ] != "none" else [],
678- "threading" : m [4 ] if m [4 ] and m [4 ] != "none" else "" ,
684+ "threading" : m [4 ]. split ( " and " ) if m [4 ] and m [4 ] != "none" else [] ,
679685 "supported_hwdevices" : m [5 ].split (" " ) if m [5 ] else [],
680- "supported_framerates" : map ( resolveFs , m [6 ].split (" " )) if m [6 ] else [],
686+ "supported_framerates" : [ resolveFs ( s ) for s in m [6 ].split (" " )] if m [6 ] else [],
681687 "supported_pix_fmts" : m [7 ].split (" " ) if m [7 ] else [],
682- "supported_sample_rates" : m [8 ].split (" " ) if m [8 ] else [],
688+ "supported_sample_rates" : [ int ( v ) for v in m [8 ].split (" " )] if m [8 ] else [],
683689 "supported_sample_fmts" : m [9 ].split (" " ) if m [9 ] else [],
684- "supported_layouts" : m [10 ]. split ( " " ) if m [10 ] else [],
690+ "supported_layouts" : _re_layouts . findall ( m [10 ]) if m [10 ] else [],
685691 "options" : m [11 ],
686692 }
687693
0 commit comments