Open pkarp0 opened 7 years ago
Because there are videos that are sized at display time I suggest adding this code block to ffmpeg_parse_infos to gather the SAR and DAR information along with the width and height. This will allow a user to get the SAR so the video can be resized if needed.
# get the size, of the form 460x320 (w x h)
match = re.search(" [0-9]*x[0-9]*(,| )", line)
s = list(map(int, line[match.start():match.end()-1].split('x')))
result['video_size'] = s
>>> Insert the following code:
# Get the SAR and DAR aspect ratios of the form 4:3
match = re.search(" \[SAR (?P<sar_w>\d+):(?P<sar_h>\d+) DAR (?P<dar_w>\d+):(?P<dar_h>\d+)\]", line)
if match:
ar_dict = {'video_sar': ['sar_w', 'sar_h'],
'video_dar': ['dar_w', 'dar_h']}
for k, v in ar_dict.items():
result[k] = [int(match.groupdict()[item]) for item in v]
The following can be included in the FFMPEG_VideoReader constructor:
self.sar = infos.get('video_sar')
self.dar = infos.get('video_dar')
Linking #289
An original video 1080x1080 file includes SAR (sample_aspect_ratio) that is used by video players to scale the video. In this example SAR = 4:3
After loading the VideoFileClip and writing it the SAR information is missing and the video is displayed incorrectly 1:1.