代码中的文件名除了以h_开头的文件以h_00、 h_100、h_200、 h_400、 h_900开头的文件名都从第二个英文开始截取import osimport globfrom natsort import natsorteddir_path = rEhomeupoutput_dir = rEhomeup1# 当前文件夹下的所有mp4路径L = for root dirs files in o
This code reads all the mp4 files in a directory and concatenates them into a single mp4 file using the ffmpeg command. The resulting mp4 file is then renamed based on certain rules.
The code first reads all the mp4 files in the specified directory using os.walk and natsorted to sort the file names in a natural order. It then generates ffmpeg commands to convert each mp4 file into a ts file using the -bsf:v h264_mp4toannexb option. These ts files are then concatenated into a single mp4 file using the ffmpeg -i "concat:" option. The resulting mp4 file is saved in the output directory with a new name.
Lastly, the code renames the resulting mp4 file according to certain rules. Files starting with 'h_' are renamed by removing the first character, and files starting with 'h_00', 'h_100', 'h_200', 'h_400', 'h_900' are renamed by removing the first two characters. The new name is then truncated to the last English letter before the file extension
原文地址: https://www.cveoy.top/t/topic/ddzO 著作权归作者所有。请勿转载和采集!