As a technician, many videos stored on the computer hard disk are tutorials and videos, not movies.
These long-term video files will be of great help to us if they can be compressed effectively.
I usually use the pill toolbox for compression. This is currently recognized as the best compression software.
Baidu online disk link: https://pan.baidu.com/s/1dRGMXBsKUGZ2tFlT0ZnJ7Q Extraction code: 6666
The functions of this software are:
1. Use software function 1 to scan all video files in a partition of the computer and copy them into one folder.
2. The user manually uses the pill toolbox for compression.
3. Use software function 2 to replace the video file.
Description: small pill toolbox can be used for batch pressing of multiple videos. Suppress coding, I usually choose x264_32_8bit, the default CRF parameter is 23 or 23.5.
Background: he returned from Mali in Africa last week and is now isolated in Shanghai. After reading the python tutorial, I wrote this very practical program for me, the first Python program.
Source code
There are many sub functions in the source code, and some are relatively simple. Not one by one.
Resources in: https://download.csdn.net/download/puff1987/22319079?spm=1001.2014.3001.5503
Project ideas
- Using the function 1 of this software, the user selects to copy the qualified videos of disk E to the specified folder.
- The user manually starts the "pill toolbox" to convert the video.
- The user continues to use the function 2 of the software and selects to replace the converted video with the original video.
I used this software to convert 480 videos in E disk, with a total video size of about 80G.
Function 1: copy
When the user selects function 1, the path will be entered to realize replication.
if __name__ == '__main__': MessageFilePath = 'CopyMessage.xlsx' postfix = '_batch.mp4' # Suffix NOUN ChoiceNum=ChoiceNumFunction() #ChoiceNum =2 #When testing, it is convenient. if ChoiceNum==1: source_dir, target_dir = ChoiceDirFunction() #source_dir='E: / internal training materials of the company / explanation of ultrasonic sensor on January 18, 2016 ' #target_dir='E: / do not use hidden dragons' Filelist = getAllSub(source_dir) FileListResult = [] FileListResult=JudgeFile(Filelist) CopyMessage = Configuration(FileListResult,target_dir) xw_toExcel(CopyMessage, MessageFilePath) print('**********') print(CopyMessage) print('**********') i=1 for MessageRow in CopyMessage: Num=mycopy(MessageRow[0],MessageRow[1]) if not Num: print('Copy of this file failed',MessageRow[0],MessageRow[1]) print('Current replication progress is{0}/{1}'.format(str(i),str(len(CopyMessage)))) i+=1
Function 2: replace
When the user selects function 2, video file replacement will be realized.
elif ChoiceNum==2: print('\n Before replacing the compressed video with the original path video, you can CopyMessage.xlsx Configure the third column in the file and choose not to replace some files.\n') ti=str(input('Do you want to start replacing files? y/n =')) if ti=='y': ReadMessage = [] ReadMessage = ReadCopyMessage(MessageFilePath) ExM=ExtendMessage(ReadMessage) i=1 print('\n') for MessageRow in ExM: #print(i,'------',MessageRow) if MessageRow[2]>0: #Enable switch Num=mycopy(MessageRow[4],MessageRow[5]) if not Num: print('Copy of this file failed',MessageRow[4],MessageRow[5]) else: ExM[i-1][3]=True if os.path.exists(MessageRow[5])&os.path.exists(MessageRow[0]): #After confirming that the copy is successful, delete the original video file. DelFile(MessageRow[0]) #print('deleted: ', MessageRow[0]) else: pass print('****Current replication progress is{0}/{1}\t\t The destination path is:{2}'.format(str(i), str(len(ExM)),MessageRow[5])) i += 1 '''if i >= 1: # For testing. Run only a few files for testing. #print(MessageRow) break''' xw_toExcel(ExM, MessageFilePath) print('\n\t The replacement work has been completed.\n\t You can',MessageFilePath,'Table file viewing conversion results') PathTar,File2=os.path.split(ExM[0][1]) print('\t You can delete it manually',PathTar,'All files in the folder.')