Git Product home page Git Product logo

mtsmerge's Introduction

mtsmerge.py: PVR output MTS merge and transcode utility script

Intended audience

This script is meant to be used by people with little prior knowledge of media files, transcoding, etc. It is meant to be simple to use but requires the use of the command line.

Description

This script is used to convert MTS files that are outputted from my PVR to mp4. MTS stands for MPEG Transport Stream. An MTS file is a video saved in the Advanced Video Coding High Definition AVCHD format.

PVR sometimes uses an older filesystem that supports only 4GB files and can split your media into several files. This is not very practical to watch a movie so I wrote this script. Storing media in AVCHD is also taking a lot of disk space. Converting them to another format for storage is useful.

The script simply merge file sequences (.mts, .mts1, .mts2, .mts3) of files having the same file name. Then, it converts it to mp4. It does it all using ffmpeg.

For example, if you have a folder with:

  • CIVM-HD-08122020-0900PM.mts
  • CIVM-HD-08122020-0900PM.mts2
  • CIVM-HD-08122020-0900PM.mts1
  • CIVM-HD-08122020-0900PM.mts3

it will convert it to:

  • CIVM-HD-08122020-0900PM-merged.mp4

The script won't delete or clean up your files.

Usage

For help: python3 mtsmerge.py -h

Exxamples:

  • python3 mtsmerge.py (from your current mts directory)
  • python3 mtsmerge.py --inputdir media folder
  • python3 mtsmerge.py --inputdir media folder --outputdir output folder
  • python3 mtsmerge.py --x265 (encoding with newer codec HEVC/H.265 video )
  • python3 mtsmerge.py --x265 --opus (encoding with newer codec HEVC/H.265 & opus audio)

You can use --x265 for encoding video in HEVC/H.265 but you will need a chromecast ultra is you plan to use a chromecast with your video.

You can use --opus for encoding audio in opus. The file will be saved as an .mkv extension since .mp4 does not support opus. Opus is supported by chromecast 3rd generation.

Encoding examples

1h57:00 1920x1080 HD movie MTS from my PVR with 5.1 ac3 384 kb/s audio

Codec File Size mtsmerge.py Options Encoding Speed
AVCHD (original file) 16.7GB N/A N/A
h264 (default) 4.26GB default Fast
h265 1.4GB --x265 Slow
h265 & opus 1.4GB --x265 --opus Slower

Requirements

I prepared a tutorial video to learn how to do that on Windows 10: https://gist.github.com/desjare/adc1514d46bcb38414a5e2a602f6d12d

Tested

Bugs & Notes

The current implementation transcode the AVCHD to h264 and does an audio passthrough by default. It is fairly simple to modify it and add parameters to use other codec configurations like HEVC, opus, etc. I welcome any contribution.

mtsmerge's People

Contributors

desjare avatar

Stargazers

 avatar

Watchers

 avatar

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.