Transcode a video using a context menu on Windows
July 29, 2020โข221 words
Transcode a video using a context menu on Windows
#windows
I'm using the game bar to create quick screencasts. The only problem is that the videos are too big to show only a few clicks. So, to quickly optimize a video for sharing I need to transcode it as easy as possible.
Updated with a new windows native tool.
Creating a context menu in explorer would be ideal. This menu action will execute VLC to transcode the video.
I'm using this tool to easily create a context menu:
The paths need to be adjusted we're on Windows and VLC is a ported application. So I wrote a script to handle that (in PHP because I have it installed it and I don't know anything about PowerShell):
if (!isset($argv[1])) {
echo "Usage: {$argv[0]} <video>";
die;
}
$path = $argv[1];
$path = str_replace('\\', '/', $path);
$path = preg_replace('/^C:/', '', $path);
$cmd = <<<CMD
"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe" "-I dummy" "%s" ":sout=#transcode{vcodec=h264,scale=Automรกtico,width=720,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:std{access=file{no-overwrite},mux=mp4,dst='%s-small.mp4'}" "vlc://quit"
CMD;
$cmd = sprintf($cmd, $argv[1], $path);
system($cmd);
To actually create the menu entry that runs the php script, run:
FileActionsConsole.exe add mp4 compress_video "Compress Video (720p)" "\"C:\tools\php74\php.exe\" \"/Users/user/bin/compress-video.php\" \"%1\
""
Update (2020-08-26): I had to wipe my windows partition and decided to write a native tool to implement this. You can find it here.