FFmpeg learning (1) - Video file format conversion

Ffmpeg download and extract;

New batch file in mmfpeg.exe directory, as follows

@echo off
title 正在转换,mp4转换完成自动关闭
ffmpeg -i %1 -y -qscale 0 -vcodec libx264 %~n1.mp4
ping -n 5 127.0.0.1 >nul

Copy the need to convert video to the same batch directory, drag and drop the files you want to convert to the above batch. Conversion is completed automatically exit, generating a mp4 format video

Batch conversion script convert2MP4.bat

@echo off
title 视频批量无损转mp4格式
set path=E:\softs\ffmpeg-4.2.2-win64-static\bin;%path%
for /f "delims=" %%i in ('dir /b /a-d /s "*.%1"') do echo ffmpeg -i "%%i" -y -qscale 0 -vcodec libx264 "%cd%\%%~ni.mp4"
ping -n 5 127.0.0.1 >nul

Usage: Copy this file to the directory you want to convert. For example, should turn wmv mp4 execute the following command

convert2MP4.bat wmv, execution is completed as follows (the file name is converted not to take spaces)

 Report: Batch clear the batch file character

setlocal enabledelayedexpansion 
for %%j in (*.%1) do ( 
set filename=%%~nj 
rem 、替换成.
set filename=!filename:、=.!
rem 清除空格
set filename=!filename: =!
rem ... 其他读者触类旁通
if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj" 
)

Operating Screenshot:

 

Published 295 original articles · won praise 37 · views 30000 +

Guess you like

Origin blog.csdn.net/tianshan2010/article/details/104735423