“Ffmepg”的版本间的差异
跳到导航
跳到搜索
(→Usage) |
|||
第7行: | 第7行: | ||
# 这些文件是相对路径,如使用绝对路径需要添加 `-safe 0` 参数 | # 这些文件是相对路径,如使用绝对路径需要添加 `-safe 0` 参数 | ||
$ ffmpeg -f concat -i mylist.txt -c copy output.mp3 #or output.mp4 | $ ffmpeg -f concat -i mylist.txt -c copy output.mp3 #or output.mp4 | ||
+ | </pre> | ||
+ | == 对有字母和数字的文件名排序后合并shell version== | ||
+ | |||
+ | <pre> | ||
+ | |||
+ | 原因 kevin大神合并的文件是有漏的,而我想合并一些只是自己喜欢学过的比较easy的 所以 | ||
+ | |||
+ | |||
+ | 1. 得到文件列表 | ||
+ | |||
+ | ➜ 111 for loop in `ls` | ||
+ | for> do | ||
+ | for> echo $loop | ||
+ | for> done | ||
+ | englishpod_B0111mydg.mp3 | ||
+ | englishpod_B0113mydg.mp3 | ||
+ | englishpod_B0115mydg.mp3 | ||
+ | englishpod_B0119mydg.mp3 | ||
+ | englishpod_C0112mydg.mp3 | ||
+ | englishpod_C0114mydg.mp3 | ||
+ | englishpod_C0118mydg.mp3 | ||
+ | englishpod_D0117mydg.mp3 | ||
+ | |||
+ | |||
+ | 2. 按字母 awk sort | ||
+ | |||
+ | ➜ 111 awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' 0 |sort -nk1 | cut -d $'\t' -f2- | ||
+ | englishpod_B0111mydg.mp3 | ||
+ | englishpod_C0112mydg.mp3 | ||
+ | englishpod_B0113mydg.mp3 | ||
+ | englishpod_C0114mydg.mp3 | ||
+ | englishpod_B0115mydg.mp3 | ||
+ | englishpod_D0117mydg.mp3 | ||
+ | englishpod_C0118mydg.mp3 | ||
+ | englishpod_B0119mydg.mp3 | ||
+ | |||
+ | awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' 0 |sort -nk1 | cut -d $'\t' -f2- >list.txt | ||
+ | |||
+ | 3. 添加head | ||
+ | ➜ 111 sed "s/^/file '/g" list.txt | ||
+ | file 'englishpod_B0111mydg.mp3 | ||
+ | file 'englishpod_C0112mydg.mp3 | ||
+ | file 'englishpod_B0113mydg.mp3 | ||
+ | file 'englishpod_C0114mydg.mp3 | ||
+ | file 'englishpod_B0115mydg.mp3 | ||
+ | file 'englishpod_D0117mydg.mp3 | ||
+ | file 'englishpod_C0118mydg.mp3 | ||
+ | file 'englishpod_B0119mydg.mp3 | ||
+ | |||
+ | 添加 tail | ||
+ | ➜ 111 sed "s/$/&'/g" list.txt | ||
+ | file 'englishpod_B0111mydg.mp3' | ||
+ | file 'englishpod_C0112mydg.mp3' | ||
+ | file 'englishpod_B0113mydg.mp3' | ||
+ | file 'englishpod_C0114mydg.mp3' | ||
+ | file 'englishpod_B0115mydg.mp3' | ||
+ | file 'englishpod_D0117mydg.mp3' | ||
+ | file 'englishpod_C0118mydg.mp3' | ||
+ | file 'englishpod_B0119mydg.mp3' | ||
+ | |||
+ | cat mylist.txt #最后文件列表文件排序后如下 | ||
+ | file 'englishpod_B0111mydg.mp3' | ||
+ | file 'englishpod_C0112mydg.mp3' | ||
+ | file 'englishpod_B0113mydg.mp3' | ||
+ | file 'englishpod_C0114mydg.mp3' | ||
+ | file 'englishpod_B0115mydg.mp3' | ||
+ | file 'englishpod_D0117mydg.mp3' | ||
+ | file 'englishpod_C0118mydg.mp3' | ||
+ | file 'englishpod_B0119mydg.mp3' | ||
+ | |||
+ | |||
+ | ffmpeg -f concat -i mylist.txt -c copy 111-120.mp3 | ||
+ | |||
+ | |||
+ | </pre> | ||
+ | === shell 解说=== | ||
+ | <pre> | ||
+ | awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' file | ||
+ | | sort -nk1 | cut -d $'\t' -f2- | ||
+ | bc14de | ||
+ | cd 18 | ||
+ | abc90 | ||
+ | 100def | ||
+ | |||
+ | awk用于在输入中添加仅使用gsub的数字字符的第一列。 | ||
+ | sort -nk1用于对第一列的输入进行数字排序。 | ||
+ | cut最终用于截断第一列。 | ||
+ | |||
+ | awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' file \ | ||
+ | | sort -nk1 | cut -d $'\t' -f2- | ||
+ | bc14de | ||
+ | cd 18 | ||
+ | abc90 | ||
+ | 100def | ||
+ | |||
+ | awk is used to add a first column in input with only numeric characters using gsub | ||
+ | sort -nk1 is used for sorting input numerically on first column | ||
+ | cut is finally used to truncate first column | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | “`shell | ||
+ | ffmpeg -i 视频文件.mp4 -i 音频文件.mp3 -c:v copy -c:a aac -strict experimental 输出文件名.mp4 | ||
+ | “` | ||
+ | 具体的命令解释如下: | ||
+ | – `-i 视频文件.mp4`:指定输入的视频文件名。 | ||
+ | – `-i 音频文件.mp3`:指定输入的音频文件名。 | ||
+ | – `-c:v copy`:将视频流直接复制到输出文件中,以保持原始的视频质量。 | ||
+ | – `-c:a aac`:使用AAC编码器编码音频流。 | ||
+ | – `-strict experimental`:在使用AAC编码器时,启用实验性的模式。 | ||
+ | – `输出文件名.mp4`:指定输出文件的文件名和格式。 | ||
+ | |||
+ | |||
</pre> | </pre> | ||
https://wangchujiang.com/reference/docs/ffmpeg.html | https://wangchujiang.com/reference/docs/ffmpeg.html | ||
+ | |||
=install= | =install= | ||
==yum== | ==yum== |
2024年6月23日 (日) 09:37的版本
Usage
# mylist.txt >>> file '1.mp4' file '2.mp4' file '3.mp4' # 这些文件是相对路径,如使用绝对路径需要添加 `-safe 0` 参数 $ ffmpeg -f concat -i mylist.txt -c copy output.mp3 #or output.mp4
对有字母和数字的文件名排序后合并shell version
原因 kevin大神合并的文件是有漏的,而我想合并一些只是自己喜欢学过的比较easy的 所以 1. 得到文件列表 ➜ 111 for loop in `ls` for> do for> echo $loop for> done englishpod_B0111mydg.mp3 englishpod_B0113mydg.mp3 englishpod_B0115mydg.mp3 englishpod_B0119mydg.mp3 englishpod_C0112mydg.mp3 englishpod_C0114mydg.mp3 englishpod_C0118mydg.mp3 englishpod_D0117mydg.mp3 2. 按字母 awk sort ➜ 111 awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' 0 |sort -nk1 | cut -d $'\t' -f2- englishpod_B0111mydg.mp3 englishpod_C0112mydg.mp3 englishpod_B0113mydg.mp3 englishpod_C0114mydg.mp3 englishpod_B0115mydg.mp3 englishpod_D0117mydg.mp3 englishpod_C0118mydg.mp3 englishpod_B0119mydg.mp3 awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' 0 |sort -nk1 | cut -d $'\t' -f2- >list.txt 3. 添加head ➜ 111 sed "s/^/file '/g" list.txt file 'englishpod_B0111mydg.mp3 file 'englishpod_C0112mydg.mp3 file 'englishpod_B0113mydg.mp3 file 'englishpod_C0114mydg.mp3 file 'englishpod_B0115mydg.mp3 file 'englishpod_D0117mydg.mp3 file 'englishpod_C0118mydg.mp3 file 'englishpod_B0119mydg.mp3 添加 tail ➜ 111 sed "s/$/&'/g" list.txt file 'englishpod_B0111mydg.mp3' file 'englishpod_C0112mydg.mp3' file 'englishpod_B0113mydg.mp3' file 'englishpod_C0114mydg.mp3' file 'englishpod_B0115mydg.mp3' file 'englishpod_D0117mydg.mp3' file 'englishpod_C0118mydg.mp3' file 'englishpod_B0119mydg.mp3' cat mylist.txt #最后文件列表文件排序后如下 file 'englishpod_B0111mydg.mp3' file 'englishpod_C0112mydg.mp3' file 'englishpod_B0113mydg.mp3' file 'englishpod_C0114mydg.mp3' file 'englishpod_B0115mydg.mp3' file 'englishpod_D0117mydg.mp3' file 'englishpod_C0118mydg.mp3' file 'englishpod_B0119mydg.mp3' ffmpeg -f concat -i mylist.txt -c copy 111-120.mp3
shell 解说
awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' file | sort -nk1 | cut -d $'\t' -f2- bc14de cd 18 abc90 100def awk用于在输入中添加仅使用gsub的数字字符的第一列。 sort -nk1用于对第一列的输入进行数字排序。 cut最终用于截断第一列。 awk -v OFS='\t' '{rec=$0; gsub(/[^[:digit:]]+/, "", rec); print rec, $0}' file \ | sort -nk1 | cut -d $'\t' -f2- bc14de cd 18 abc90 100def awk is used to add a first column in input with only numeric characters using gsub sort -nk1 is used for sorting input numerically on first column cut is finally used to truncate first column “`shell ffmpeg -i 视频文件.mp4 -i 音频文件.mp3 -c:v copy -c:a aac -strict experimental 输出文件名.mp4 “` 具体的命令解释如下: – `-i 视频文件.mp4`:指定输入的视频文件名。 – `-i 音频文件.mp3`:指定输入的音频文件名。 – `-c:v copy`:将视频流直接复制到输出文件中,以保持原始的视频质量。 – `-c:a aac`:使用AAC编码器编码音频流。 – `-strict experimental`:在使用AAC编码器时,启用实验性的模式。 – `输出文件名.mp4`:指定输出文件的文件名和格式。
https://wangchujiang.com/reference/docs/ffmpeg.html
install
yum
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro #rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm yum install -y ffmpeg #ffmpeg-devel 开发包