Advertisement
Guest User

Untitled

a guest
Dec 13th, 2024
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. # Set the input file path from the first argument
  2. param (
  3. [string]$input_file
  4. )
  5.  
  6. # Override input file location
  7. # $input_file = "C:\your\override\here"
  8.  
  9. # Get the directory of the input file
  10. $inputFileDirectory = Split-Path -Path $input_file -Parent
  11.  
  12. # Define the debug log path in the same directory as the input file
  13. $debugLog = Join-Path -Path $inputFileDirectory -ChildPath "stacherPost_log.txt"
  14.  
  15. # Debugging step: Log the input file path
  16. "Input file: $input_file" | Out-File -FilePath $debugLog -Append
  17.  
  18. # Run ffprobe to detect codec and log output
  19. "Running ffprobe..." | Out-File -FilePath $debugLog -Append
  20. $ffprobeOutput = & ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of csv=p=0 $input_file
  21.  
  22. # Extract codec information from ffprobe
  23. $codec = $ffprobeOutput.Trim()
  24.  
  25. # Log the codec detected
  26. "Detected codec: $codec" | Out-File -FilePath $debugLog -Append
  27.  
  28. # If codec is empty or not detected properly, log it and exit
  29. if (-not $codec) {
  30. "Failed to detect codec or ffprobe error." | Out-File -FilePath $debugLog -Append
  31. exit 1
  32. }
  33.  
  34. # Check codec and process if VP9 or AV1. Alter ffmpeg command here if you wish to encode differently.
  35. if ($codec -ieq "vp9" -or $codec -ieq "av1") {
  36. "Codec is $codec. Proceeding with conversion..." | Out-File -FilePath $debugLog -Append
  37. & ffmpeg -hide_banner -threads 0 -hwaccel auto -i $input_file -c:v hevc_nvenc -b_ref_mode 0 -b:v 24000k -profile:v main -level 6.1 -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -sws_flags bicubic -tag:v hvc1 -y "$($input_file.Substring(0, $input_file.LastIndexOf('.')))_converted.mp4"
  38. } else {
  39. "Codec is $codec. Conversion not needed." | Out-File -FilePath $debugLog -Append
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement