<p>I found <a href="https://www.junian.net/tech/powershell-ffmpeg-batch/" rel="nofollow noreferrer">this</a> extremely helpful batch script for Powershell (.ps1) file which I listed below:</p>
<pre><code>$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
}
</code></pre>
<p>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.</p>
<ul>
<li>My first question is how could I change it to specify an output
folder?</li>
<li>Also, how could I do the same for the origin file (specify a folder for the original file after the conversion is completed)?</li>
<li>My last question is, how might this be able to be altered to convert a video file into images?</li>
<li>But more specifically a GIF?</li>
</ul>
<p>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.</p>

CC BY-SA 4.0
2022-03-13T19:31:40.057Z
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 https://superuser.com or https://stackoverflow.com.
mivk
CC BY-SA 4.0
2022-03-18T10:37:21.587Z
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.
EngineerJack
<ffmpeg>
Using ffmpeg to batch convert between different video formats, AND image formats
EngineerJack
# Using ffmpeg to batch convert between different video formats, AND image formats

(Asked by: username_0 on 2022-03-12)

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.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: 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 https://superuser.com or https://stackoverflow.com.  
> **username_0**: 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.  

---

## 0 answers

