Code Monkey home page Code Monkey logo

transcode's Introduction

transcode

Cargo version

Transcode a directory of videos

Example

transcode ~/Videos/ ~/ConvertedVideos
  • Converts video/audio files in ~/Videos/ to ~/VideosConverted/

Full Usage

Usage: target/debug/transcode [OPTION]... INPUT_DIRECTORY OUTPUT_DIRECTORY [INPUT_FILE]...

Options:
    -d, --dry-run       No paths are created or updated
    -h, --help          Display this help and exit
    -f, --format        Set the output format

Examples of the --format option:
    --format=mkv,h264,18,normal,opus,192

Features

  • Shows progress for individual files and total progress
  • Shows ETA for individual files and total ETA
  • Takes directory as input, automatically identify audio/video files within.
  • Copies files that are already in the target format instead of processing.

Formats

Currently the only target format is hardcoded and is:

Container Audio Video
Matroska Opus 192k h.264 4.1

Installation

Motivation

I ran into the problem of having many video files of various formats that needed to run on a raspberry pi. So i needed a script to convert all of them for playback in a format that raspberry pi can run.

You could of course just loop through all the files. Though i found the following issues:

Problems:

  • There is no ETA on when the script will finish.
  • Files would be scattered in the file system.

So i decided i wanted to write a more specific program for the job.

transcode's People

Contributors

bjornua avatar

Stargazers

Daniel Bodnar avatar Jason Howmans avatar Shuwen Sun avatar Jordan Deitch avatar  avatar

Watchers

 avatar James Cloos avatar

transcode's Issues

Improve usability of --format

The program should be pretty user friendly yet flexible. The --target option is flexible but not very easy to read. The --target option should probably be more verbose, show hierarchy, and use named arguments

Inpsired by rust structs .transcoderc file could be in a format like:

mypreset = mkv {
    video: maxres {
        maxheight: 1024,
        maxwidth: 768,
        encoder: h264 {
            crf: 18,
            speed: normal
        }
    ),
    audio: opus {
        bitrate: 192
    }
}

If it's very hard to implement an parser, consider using some json format.

Add additional targets

It should be possible to add additional targets.

Should consider whether to enable users to pass options directly to ffmpeg or to parse them. Or both.

ETA's are pretty inaccurate

FFmpeg outputs the amount of seconds processed.
We also know the amount of total seconds.

We assume amount processing speed for a single conversion is constant. (though this could cause significant an error).

Each file should have a calculated field called "Work"

It's the estimated amount of processing needed to complete.

The significant factors (that we can know before processing) could be:

  • input audio decoder
  • input video decoder
  • hardware decoders are present or is done by cpu
  • output video encoder
  • output video encoder
  • hardware encoders are present or is done by cpu
  • input width
  • input height
  • output width
  • output height
  • duration
  • frames/sec

Need some kind of system to collect all these variables and estimate the amount of work.

We can probably just learn as we go from the computer, which make "hardware support" constant.

Also probably these variables are not completely independent.

A formula could be:
work = output_decoder * input_decoder * width * height * (frames/sec * duration)
where input_decoder and output_decoder are some number.

Handling early conversion exits.

When a conversion fails, it exists earlier.
When a conversion is shorter than expected, it exists earlier.

This messes up the amount of work done, especially when a big file fails in the beginning. The calculated processing speed becomes way too high.

A fix would be to change the way progress works:
Status::Done(Done{target}) = Status::Progress(Progress{processed})
Status::Fail(Fail{target}) = Status::Progress(Progress{processed})

FFProbe error handling

Sources are filtered away if they are not video/audio files. The way it's implemented is to discard any source that had any ffprobe error.

If ffprobe fail for some unknown reason, it is simply silenced and skipped.

Only certain errors from ffprobe lead to a skip, not all errors.

Processing errors

If ffmpeg errors happen, the target file should be deleted, and the processing should just skip it and continue.

Report the errors in the end of script.

New option --smallest-first

The order of processing right now is by command line order and whatever walking a dir returns.

Another idea is to do the smallest (quickest) conversions first. In this way if the user decides to cancel, there are at least some finished conversions.

A use case is that you start the conversion, and then check out the result immediately to check the quality.

Resume processing

It should be possible to cancel the script and when you run again it picks up where you last cancelled.

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.