简体   繁体   English

Bash Shell Linux如何检测扩展文件的名称(FLV)(ass)

[英]Bash shell linux how to detect name of the extention files (flv) (ass)

I would like to create a script to mux video (flv) subtitle (.ass) automatically without user intervention 我想创建一个脚本来自动多路复用视频(flv)字幕(.ass),而无需用户干预

Exemple the script detect two files with the same name (.flv) (.ass) 例如,脚本检测到两个具有相同名称(.flv)(.ass)的文件

~/Vidéos/vidéo numbre 1.mp4
~/Vidéos/vidéo numéro 1.ass
~/Vidéos/vidéo numbre 2.mp4
~/Vidéos/vidéo numéro 2.ass
~/Vidéos/vidéo numbre x.ass
~/Vidéos/vidéo numbre x.mp4
~/Vidéos/vidéo numbre zz.mp4
~/Vidéos/vidéo numbre xy.ass

and get this 并得到这个

~/Vidéos/vidéo numbre 1.mkv
~/Vidéos/vidéo numbre 2.mkv
~/Vidéos/vidéo numbre x.mkv
~/Vidéos/vidéo numbre zz.mkv

... ...

how to détect name of the files with extention .flv .ass with the same folder of the script and mux with my commande line 如何使用扩展名.flv .ass和脚本的相同文件夹来检测文件名,并使用我的命令行对mux进行检测

ffmpeg -i "${name}.flv" -vcodec copy -acodec copy mkvtemp.mkv
mkvmerge -v -o "${name}.mkv" --default-track 0 --language 0:fre "${name}.ass" mkvtemp.mkv

tx for your help 发送给您帮助

for name in `ls | rev | cut -f2- -d. | rev | sort | uniq`; do
  ffmpeg -i "${name}.flv" -vcodec copy -acodec copy mkvtemp.mkv
  mkvmerge -v -o "${name}.mkv" --default-track 0 --language 0:fre "${name}.ass" mkvtemp.mkv
done

Replace ls with whatever you used to output the list of files. ls替换为用于输出文件列表的任何内容。

Try this 尝试这个

find . -name "*.mp4" | while read line
do
   name=`basename "$line" .mp4`
   ffmpeg -i "${name}".flv -vcodec copy -acodec copy mkvtemp.mkv
   mkvmerge -v -o "${name}".mkv --default-track 0 --language 0:fre "${name}".ass mkvtemp.mkv
done

This should work with filenames containing spaces. 这应该与包含空格的文件名一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在shell中合并bash中的两个文件 - Merging two files in bash with a twist in shell linux 在Linux Shell bash脚本中复制文件时出错 - Error copying files in Linux shell bash script shell脚本linux,bash:使用`cut`根据名称field-1将文件移动到field-2中的特定路径。 - shell script linux,bash : moving files according to name field-1 to the specific path in field-2 using `cut` 如何使用 linux 中的 bash shell 脚本递归地重命名文件中的所有目录、文件和文本 - How to rename all directories , files and text in the files recursively using bash shell script in linux bash shell:如何重命名文件 - bash shell: how to rename files 如何检测bash shell命令后面是否为逻辑&& AND或|| 要么? - How to detect if bash shell command is followed by a logical && AND or || OR? 如何在Bash / Shell中检测GUI的可用性? - How to detect availability of GUI in Bash/Shell? 重命名文件并删除Shell PID作为扩展 - rename files and remove shell PID as extention 如何在 Linux Bash(shell 脚本)中用名称中的时间戳替换备份文件而不产生重复文件 - How to replace backup file with timestamp in its name without producing duplicates in Linux Bash (shell script) 如何使用linux bash shell工具在服务器上搜索文件名列表 - How to search for a list of file name on the server using linux bash shell tool
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM