A possible program to convert other formats to MP4

Ok, here is a possible program to convert other formats to MP4:

首先,您需要安装一个支持多种音视频格式转换的工具。FFmpeg是一款广泛使用且功能强大的开源工具, 可以通过命令行进行操作.
假设您要将输入文件夹中的所有文件都转换成MP4格式,请使用以下命令:

ffmpeg -i input_file.avi output_file.mp4

如果你想将整个目录下所有文件批量转化到mp4格式, 请使用如下脚本:

#!/bin/bash

#Define input and output directories
INPUT_DIR=/path/to/input/dir
OUTPUT_DIR=/path/to/output/dir

#Traverse all non-hidden files in the input directory and process them one by one
for file in " INPUTDIR " / ∗ dofilename = INPUT_DIR"/* do filename=INPUTDIR"/dofilename= (basename – "KaTeX parse error: Expected 'EOF', got '#' at position 8: file") #̲Get the current file name (without path) ...{filename##*.}" #Get the current extension (without dots)

if [ $extension != "mp4" ] && [ ${filename:0:1} != "." ]; then #如果当前不是mp4并且也不是隐藏文件,则开始处理该文件
    echo "Converting $filename ..."
    ffmpeg -i "$file" "${OUTPUT_DIR}/${filename%.*}.mp4"
fi 

done

echo “Conversion complete.”

This script will find all ordinary (non-hidden) files in the specified directory except the beginning of . and the end of mp4, and execute the ffmpeg command one by one for conversion.

确保您已经安装了FFmpeg并正确配置了输入和输出路径。如果需要,可以根据自己的需求修改脚本中的参数。

In summary, FFmpeg is a powerful and widely used open source tool that can be used to convert various audio and video formats to MP4 format. Batch conversion can be realized by writing simple scripts or command line operations.

Guess you like

Origin blog.csdn.net/qq_36146442/article/details/131168199