Tag Archives: Scripting

Extracting audio from a video file (mpg/mpeg)

So you have a video file, such as an mpg/mpeg file. You would like to extract the audio from it without making any changes. Video containers usually hold the video and audio file separately so lossless conversion is possible.

Depending on your video container format, the method would be different, but for mpg/mpeg you can simply download ffmpeg (BtbN/FFmpeg-Builds) and extract it to your C drive (or your preferred location), name the folder ffmpeg and start Command Prompt (see below)

Type “cmd” after pressing the Windows start menu.

Once you launch Command Prompt, you will need to head to the folder that you created and extracted the downloaded files. Type “cd C:\ffmpeg”. For convenience, move your video file to the same folder and execute the command below.

ffmpeg -i "1.mpeg" -vn -acodec copy "1.wav

What you’re telling ffmpeg to do is look for the file “1.mpeg” within the folder (rename this to your file name), then extract the audio, creating the file “1.wav” (or you could change it to “1.mp3”). Once done you should see the newly created file in the same folder.

All done!

For more advanced people, if you know what you’re doing you can do this without moving any files around.

Links

https://streamshark.io/blog/understanding-codecs-and-formats/

https://en.wikipedia.org/wiki/Comparison_of_video_container_formats

Android; Long press volume buttons to change tracks.

It’s very odd that Android does not have this simple feature installed on its OS. Nevertheless we can still do it ourselves until they come around by using a simple application someone (Cilenco) has kindly developed.

The Link

If you know what you’re doing then here’s the link.

If you’re not sure, continue reading. It’s not hard, but it’s not as simple as install and go. You’ll first need to do a few things.

Step 1

Download the application installer here. Once you install it will ask you to run a command line on adb (Android Debug Bridge). Before you can successfully execute the command, you’ll need to enable developer and debugging modes on your device. Your device needs to be connected to your USB for this entire process. You can transfer over the application installer this way anyway.

Step 2

On your computer, download Android Studio here. You can either download the whole package or simply download the platform-tools to use adb. You’ll only need adb, but I had trouble finding it so I downloaded the entire thing and via the configuration went to SDK Manager > SDK Tools installed the package.

Android Studio SKD Manager, SK Tools.

Step 3

If you managed to install platform-tools one way or another. Press start and type “cmd”, which should auto search for Command Prompt. Run it.

You will need to navigate to the folder, so type “cd <location of platform-tools folder>”. If like me you installed on a different drive, you will need to type “d:” or whatever drive letter your folder is at. Then the cd part above.

Next you’ll want to test the connection to your device. Type:

adb devices

If you see a device in the list then you’re good to go with executing the final command.

adb shell pm grant com.cilenco.skiptrack android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER

Start the application on your phone and you’re done. Follow any necessary permission steps on the app.

If you did not see your device in the list, you’ll need to track back and make sure you’ve enabled developer mode, USB debugging mode and your computer sees your phone. Install USB/device drivers if necessary.

Links

https://forum.xda-developers.com/android/apps-games/app-skip-track-volume-keys-t3914337/

https://developer.android.com/studio#downloads

https://github.com/Cilenco/skipTrackLongPressVolume/releases

https://www.howtogeek.com/125769/how-to-install-and-use-abd-the-android-debug-bridge-utility/

Using Symbolic Link’s to connect to a shared Blu-Ray/DVD drive within your network

If you have a Blu-Ray drive on a device within your network and you’d like to be able to play your disks on say your other PC or laptop, you don’t necessarily need to go out and buy another Blu-Ray drive.

The very first thing that needs to be done is to share your Blu-Ray/DVD drive across your network. This step will obviously be different depending on your operating system.

On Windows 10 for example (on the device that has the drive), go to ‘This PC’, right click on the drive and go to “Give access to” then to “Advanced sharing…” Hit “Advanced Sharing…” button, tick the box “Share this folder”, give it a name. This essentially shares your drive to the network, without this the other devices won’t have access.

The next step is to map the drive or you can skip this and just go right to creating the Symbolic Link.

If you did map the drive, you might get a permission issue and instead of fiddling around with permissions I added a password to the Windows account (of the system with the drive) and used those credentials to gain access. If you already use a password, great, but if you don’t prefer to use one, you’ll need to configure the permissions to allow this.

Here’s the Symbolic Link I used. You will need to execute this in the Command Prompt (elevated or it will not allow you to create it):

mklink /D "C:\Blu-ray Drive" "\\NETWORKNAME\d"

To explain a little, the first quotes is the location to where I want to create the link, the second quote is where the link will point to. You can type “mlink” within the console to get a list and more understanding of Symbolic Links. The idea is that your media player believes it’s simply playing from a folder in C drive.

Read more about Symbolic Links here from Microsoft.

Another way that seemed to work was to use the VCL Media Player to play directly from the mapped drive. Run using \E:/ (Change the drive letter to yours).

You can use that to run it from VLC Media Player.

Pro’s and Con’s?

Pro’s and con’s are pretty basic so far, however the pro is you don’t need to splash out on a blu-ray drive just to watch something else-where, the con is that you’ll have to run the device in which the blu-ray is on even if you’re not using it. A restart or disruption to the network and you’re disconnected, of course.

Creating Symbolic Links

I’ve been meaning to create a post about symbolic links and how to set them up, the benefits of them, pros and cons, however I’ve not had the time and I might just come back to this post one day, however it’s been a while and I think it’s worth just starting and leaving it where it is.

I sometimes reformat my Windows drive or as you do, upgrade to say another drive. Backing up your files is one thing, but have you ever thought, what about just using scripts to run once you re-install everything to point to the files so it’s almost plug and play?

So for example, in this situation we have the Steam userdata folder that resides in the Program Files within the C drive. Setting up a symbolic link to then automatically have that folder divert to a location on say a Steam dedicated drive, would mean no need to ever do large copies, but to just run the script after a reformat and you’re good to go. Especially handy when you forget to make a back up and reformat your Windows anyway!

This also comes in handy when the times your drive fails, however that doesn’t mean the drive you’re creating the link to doesn’t fail, make sure you have a plan for that.

Anyway, here’s the way to do it:

Step 1, run command prompt)

Start Command Prompt. Press start, type “command prompt”, right click on it and run as the administrator.

Step 2, copy paste your symbolic link)

You can just type “mklink” to get a list of details on what each parameter does. In this case we’re going to link one folder to another.

mklink /J “C:\Program Files (x86)\Steam\userdata” “D:\Steamuserdata”

And that’s it, we’re done.

I did a quick Google search to find more details on it, Microsoft have a page on symbolic links, you can find that here.

Uplay likes to save your screenshots to C:\Users\xxxxx\Pictures\Uplay another idea would be to divert those to your preferred location.

Combine PDF files with a context menu option

I needed a way to quickly combine two or more PDF files without having to run a program or click mutiple times. This solution basically allows you to right click and automatically combine your PDF files then delete them once it’s finished combining.

First download a program called pdftk, once installed head over to where you actually installed it, copy two files; “pdftk.exe” and “libiconv2.dll” to a new folder (preferably where you will not accidently delete it).

Create a new text file and rename it to “PDF Combine.cmd”, edit the batch file and copy paste the below code:

@echo off
setlocal enabledelayedexpansion

for /f “tokens=2 delims==+-” %%i in (‘WMIC OS Get LocalDateTime /value ^| findstr “=”‘) do (
set _Date=%%i
set YY=!_Date:~2,2!
set MM=!_Date:~4,2!
set DD=!_Date:~6,2!
set HH=!_Date:~8,2!
set MIN=!_Date:~10,2!
set SS=!_Date:~12,2!
)
set today=20%YY%-%MM%-%DD%-%HH%%MIN%%SS%

FOR %%A IN (%*) DO (set command=!command! %%A)
D:\pdftk\pdftk.exe %command% cat output “%~dp1CombinedScan_%today%.pdf”

del %command%

The output file names for mine is “CombinedScan_DATE&TIME.pdf”. Make relavent changes preffered to you and save.

Now we want to set up the context menu for it so you can right click on files.

  1. Right click on your “PDF Combine.cmd” file, create a shortcut.
  2. Press your Windows key + R to bring up your run dialog. Type “shell:sendto”, which should open up your Windows SendTo folder. Move your shortcut you just created to this folder and feel free to rename your shortcut to whatever you prefer, I personally named it “Combine PDF’s”.

Now go ahead and test your automated method out. I recommend you use some spare PDF’s that are backups just in case you did something wrong. If you prefer to just skip downloading and copying the files, I’ve done that already and made a zip folder for you below.

Download pdftk.

How to fast switch between resolutions using a batch file.

Here’s a quick way to switch between Windows desktop resolutions using a batch file and an executable file. I needed to do this in order to have a better overview in the game Age of Empires HD (on Steam). Let me visually show you what I mean. Have a look at the screenshots below, you can clearly see a more broader view as you up the resolution.

For some reason the viewing distance is different to the one in the original game.. A few years ago I tested to see if there is a difference in resolution compared to the old Age of Empires and there is so they have in fact made your viewing distance closer. As someone who’s played Age of Empires for a long time this was a problem for me. Now in the original you could change your resolution so simply enabling DSR Factor via your graphics control panel and changing the resolution in-game could resolve this issue for me, in this version the ability is not there (I assume poor development). Anyway, you will first need to enable DSR Factor, I currently prefer x1.75 as shown below.

Then you’ll need to download the file below. Tweak the resolution settings for what you prefer and run the game. If you have the option you can play around with the smoothing, essentially it’s anti-aliasing between the pixels so it doesn’t look pixelated due to the difference of your monitors resolution capability and what’s being scaled.

Now I was under the impression that a batch file can’t actually do this (on its own), I still think this is the case, but with simple help from a file you can still achieve it. The benefits of this way is you can change your preferred resolutions and simply run the batch file with as less clicking as possible, while an executable would require a bit of extra clicks.

At the time I could not find the source code for QRes (and I downloaded it from a separate site) so I did a virus scan on it – here’s the result. Secondly I used Sandboxie and launched the file in a sandboxed environment and looked at what – if any – files were executed along with it.. It left zero trace and the file size also indicates to me it’s pretty simple.

Now here comes the actual batch file.

QRes.exe /X 1920 /Y 1080

Yup, that’s it. So in the folder there is the ‘QRes.exe’ file, then there’s ‘RC 1920×1080.bat’ and ‘RC 2560×1440.bat’ files which I run to switch between the resolutions. All these files must be in the same folder for it to work and by the size of the QRes.exe file it looks to just simply run based on the resolution that’s provided in the batch.

Download Resolution Changer version 1.0 here.

 

RMS syntax support for Notepad++ (UDL)

So I wrote a guide on Steam on syntax colouring for Random Map Scripting for Notepad++, the scripting language to write random maps on Age of Empires. Essentially Notepad++ supports language syntax support, allowing you to make syntax easier on the eye.

So you’re writing a random map script, using standard default Notepad (that comes with Windows), it would look like this:
notepad

With Notepad++ and syntax colouring (User Defined Language Files) enabled, it will look like this:
notepad++

So you get the drift, basically giving you a clearer visual on your code and possibly preventing errors in them as well.

You can see the guide here:
http://steamcommunity.com/sharedfiles/filedetails/?id=439948511