Code Monkey home page Code Monkey logo

gorpomergeandencode's Introduction

GorpoMergeAndEncode

Merge and encode single videos split into multiple mp4 files with PowerShell using MKVToolNix and Handbrake

Description

Merge and encode single videos split into multiple mp4 files in the given GoPro export folder and removes original files if successful. various unique recording in the same directory.

Requires MKVmerge and HandBrakeCLI installed in C:\Program Files\MKVToolNix\ and C:\Program Files\HandBrake\ respectively. Custom paths can be setup using the parameters -MKVMergeLocation and -HandbrakeLocation.

See official Handbrake presets

Output file is Encoded-{original filename}-{date of subfolder}

Parameters

  • -dir Defaults to the current directory

  • -preset The default preset is "Vimeo YouTube HQ 1440p60 2.5K".

  • -MKVMergeLocation Location of mkvmerge.exe, defaults to 'C:\Program Files\MKVToolNix',

  • -HandbrakeLocation Location of HandBrakeCLI.exe, defaults to'C:\Program Files\HandBrake',

  • -MKVMergeExtraParam Extra parameters for MKVMerge

  • -HandbrakeExtraParam Extra parameters for Handbrake

  • -test Test merge and encode three seconds of each video, without deleting the original files

  • -delete Delete original files if no error is found. Defaults to true

  • -mergeAll Ignore file naming and merge all files in the directory

  • -noEncoding Skip encoding step, only merge

Examples

PowerShell command line

.\goproMergeEncode.ps1 -dir "d:\Video\GoPro\2019-04-21\HERO5 Black 1\"

Process backlog

If you have a backlog of videos to split, you can create a chain of PowerShell commands .\goproMergeEncode.ps1 -dir "D:\Video\GoPro\2018-10-19\HERO5 Black\"; .\goproMergeEncode.ps1 -dir "D:\Video\GoPro\2018-12-04\HERO5 Black 1\"; .\goproMergeEncode.ps1 -dir "D:\Video\GoPro\2018-12-11\HERO5 Black 1\";

Windows command line

powershell.exe –ExecutionPolicy Bypass -noexit "& 'D:\goproMergeEncode.ps1' -dir 'D:\Video\GoPro\2019-04-19\HERO5 Black 1\'"

Output file for D:\Video\GoPro\2019-04-21\HERO5 Black 1\GOPR2548.MP4 is Encoded-GOPR2548-20190421.mp4

Issues running PowerShell

By default, Windows doesn't allow to run PowerShell scripts, see execution policies

Permanent allow running this script

Open Start, search for PowerShell, right-click the top-result and click the Run as administrator option.

Check your execution policy by running the command Get-ExecutionPolicy

To change to a policy that allows you to run scripts, run PowerShell as administrator and run Set-ExecutionPolicy RemoteSigned

To unblock this file only, go to the folder you downloaded the file and run Unblock-File .\goproMergeEncode.ps1

Temporary allow

Run from command line powershell –ExecutionPolicy Bypass

All scripts run during this session will bypass the restrictions.

Notes

Based on the file name format GOPR2548.MP4 and multiple files GP012548.MP4, GP022548.MP4,... and folder structure ..\GoPro\2019-04-21\HERO5 Black 1
Note that the script expects an arrangement that works for single videos for the camera models: HD HERO2, HERO3, HERO3+, HERO (2014), HERO Session, HERO4, HERO5 Black, HERO5 Session, HERO (2018)

For HERO6 Black, & HERO7 (White, Silver, Black) or other formats use -mergeAll parameter. See GoPro Camera File Naming Convention

Note that HandBrake doesn't support merging.

Alternatives

About

This script was made quickly with the goal for me to learn more about PowerShell. Probably would be better to use ffmpeg, but I like the presets of HandBrake, and my focus was mostly on learning to script something using PowerShell.

Decided to make it open source, since others might find useful, but now I have spent more time on documentation than actual scripting :)

Contact

All code reviews, suggestions, recommendations, pieces of advice, optimizations, insults are welcomed. [email protected]

gorpomergeandencode's People

Contributors

alexandrosk0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

qwiboo

gorpomergeandencode's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.