How to adjust the width and height of the video in .bat (horizontal and vertical video processing)

One of the requirements developed before is that others provide some videos and play them on Android devices with horizontal screens. However, when the default player and Exoplayer play, the vertical screen videos will be automatically stretched horizontally, which will affect normal viewing;

 

Processing method: 1. Select another player, which can play normally; 2. Process the vertical video; 3. Find a method to process the video online

The first method requires some development. It is cumbersome to choose the correct video playback framework and incorporate the code.

The second method is to process the video and adjust the width and height of the video, such as changing the original width and height from 360:640 to 1280:800;

The third method, the Internet or some small programs can be converted, but they are all charged

 

I use the second method, the video processing should be designed into ffmpeg, and this function can also be realized through the .bat file, and batch processing is also possible;

        Video and audio processing , generally using ffmpeg technology, can handle

        For ffmpeg- related information, please refer to: ffmpeg common commands_Da Yuge_'s Blog-CSDN Blog

The following is the content of the .bat script:

@echo off
setlocal enabledelayedexpansion

rem video 是你要调整的视频的文件名
set /p video=请输入文件名(如 a.mp4):

rem wvh 原视频的宽:高
set wvh=368:640

rem 设置你想设置的视频的宽度,默认是1280
set orweight=1280

rem 设置你想设置的视频的高度,默认是800
set orheight=800

rem weight 原视频的宽
set /p weight=请输入原视频的宽:

rem height 原视频的高
set /p height=请输入原视频的高:

rem 新视频的名字
set outvideo=%video%-newmp4.mp4

set /a x1=(%orweight%-%weight%)/2
set /a y1=(%orheight%-%height%)/2

echo --------------------------------------------------
echo %video%
echo %wvh%
echo %outvideo%
echo %x1%   %y1%

rem 640*400 为视频的视频率,可自行修改,注意视频的大小

rem ffmpeg -i %video% -s 640*400 -aspect %wvh% -y %outvideo%

rem ffmpeg -i %video% -vf "transpose=2" -y %outvideo%

rem ffmpeg -i %video% -vf drawbox=x=0:y=0:w=100:h=640:c=yellow:t=10 -y %outvideo%

rem 1280*800  默认调整视频分辨率为1280*800,可自行调整
ffmpeg -i %video% -vf pad=%orweight%:%orheight%:%x1%:%y1%:black -y %outvideo%

pause

In this way, the conversion of vertical screen video is perfectly solved;

In fact, the main principle is to add black borders horizontally, and then make the video play like a horizontal video. It is a tricky method. The generated video is actually similar to the video obtained in the third method;

Guess you like

Origin blog.csdn.net/gqg_guan/article/details/132075949