I'm a newbie needing some clear advice on how to convert a number of MTS videos to MP4. The MP4 can replace the MTS. I'm on Windows 7 x64
I am familiar with Handbrake but open to using other utilities. The gaps with Handbrake is that it can't do batch on recursive subfolders. And second, it doesn't copy the Date Created metadata to the new file. I've pieced together a couple solutions from the web. Looks like I can copy the metadata using FFmpeg with this type of command: $ ffmpeg -i in.mts -i out.mp4 -map 1 -map_metadata 0 -c copy fixed.mp4
And for the recursive conversion, I found this Powershell script:
gci . *.mts -R | foreach-object { $newfile = $_.Path + $_.DirectoryName + "\" + $_.BaseName + "-convert" + $_.Extension; &"C:\Program Files (x86)\HandBrake\HandBrakeCLI.exe" -i "$_.FullName" -o "$newfile" --preset "custom" }
Can somebody help me with a one-stop solution for the recursive batch conversion and preserving the metadata?
Thanks, Vlad
+ Reply to Thread
Results 1 to 11 of 11
-
-
FFmpeg batch with subfolders. Put it in a video.bat textfile with for example notepad.
Code:@echo off & setlocal FOR /r %%i in (*.mts) DO c:\ffmpeg\ffmpeg -i "%%~fi" -i "%%~dpni(2).mp4" -map 1 -map_metadata 0 -c copy "%%~dpni(2)-fixed.mp4" pause
(from http://stackoverflow.com/questions/16141869/ffmpeg-batch-convert-subfolders )
Maybe you can add the powershell script before. I have never used any powershell scripts. Or convert directly with ffmpeg....if you find a good preset. -
Baldrick,
I'm getting error message in attached file. Can you help me out? Also I'm looking to rename original MTS file, not copy. Will this script do that?
Thanks! Vlad -
C:\Users\vselsky\Downloads\folder 1\folder 2\00064.mp4 is missing.
It should be the out.mp4(from handbrakecli) in your ffmpeg example.
And you must change the output filename so it's not same as the input. Like "%%~dpni(2)-fixed.mp4" -
Sorry I still can't get it to work. Maybe we can start from beginning. In the code below, is there anything I need to replace or it should work as written?
@echo off & setlocal
FOR /r %%i in (*.mts) DO c:\ffmpeg\ffmpeg -i "%%~fi" -i "%%~dpni(2).mp4" -map 1 -map_metadata 0 -c copy "%%~dpni(2)-fixed.mp4"
pause -
But have you run the handbrakecli command?
Please list some of your files in the folder.
(and when you post it's 04.00 in the morning here....so I can't answer directly)
-
Sorry you lost me. What is the handbrakecli command and how do I run it? I thought this script has nothing to do with handbrake? I just double click on the .bat file to launch it?
I'm running a test....I've placed the .bat script into C:\Users\vselsky\Downloads
I've created:
C:\Users\vselsky\Downloads\folder 1 and C:\Users\vselsky\Downloads\folder 1\folder 2
In folder 2, I have file 00064.mts (basically two directories deep from the .bat file). It is this file that I want to replace with 00064.mp4 -
No it has nothing to do with handbrakecli. You should have used it already to create/converted all mp4 files.
So do you have the mts and mp4 in SAME folder?
If so post the ffmpeg error. -
Having done the Hanbrake conversion first, I was able to run the script. There are a couple messages that I've highlighted in yellow in attached file, not sure if these are problematic.
But I don't see any of the metadata being copied over from the MTS file to the 'fixed' MP4 file. You can see the Date and Content Created attributes not copying over. See attached file.
HOWEVER, as these converted files are ultimately being stored on my Synology NAS, I've come to the realization that there are only a few limited columns by which to view and sort the media. In terms of dates, all I have are Created Date and Modified Date. Is it all possible to write the original Date, or Content Created Date, to one of these two attributes? Because if not, then I need to abandon this approach.
So my second approach is simply to write the original Date/Content Created as a prefix in the file name. If the file is 'test.mp4', I'd want to see "2013-11-12 test.mp4". Is something like this possible with ffmpeg?
I should add that after I get this to work, I'd like to delete the original AVCHD file in all the recursive folders. Hoping there is an easy command for that.
Thanks for sticking with me! Hope we can see this through.
Vlad -
Didn't you try the ffmpeg metadata copy command on one file before I wrote the complex batch command?
Isn't the original/created date just the date from the file system. Maybe you could find some batch command to extract it easily and add to the filename...search stackoverflow.com .
Similar Threads
-
THandBrake 1.2 - Batch GUI for Handbrake
By ozok in forum Video ConversionReplies: 35Last Post: 30th Jun 2014, 10:47 -
Date Created - Batch Encode
By conandrum in forum Video ConversionReplies: 15Last Post: 14th Nov 2013, 15:57 -
Preserving Time / Date metadata in capture files
By jlaymon in forum Capturing and VCRReplies: 4Last Post: 28th May 2013, 11:51 -
videos or pictures - date created vs date modified
By jyeh74 in forum Newbie / General discussionsReplies: 2Last Post: 4th Oct 2012, 16:00 -
undo date modified on "favorites" files
By gordes04 in forum ComputerReplies: 11Last Post: 21st Aug 2011, 17:07