0

I found this extremely helpful batch script for Powershell (.ps1) file which I listed below:

$originalVids = Get-ChildItem *.ts -Recurse

foreach ($inputVid in $originalVids) {
    $outputVid = [io.path]::ChangeExtension($inputVid.FullName, '.mp4')
    ffmpeg.exe -i $inputVid.FullName -c:v libx264 -crf 18 -c:a aac -map_metadata 0 $outputVid
}

The thing I like the most about this script is that on the top line, you can change the *.ts to any video format you want (I've tested it with .avi, .mkv., .ts, and .wmv). The same is true about the output also, which in the above example is .mp4. Also, the script can be run from any folder, just drop the .ps1 file into the folder, right-click it and select Run With PowerShell.

  • My first question is how could I change it to specify an output folder?
  • Also, how could I do the same for the origin file (specify a folder for the original file after the conversion is completed)?
  • My last question is, how might this be able to be altered to convert a video file into images?
  • But more specifically a GIF?

I want it all to be able to be done as a batch, so it can do multiple files at once, preferably keeping it's name.

2
  • These are 2 really unrelated questions. One is about powershell scripting: how to give it source and destination folders arguments, and how to modify variables (eg. to keep the file name but change the extension) etc. The other question seems to be about how to convert video to .gif images. You should probably keep only that second question here, with more specific details. And for the PS scripting question, you could try superuser.com or stackoverflow.com.
    – mivk
    Mar 13 at 19:31
  • Ok, I'll try to get around to it soon, and I apologize for posting things in the incorrect places, I just assumed they were close enough together and tried to kill two birds with one stone. I'm just really bad when it comes to programming, languages, and honestly, screwing things up, sometimes pretty badly. Mar 18 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.