diff --git a/.gitignore b/.gitignore index 8a7c3c6..9e3eb41 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ /cache/ *.log __pycache__ -ffmpeg.exe -.vscode/ \ No newline at end of file +ffmpeg.exe \ No newline at end of file diff --git a/HLSDownloader.exe b/HLSDownloader.exe new file mode 100644 index 0000000..3edebfe --- /dev/null +++ b/HLSDownloader.exe Binary files differ diff --git a/m3u8dl-windows-amd64.exe b/m3u8dl-windows-amd64.exe new file mode 100644 index 0000000..4b290fa --- /dev/null +++ b/m3u8dl-windows-amd64.exe Binary files differ diff --git a/manual command.txt b/manual command.txt new file mode 100644 index 0000000..ec0a6d4 --- /dev/null +++ b/manual command.txt @@ -0,0 +1 @@ +ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i "input.ts" -c:v hevc_nvenc -cq 28 -surfaces 64 -bufsize 12800k -r 7.5 -rc-lookahead 63 -c:a aac -ac 1 -rematrix_maxval 1.0 -b:a 64k "output.ts" -n -hide_banner -loglevel warning -stats \ No newline at end of file diff --git a/manual-video_proc.bat b/manual-video_proc.bat new file mode 100644 index 0000000..4661c6d --- /dev/null +++ b/manual-video_proc.bat @@ -0,0 +1,63 @@ +@echo off +setlocal enabledelayedexpansion + +:: Set the input and output folders +set "input_folder=C:\Users\YLW-LAPTOP\Downloads\Video" +set "output_folder=C:\Users\YLW-LAPTOP\Downloads\video\Output" + +:: Ensure the output folder exists +if not exist "%output_folder%" ( + mkdir "%output_folder%" +) + +:: Change to the input folder +cd /d "%input_folder%" + +:: Initialize variables +set "current_group=" +set "concat_file=" + +:: Loop through all files with the .mp4 extension in the input folder +for %%F in (*.mp4) do ( + :: Extract the group prefix from the filename (e.g., 1 from 1-1.mp4) + for /f "tokens=1 delims=-" %%G in ("%%F") do ( + set "group_prefix=%%G" + + :: Check if we're still in the same group + if not "!group_prefix!"=="!current_group!" ( + :: If a previous group exists, process it + if defined current_group ( + :: Run ffmpeg with CUDA on the current group + ffmpeg -f concat -safe 0 -i "!concat_file!" ^ + -c:v hevc_nvenc -cq 28 -surfaces 64 -bufsize 12800k -r 7.5 -rc-lookahead 63 ^ + -c:a copy "%output_folder%\!current_group!_output.mp4" -n -hide_banner -loglevel warning -stats + + :: Clean up the temporary concat file + del "!concat_file!" + ) + + :: Start a new group and reset concat file + set "current_group=!group_prefix!" + set "concat_file=%output_folder%\!current_group!_concat.txt" + echo Creating concat file for group !current_group! + + :: Initialize the concat file for the new group + > "!concat_file!" echo file '%input_folder%\%%F' + ) else ( + :: Append the current file to the concat file + >> "!concat_file!" echo file '%input_folder%\%%F' + ) + ) +) + +:: Process the last group if needed +if defined current_group ( + ffmpeg -f concat -safe 0 -i "!concat_file!" ^ + -c:v hevc_nvenc -cq 28 -surfaces 64 -bufsize 12800k -r 7.5 -rc-lookahead 63 ^ + -c:a copy "%output_folder%\!current_group!_output.mp4" -n -hide_banner -loglevel warning -stats + del "!concat_file!" +) + +echo All videos processed! +endlocal +pause diff --git a/manual_process.bat b/manual_process.bat new file mode 100644 index 0000000..8a8749c --- /dev/null +++ b/manual_process.bat @@ -0,0 +1,64 @@ +@echo off +chcp 65001 +setlocal enabledelayedexpansion + +:: Set the input and output folders +set "input_folder=INPUT_FOLDER" +set "output_folder=OUTPUT_FOLDER" + +:: Ensure the output folder exists +if not exist "%output_folder%" ( + mkdir "%output_folder%" +) + +:: Change to the input folder +cd /d "%input_folder%" + +:: Initialize variables +set "current_group=" +set "concat_file=" + +:: Loop through all files with the .mp4 extension in the input folder +for %%F in (*.mp4) do ( + :: Extract the group prefix from the filename (e.g., 1 from 1-1.mp4) + for /f "tokens=1 delims=-" %%G in ("%%F") do ( + set "group_prefix=%%G" + + :: Check if we're still in the same group + if not "!group_prefix!"=="!current_group!" ( + :: If a previous group exists, process it + if defined current_group ( + :: Run ffmpeg with CUDA on the current group + ffmpeg -f concat -safe 0 -i "!concat_file!" ^ + -c:v hevc_nvenc -cq 28 -surfaces 64 -bufsize 12800k -r 7.5 -rc-lookahead 63 ^ + -c:a copy "%output_folder%\!current_group!_output.mp4" -n -hide_banner -loglevel warning -stats + + :: Clean up the temporary concat file + del "!concat_file!" + ) + + :: Start a new group and reset concat file + set "current_group=!group_prefix!" + set "concat_file=%output_folder%\!current_group!_concat.txt" + echo Creating concat file for group !current_group! + + :: Initialize the concat file for the new group + > "!concat_file!" echo file '%input_folder%\%%F' + ) else ( + :: Append the current file to the concat file + >> "!concat_file!" echo file '%input_folder%\%%F' + ) + ) +) + +:: Process the last group if needed +if defined current_group ( + ffmpeg -f concat -safe 0 -i "!concat_file!" ^ + -c:v hevc_nvenc -cq 28 -surfaces 64 -bufsize 12800k -r 7.5 -rc-lookahead 63 ^ + -c:a copy "%output_folder%\!current_group!_output.mp4" -n -hide_banner -loglevel warning -stats + del "!concat_file!" +) + +echo All videos processed! +endlocal +pause diff --git a/pdf_converter.py b/pdf_converter.py new file mode 100644 index 0000000..fe93608 --- /dev/null +++ b/pdf_converter.py @@ -0,0 +1,59 @@ +from PIL import Image +import os +import re + +def convert_images_to_pdf(folder_path): + # Iterate over each subfolder in the given folder + for subfolder in os.listdir(folder_path): + subfolder_path = os.path.join(folder_path, subfolder) + + # Only process directories (subfolders) + if os.path.isdir(subfolder_path): + print(f"Processing folder: {subfolder_path}") + + # Get all images in the subfolder (only .png, .jpg, .jpeg) + images = [] + for img in os.listdir(subfolder_path): + img_path = os.path.join(subfolder_path, img) + if img.lower().endswith(('.png', '.jpg', '.jpeg')): # Only consider image files + base_name = os.path.splitext(img)[0] # Get base name without extension + + # Check if a 'n-ans.*' file exists for the image 'n.*' + ans_image = f"{base_name}-ans{os.path.splitext(img)[1]}" + if ans_image in os.listdir(subfolder_path): + images.append(os.path.join(subfolder_path, ans_image)) + else: + images.append(img_path) + + if images: + # Sort images by numeric part of filename (ignoring '-ans' suffix) + images.sort(key=lambda x: int(re.match(r'(\d+)', os.path.splitext(os.path.basename(x))[0]).group(1))) + + # Open images and convert to PDF + image_list = [] + for img_path in images: + image = Image.open(img_path) + image = image.convert("RGB") # Convert to RGB for PDF compatibility + image_list.append(image) + + # Generate the PDF named after the subfolder + pdf_filename = f"{subfolder}.pdf" + output_pdf_path = os.path.join(folder_path, pdf_filename) + image_list[0].save( + output_pdf_path, + "PDF", + resolution=100.0, # High resolution + subsampling=0, + save_all=True, + append_images=image_list[1:] + ) + + print(f"Converted images in {subfolder} to PDF: {output_pdf_path}") + else: + print(f"No valid images found in folder: {subfolder_path}") + +# Set the folder path +folder_path = r"C:\Users\YLW-LAPTOP\Downloads\2021秋-写作与沟通-103-王沛楠" # Replace with the path to your folder + +# Convert images in subfolders to PDFs +convert_images_to_pdf(folder_path) diff --git a/vsd.exe b/vsd.exe new file mode 100644 index 0000000..17eb7d6 --- /dev/null +++ b/vsd.exe Binary files differ