PowerShell script ffmpeg -


being windows systems admin am, i'm getting around learning powershell. being said, have no idea i'm doing (surprise, surprise).

i thought learning experience me play around powershell @ home, far away production environment. recently, i've begun using ffmpeg convert of .mkv files .mp4 have better playback support playstation 3 via plex, , thought learning experience.

the command i've been running follows:

ffmpeg -i oldvideoname.mkv -vcodec copy -acodec ac3 oldvideoname.mp4 

what want have powershell script run once, scanning folder , sub-folders .mkv files (get-childitem ".*.mkv"), transcode them .mp4 via above command, , place them in same location .mkv same naming scheme.

example of running script d:\videos 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 can guess, can't figure out life of me. here's 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 appreciated!

try this:

$oldvids = get-childitem *.mkv -recurse foreach ($oldvid in $oldvids) {     $newvid = [io.path]::changeextension($oldvid.fullname, '.mp4')     .\ffmpeg.exe -i $oldvid.fullname -y -vcodec copy -acodec ac3 $newvid } 

$oldvid .net fileinfo object , when needs converted string, can filename , not whole path. won't work files not in current dir. use fullname property full path.


Popular posts from this blog

java - Cannot send AES encrypted messages of over 47 characters -

php - Error using Mockery/phpUnit in Laravel -