BrianDMG / conv2mp4

This Powershell script will recursively search through a user-defined file path and convert all videos of user-specified file types to MP4 with H264 video and AAC audio using ffmpeg. The purpose of this script is to reduce transcoding CPU load on a media server like Plex or Emby and increase video compatibility across platforms.
129 stars 23 forks source link

Spaces Not Handled in FFmpeg Path #70

Closed Polychronopolis closed 4 years ago

Polychronopolis commented 4 years ago

Apologies as I'm not very familiar with GitHub etiquette. I have found a bug and can suggest code modification but couldn't seem to figure out how to start a pull request.

It appears that spaces are not properly handed in the FFmpeg path variable. In digging through the code, spaces in the Handbrake path are properly handled.

My FFmpeg path is set to C:\Program Files (x86)\VideoProc

At line 39 in Get-Codec.ps1, this code will fail: $ffprobeCMD = cmd.exe /c "$ffprobe $ffprobeArgs"

The error indicates a problem with incorrect path quoting . cmd.exe : 'C:\Program' is not recognized as an internal or external command,

Updating the code to this allows the path to be properly quoted: $ffprobeCMD = cmd.exe /c ""$ffprobe" $ffprobeArgs"

Line 120 in ConvertFile.ps1 should be updated to $ffCMD = cmd.exe /c ""$ffmpeg" $ffArgs"

Line 14 in GetAudioStreams.ps1 should be updated to

[int[]] $audioStreamArray = cmd.exe /c ""$ffprobe" $ffprobeArgs"

The post is stripping out the escape characters, but quoting the reply will show their placement...

BrianDMG commented 4 years ago

Hey, thanks for pointing this out, I appreciate you bringing it to my attention! I had already escaped for handbrake failover, so it was an oversight on my part. In the future, feel free to create a PR with the suggested changes if you like, happy to merge it and have you show as a project contributor.