{"id":887,"date":"2025-05-29T17:31:26","date_gmt":"2025-05-29T17:31:26","guid":{"rendered":"https:\/\/remote-support.space\/wordpress\/?p=887"},"modified":"2025-05-29T17:31:27","modified_gmt":"2025-05-29T17:31:27","slug":"scaling-video-sizes-via-ffmpeg","status":"publish","type":"post","link":"https:\/\/remote-support.space\/wordpress\/2025\/05\/29\/scaling-video-sizes-via-ffmpeg\/","title":{"rendered":"Scaling video sizes via ffmpeg."},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>To reduce the resolution of an MP4 video using FFmpeg, follow these steps and choose the method that best fits your needs:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Basic Resolution Reduction (e.g., to 640&#215;480)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale=640:480\" output.mp4<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Note:<\/strong> This may distort the aspect ratio if not proportional to the original.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Maintain Aspect Ratio (Auto-Height)<\/strong><\/h3>\n\n\n\n<p>Scale to a specific width while calculating height to preserve aspect ratio:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale=640:-2\" output.mp4<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-2<\/code> ensures the height is divisible by 2 (required for most codecs).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Scale by Percentage (e.g., 50% smaller)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale=iw*0.5:ih*0.5\" output.mp4<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>iw\/ih<\/code>: Input width\/height. Multipliers (<code>0.5<\/code> = half size) can be adjusted.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>Target Maximum Dimensions (Fit within 640&#215;480 box)<\/strong><\/h3>\n\n\n\n<p>Scales down only if needed, preserving aspect ratio:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale='min(640,iw)':'min(480,ih)':force_original_aspect_ratio=decrease\" output.mp4<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>High-Quality Downscale with Lanczos Filter<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale=1280:720:flags=lanczos\" -c:v libx264 -crf 23 -preset slow -c:a copy output.mp4<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>flags=lanczos<\/code>: Uses the Lanczos algorithm for sharper downscaling.<\/li>\n\n\n\n<li><code>-crf 23<\/code>: Controls quality (lower = better, 18\u201328 is typical).<\/li>\n\n\n\n<li><code>-preset slow<\/code>: Better compression (slower encoding).<\/li>\n\n\n\n<li><code>-c:a copy<\/code>: Copies audio without re-encoding (remove to re-encode audio).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>Force Specific Codec &amp; Optimize for Web<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>   ffmpeg -i input.mp4 -vf \"scale=1280:720\" -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k -movflags +faststart output.mp4<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-c:v libx264<\/code>: Uses H.264 video codec.<\/li>\n\n\n\n<li><code>-c:a aac<\/code>: Re-encodes audio to AAC.<\/li>\n\n\n\n<li>`-movflags +faststart**: Allows video to start playing faster online.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Key Notes:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Aspect Ratio:<\/strong> Always use <code>scale=WIDTH:-2<\/code> (auto-height) or <code>force_original_aspect_ratio<\/code> to avoid distortion.<\/li>\n\n\n\n<li><strong>Quality:<\/strong> Use <code>-crf<\/code> (lower = better) and <code>-preset<\/code> (slower = better compression).<\/li>\n\n\n\n<li><strong>Hardware Acceleration:<\/strong> Add flags like <code>-hwaccel cuda<\/code> (NVIDIA) or <code>-c:v h264_videotoolbox<\/code> (macOS) for faster encoding.<\/li>\n\n\n\n<li><strong>Check Resolution:<\/strong> Use <code>ffprobe input.mp4<\/code> to see original dimensions.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example (Most Common Use Case):<\/h3>\n\n\n\n<p>Scale to <strong>720p<\/strong>, preserve aspect ratio, high-quality settings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -vf \"scale=1280:-2\" -c:v libx264 -crf 22 -preset slow -c:a copy output.mp4<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To reduce the resolution of an MP4 video using FFmpeg, follow these steps and choose the method that best fits your needs: 1. Basic Resolution Reduction (e.g., to 640&#215;480) 2. Maintain Aspect Ratio (Auto-Height) Scale to a specific width while calculating height to preserve aspect ratio: 3. Scale by Percentage (e.g., 50% smaller) 4. Target [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-887","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/comments?post=887"}],"version-history":[{"count":1,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/887\/revisions"}],"predecessor-version":[{"id":888,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/posts\/887\/revisions\/888"}],"wp:attachment":[{"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/media?parent=887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/categories?post=887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/remote-support.space\/wordpress\/wp-json\/wp\/v2\/tags?post=887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}