Friday, November 17, 2017

How to rotate a video without re-encoding

Summary: A few tips on video rotation.
If your phone messes up the rotation metadata flag in a video file, download ffmpeg and run the following command:
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=0 output.mp4
This should fix the problem without re-encoding the video. If it does not, try setting the rotate switch to a different number, such as 90, 180, or 270. For additional information about video orientation MP4 and other video files, check the See also section.

See also:
iPhone recorded videos getting rotated on Windows systems
Rotate a MP4 file, while preserving codec and quality attributes
Rotate mp4 videos without re-encoding
Rotating videos with FFmpeg
How to rotate a video 180° with FFmpeg?

How to fix slow startup for old Photoshop/Premiere Elements apps (on Windows)

Summary: Easy way to fix slow startup issues for older versions of Adobe products (on Windows).
If you have an older version of Adobe video and photo editing products, such as Photoshop Elements or Premiere Elements, you may be irritated with the long startup time, which could take several minutes. Apparently, the applications try to connect to a server that is no longer in service (btw, excellent job, Adobe!), so they wait... and wait... and wait... The good thing is that there seems to be an easy fix for this.

According to the answer to this post, you just need to add the following entry to your hosts file located in the %WINDIR%\System32\Drivers\Etc folder:
127.0.0.1   static.photoshop.com
This solved the problem form my Photoshop Elements 9 and Premiere Elements 13 instances running on Windows 7 (yeah, I know, need to upgrade to Windows 10, but that's a different story).

Enjoy!

Friday, October 20, 2017

Save STDOUT/STDERR to clipboard (and more)

Summary: How to redirect the STDOUT or STDERR stream to clipboard.
Note to self (mostly), in case I forget the command that would redirect standard output or standard error stream and save it on the clipboard.

Redirect STDOUT to clipboard:
command | clip
Redirect STDERR to clipboard:
command 2>&1 | clip
The following will save the contents of the current directory to the clipboard:
dir | clip
Now, let's try the following:
dir xyz: | clip
The clipboard now will hold something like this:
 Volume in drive C is SYSTEM
 Volume Serial Number is 1234-ABCD

 Directory of C:\Windows\SysWOW64
Now, let's redirect STDERR to clipboard:
dir xyz:2>&1 | clip
The clipboard now will hold something like this:
"xyz:" is not a recognized device.
"xyz:" is not a recognized device.
 Volume in drive C is SYSTEM
 Volume Serial Number is 1234-ABCD

 Directory of C:\Windows\SysWOW64

File Not Found
See also:
Forgotten (but Awesome) Windows Command Prompt Features by Scott Hanselman
How to pipe stderr, and not stdout?

Tuesday, August 22, 2017

How to clean up BIN and OBJ folders in a Visual Studio solution

Summary: Some ideas on cleaning up intermediate and output folders in Visual Studio projects.
There may be better (and more elegant) ways of cleaning up the output (BIN) and intermediate (OBJ) folders generated by Visual Studio build process, but the following script is probably the easiest option you can use:

@echo off
rem Delete BIN and OBJ folders from the immediate folder and all subfolders.
rem

rem Switch to the script folder.
cd "%~dp0"

rem Use the following to suppress the 'File Not Found' message if no folders are found.
setlocal enabledelayedexpansion 
for /f "tokens=*" %%G in ('dir /B /AD /S bin 2^>nul') do rmdir /S /Q "%%G"
for /f "tokens=*" %%G in ('dir /B /AD /S obj 2^>nul') do rmdir /S /Q "%%G"

Notice that the script call setlocal enabledelayedexpansion to allow the 2^>nul redirection in the for loops (without it, it would output the "File Not Found" message if the folder and subfolders do not hold the "BIN" or "OBJ" folders.

See also:
How to clean Visual Studio bin and obj folders
I want to delete all bin and obj folders to force all projects to rebuild everything
Want to suppress File not found output
Suppress command line output