You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this has been discussed or addressed. I tried to search but I got nothing, I apologize if it has.
I'm encountering an issue when upscaling where the aspect ratio of the output would change from 4:3 to 5:4 (from 768×576 to 720×576). I suspected it has to do with ffmpeg, so I tried extracting frames using the ffmpeg cli tool directly. And indeed I got a similar result.
Key points:
Input video resolution: 768×576
Extracted frame resolution: 720×576
Issue: The extracted frames have a different aspect ratio/resolution, which means the upscaled video will also have a different aspect ratio/resolution
Expected behavior: The frames should be extracted at the original DAR resolution 768×576
I didn't fully understand why this happens at first, but after reading and I think I got a rough understanding of it. There's 2 things regarding resolution / aspect ratio in videos that need to be considered when extracting frames:
Storage Aspect Ratio (SAR)
This refers to how the pixel data is stored in a video file. In some cases, the pixels are not stored as square (non-square pixels), which means during display, DAR adjusts for that. However, when extracting frames, ffmpeg reads the data from the SAR directly, without performing this adjustment.
Display Aspect Ratio (DAR)
This refers to the resolution of the video as it is displayed on screen by the video player. In most cases, DAR matches SAR, meaning the video is displayed with square pixels. However, in some cases, such as with older media, DAR may differ from SAR.
The key idea here is to multiply the input width iw (which is 720 in my case) by SAR (which is 16:15 in my case) to compensates for the non-square pixels in SAR in the original video.
720 * (16/15) = 768.
Here's the full command I used to get the correct aspect ratio for the extracted frames that matches DAR:
I'm not sure if this has been discussed or addressed. I tried to search but I got nothing, I apologize if it has.
I'm encountering an issue when upscaling where the aspect ratio of the output would change from 4:3 to 5:4 (from 768×576 to 720×576). I suspected it has to do with ffmpeg, so I tried extracting frames using the ffmpeg cli tool directly. And indeed I got a similar result.
Key points:
I didn't fully understand why this happens at first, but after reading and I think I got a rough understanding of it. There's 2 things regarding resolution / aspect ratio in videos that need to be considered when extracting frames:
Storage Aspect Ratio (SAR)
This refers to how the pixel data is stored in a video file. In some cases, the pixels are not stored as square (non-square pixels), which means during display, DAR adjusts for that. However, when extracting frames, ffmpeg reads the data from the SAR directly, without performing this adjustment.
Display Aspect Ratio (DAR)
This refers to the resolution of the video as it is displayed on screen by the video player. In most cases, DAR matches SAR, meaning the video is displayed with square pixels. However, in some cases, such as with older media, DAR may differ from SAR.
I found a solution using ffmpeg's scale filter.
The key idea here is to multiply the input width
iw
(which is 720 in my case) bySAR
(which is 16:15 in my case) to compensates for the non-square pixels in SAR in the original video.720 * (16/15) = 768.
Here's the full command I used to get the correct aspect ratio for the extracted frames that matches DAR:
Thankfully ffmpeg understands the keyword
sar
so this command figures out all the needed numbers for the math automatically.Maybe this should be added as an optional setting for those who need it.
The text was updated successfully, but these errors were encountered: