Being the good Windows systems admin that I am, I'm finally getting around to learning PowerShell. With that being said, I have no idea what I'm doing (surprise, surprise).
I thought that it would be a good learning experience for me to play around with PowerShell at home, far away from my production environment. Recently, I've begun using FFMPEG to convert all of my .mkv files to .mp4 so I could have better playback support to my PlayStation 3 via Plex, and thought that this would be a good learning experience.
The command I've been running is as follows:
ffmpeg -i OldVideoName.mkv -vcodec copy -acodec ac3 OldVideoName.mp4
What I want is have a PowerShell script that will run once, scanning a folder and all sub-folders for .mkv files (Get-ChildItem ".*.mkv"), transcode them to .mp4 via the above command, and place them in the same location as the .mkv with the same naming scheme.
Example of running the script with D:\Videos as the target directory:
D:\Videos\home_dvr\movies\video1.mkv --> D:\Videos\home_dvr\video1.mp4 D:\Videos\home_dvr\tv\video2.mkv --> D:\Videos\home_dvr\tv\video2.mp4
As you can guess, I can't figure it out for the life of me. Here's the latest attempt before giving up.
$oldvid = Get-ChildItem .\*.mkv -Recurse
$newvid = $oldvid.Name.split(‘.’)[0]; ForEach-Object {
.\ffmpeg.exe -i $oldvid -y -vcodec copy -acodec ac3 $newvid".mp4”
}
Any help would be appreciated!