Since Automating all the VMworld Session Download for 2014 Breakout sessions is not an option, I manually downloaded them. I extracted the zip folder, and found the mp4 file. I loaded it into iTunes. It doesn't play natively on iphone because it is not in the right mp4 format. So I went and converted it from it's native non-itunes compatible format to a compatible itunes format, and finally, my video plays.
Is it possible in powershell to:
Iterate through a folder with a group of downloaded session zip files.
unzip the file.
find the mp4 file
Perform the following actions on the file to make it iphone video capable: (equivalent to "create an iphone version" in itunes)
-convert video format from 1280x720 to 640x360
-convert bit rate from 576 kbps to 595kbps
-change the filename of the video so that it is replaced with the session title with underscores between words followed by .mp4
create a new folder which has only the finished, iphone ready mp4 files sorted by filename
I used a similar simple script to iterathe through a movies direcotory and convert all the ISO files to x264. Here is a little example, I changed it a bit to your requirements, not sure if it works out of the box, because I don't have handbrake installed at work. But this will get you going, there is less error handling, and I don't have information about how the zip files are build up or how to retrieve the session information. Maybe you could give us a clue about that
Download Handbrake
https://handbrake.fr/downloads.php
So we can use the handbrake CLI to convert movies
https://trac.handbrake.fr/wiki/CLIGuide
Use these options as you require in your post.
-f or --format: forces a particular container file format. Your choices are mp4 and mkv. If this is omitted, it will try to figure out the format from the output filename
-b or --vb: allows you to set an average output video bitrate in kilobits per second. Do not use this if you wish to maintain a particular quality across your encodes. Be aware that for video encoders, 1 megabit is equal to 1000 kilobits, not 1024 kilobits
-w or --width: Enter your desired output width here in pixels. The default is 720 for widescreen, 640 for fullscreen. If you do not specify a height as well, it will calculate one that will preserve the film's aspect ratio.
-l or --height: Enter your desired output height here in pixels. If you do not specify a width as well, it will calculate one that will preserve the film's aspect ratio. The default behavior is to use a height that preserves the film's aspect ratio, given the width. If you specify neither -w nor -l, by default your output will be approximately 720*400 for 1.78:1, 720*386 for 1.85:1, 720*304 for 2.35:1, and 640*480 for 1.33:1.
$Root = "D:\sessions\Zip" #Set input location
$Handbrakepath = "D:\sessions\Handbrake" #Set handbrake location
$Output = "D:\sessions\Zip" #Set destination location
$Temp = $Output+"\tmp"
Set-Location $Handbrakepath
$ZipProcess = gci $Root -Recurse |where {$_.name -like "*.Zip"}|select fullname #Building array to process zip files
#Function to extract zip file
function Extract-Zip
{
param([string]$zipfilename, [string] $destination)
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}
if (!(Test-Path $Output)){mkdir $output} #Check if output directory exists, else create it
foreach ($Zipfile in $ZipProcess){
if (!(Test-Path $Temp)){mkdir $Temp} #Check if output directory exists, else create it for processing tmp
Extract-Zip $Zipfile.FullName $Temp #Extract zip files
}
$ArrProcess = gci $Temp -Recurse |where {$_.name -like "*.iso"}|select fullname #Building array to process
foreach ($Movie in $ArrProcess){
$outputdir = (($Movie.FullName).split(".")[0])+".mkv"
if (!(Test-Path $outputdir)){
& ".\HandBrakeCLI.exe" -i $Movie.fullname -o + $Output + -f mp4 -b 595 -w 640 -l 360
}
}
#Remove tmp processing folder
Remove-Item $Temp -Confirm:$False -Recurse
This is great. I'm attempting to start working with it.
first question:
How do I determine what the $handbrakepath variable should be?
Also on this line:
$outputdir = (($Movie.FullName).split(".")[0])+".mkv"
should the .mkv extension be .mp4 if I am trying to create .mp4 files?
Also on this line:
$ArrProcess = gci $Temp -Recurse |where {$_.name -like "*.iso"
Should I be looking for .iso files? Is that a leftover from another use case where I need to change the extension to .mp4?