“Ffmepg”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
第30行: 第30行:
 
englishpod_D0117mydg.mp3
 
englishpod_D0117mydg.mp3
  
 +
另存到 0
  
 
2. 按字母 awk  sort   
 
2. 按字母 awk  sort   
第67行: 第68行:
 
file 'englishpod_B0119mydg.mp3'
 
file 'englishpod_B0119mydg.mp3'
  
cat mylist.txt  #最后文件列表文件排序后如下   
+
cat list.txt  #最后文件列表文件排序后如下   
 
file 'englishpod_B0111mydg.mp3'
 
file 'englishpod_B0111mydg.mp3'
 
file 'englishpod_C0112mydg.mp3'
 
file 'englishpod_C0112mydg.mp3'
第78行: 第79行:
  
  
ffmpeg -f concat -i mylist.txt -c copy  111-120.mp3
+
ffmpeg -f concat -i list.txt -c copy  111-120.mp3
  
  

2024年9月19日 (四) 14:21的最新版本

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. 得到文件列表  
 
 ➜ 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

另存到 0 

2. 按字母 awk  sort  
 
 ➜   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 -i "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 -i "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 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'


ffmpeg -f concat -i list.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
    

 

https://stackoverflow.com/questions/31889233/how-to-sort-alphanumeric-by-numbers-in-shell

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  开发包

refercence

CentOS中yum安装ffmpeg

nginx流媒体服务器(基于CentOS7)实现rtmp直播流,m3u8视频流