12/01/2019

Importing video from a Sony HDR-XR150 Camcorder without using PMB

I have a Sony HDR-XR150 camcorder and up until recently the only way I had to get video off of the camera was using Sony's PMB (Picture Motion Browser).

PMB is fine if you are Joe Average but for me it was sometimes very slow to import video.

I found that the reason it was sometimes slow was that if your video was larger than 2 gigs the camera breaks the file up. When PMB imports it, it somehow knows this and it re-encodes the video to a single file instead of just copying the files over. This takes as long or longer than it took to shoot the video in the first place. I don't care if the files are split as I can re-join them in my editing software. I decided to write a batch file to copy the videos over from the camcorder, and to make it even more difficult I decided to keep the PMB name format. What a pain in the ass that was. You can just copy the .mts files over and rename them manually to m2ts.

If you want to use this method you will need:
a batch file in c:\windows called imp.bat
a batch file in c:\windows called impmts.bat
a folder called c:\temp
the camcorder when connected through USB connect as drive L:
The destination folder of Z:\videos\pmb

or you can edit the batch files to whatever drive letters and locations you use.

The contents of the IMP.BAT file is:
set startdrv=%cd:~0,2%
dir %1 | find /I "MTS" > c:\temp\x.x
set /P finfo=set stripped=%finfo:~0,17%
for /F "tokens=1-8 delims=::./ " %%A in ('echo %stripped%') do set FileDateTime=%%C%%A%%B%%D%%E
for /F "tokens=1-8 delims=::./ " %%A in ('echo %date%') do set dirdate=%%B-%%C-%%D
if exist Z:\videos\pmb\%dirdate%  goto skip else
md Z:\videos\pmb\%dirdate%
start Z:\videos\pmb\%dirdate%
:skip
if exist Z:\videos\pmb\%dirdate%\%FileDateTime%.m2ts goto oops else
@echo on
copy %1 Z:\videos\pmb\%dirdate%\%FileDateTime%.m2ts
@echo off
:oops
del c:\temp\x.x
  The contents of the IMPMTS.BAT file is:
echo off
CLS
Echo Importing Files...
for %%Z in (L:\AVCHD\BDMV\STREAM\*.mts) do (
call c:\windows\imp.bat %%Z
)
It is quite probable that using 2 batch files is not necessary but I did it that way to fix some problem I was having.

The batch files work basically like this(if I remember correctly):
impmts looks to the location on the camcorder where the MTS files are stored and for each file there it runs the IMP.BAT file which sets the drive letter of drive where it started from (usually c:) to an environment variable called startdrv.

A directory listing of the MTS files is written to a file in c:\temp\x.x
information from that file is fed to more environment variables.
The MTS file date and time is retrieved and set to an environment variable FileDateTime.
The current date is set to a variable called dirdate.
The batch file then looks to see if the folder is already there, if it is it skips creating it, if not it creates it.
It then opens the new folder in a window.
It then looks to see if the new file it wants to write is already there if it is it skips copying that file from the camcorder.
If the file does not exist it copies the mts file from the camcorder to the destination with the correct name format of YYYYMMDDHHMM.mt2s
Then it deletes the x.x file from c:\temp
Control returns to IMPMTS.BAT and repeats until all files are processed.

There is not much error handling.

you may find strange characters in the batch file at the end of lines that are not in my code on this page, if those characters are there the files will not work right until they are removed. I am not sure where they come from and they are not always there. Just letting you know it might happen.

If you use these batch files and your videos are lost I am not responsible. They shouldn't be lost because it does not delete anything from the camcorder.

Usage is simple from a cmd prompt (not administrator) run impmts.bat "nameoffolder"

I cannot, and will not provide help on editing the batch files to work for your system.

No comments: