Commit d72bd51e authored by Tong Sun's avatar Tong Sun

New upstream version 1.3.1

parents
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
ffcvt
image: golang:1.10
stages:
- build
- test
before_script:
# Create a symbolic link under $GOPATH, this is needed for local build
- cd $GOPATH/src
- mkdir -p gitlab.com/$CI_PROJECT_NAMESPACE
- cd gitlab.com/$CI_PROJECT_NAMESPACE
- ln -s $CI_PROJECT_DIR
- cd $CI_PROJECT_NAME
- go get ./...
build-test:
script:
# == build
# - godep restore
# - godep go build
- go build -v -ldflags="-X main.date=`date -I$TIMESPEC`"; date -I$TIMESPEC
# == test
- $CI_PROJECT_NAME
- $CI_PROJECT_NAME -version
# - godep restore
# - godep go test -v -cover ./...
- go test -v -cover ./...
- ( pwd; cd test; pwd; ls -l; ./test-sym.sh; )
# -*- yaml -*-
language: go
env:
global:
# http://pkg-go.alioth.debian.org/packaging.html
- VERSION="${TRAVIS_TAG:=0.0~git$(date +%Y%m%d)-1}"
- PKG_URL="https://github.com/suntong/ffcvt"
- PKG_CAT=utils
- PKG_ARCH=amd64
- PKG_DESC="ffmpeg convert wrapper tool"
- PKG_VEND="suntong"
- PKG_MAINT="Tong Sun <suntong@cpan.org>"
- PKG_LICNS="MIT"
script:
- go get -t -v ./...
- go build -v
- ( cd test; ./test-sym.sh; )
- go get github.com/mitchellh/gox
- gox -osarch="linux/386 linux/amd64 darwin/amd64 windows/amd64" -output="out/{{.Dir}}-{{.OS}}-{{.Arch}}"
# linux/386 linux/amd64 linux/arm darwin/amd64 darwin/386 windows/amd64 windows/386
before_deploy:
- gem install fpm --no-document
- make pkg
- sed -i -e "s/\$VERSION/$VERSION/" bintray-pkg.json
- sed -i -e "s/\$DATE/$(date +%Y-%m-%d)/" bintray-pkg.json
deploy:
- provider: bintray
user: suntong
key: ${BINTRAY_API_KEY}
file: bintray-bin.json
skip_cleanup: true
- provider: bintray
user: suntong
key: $BINTRAY_API_KEY
file: bintray-pkg.json
skip_cleanup: true
on:
# tags: true
The MIT License (MIT)
Copyright (c) 2015 Tong SUN <suntong@cpan.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
NAME := $(shell basename $(shell pwd))
VERSION ?= 0.0.0
all: test
clean: cleanbuild cleanpkg
cleanbuild:
rm -fr ./build
cleanpkg:
rm -fr ./pkg
show:
echo "Building '${NAME}'"
test:
go -v test ./...
build: build/${NAME}
build/%:
GOOS=linux GOARCH=amd64 go build -v -ldflags="-X main.date=`date -I`" -o build/$*
pkg: show build pkg/${NAME}.deb
pkg/%.deb:
mkdir -p ./pkg
# https://github.com/jordansissel/fpm/wiki
fpm --verbose -s dir -t deb \
--name ${NAME} \
--package ./pkg/${NAME}.deb \
--force \
--deb-compression bzip2 \
--url "${PKG_URL}" \
--category ${PKG_CAT} \
--description "${PKG_DESC}" \
--maintainer "${PKG_MAINT}" \
--vendor "${PKG_VEND}" \
--license "${PKG_LICNS}" \
--version ${VERSION} \
--architecture ${PKG_ARCH} \
--depends apt \
./build/=/usr/bin/
# {{.Name}}
{{render "license/shields" . "License" "MIT"}}
{{template "badge/godoc" .}}
{{template "badge/goreport" .}}
{{template "badge/travis" .}}
## {{toc 5}}
## {{.Name}} - ffmpeg convert wrapper tool
## Introduction
- The next-generation codec like [High Efficiency Video codec (HEVC), H.265](https://goo.gl/IZrDH2) or [VP9](https://developers.google.com/media/vp9/) can produce videos visually comparable to H.264's result, but in [about half the file size](https://trac.ffmpeg.org/wiki/Encode/H.265).
- Meanwhile the [Opus](https://goo.gl/BPUkTf) [audio codec](https://goo.gl/IZrDH2) is becoming the best thing ever for compressing audio -- A 64K Opus audio stream is comparable to mp3 files of 128K to 256K bandwidth.
- Such fantastic high efficiency audio/video codec/encoding capability has long been available in `ffmpeg`, but fewer people know it or use it, partly because the `ffmpeg` command line is not that simple for every one.
- The `ffcvt` is designed to take the burden from normal Joe -- All you need to do to encode a video is to give one parameter to `ffcvt`, i.e., the path and file name of the video to be encoded, and `ffcvt` will take care of the rest, using the recommended values for both audio/video encoding to properly encode it for you.
- It can't be more simpler than that. However, beneath the simple surface, `ffcvt` is versatile and powerful enough to allow you to touch every corner of audio/video encoding. There is a huge list of environment variables (or command-line parameters) which will allow you tweak the encoding methods and parameters to exactly what you prefer instead.
- Moreover, to encode a directory full of video files, including under its sub-directories, you need just to give `ffcvt` one single parameter, the directory location, and `ffcvt` will go ahead and encode all video files under that directory, including all its sub-directories as well.
## Quick Usage
There is a quick usage help that comes with `ffcvt`, produced when it is invoked without any parameters:
### $ {{exec "ffcvt" | color "sh"}}
## Environment Variables
For each `ffcvt` command line parameter, there is a environment variable corresponding to it. For example you can use `export FFCVT_FFMPEG=avconv` to use `avconv` instead of `ffmpeg` (Don't, I use it for my [CommandLineArgs](https://github.com/suntong001/lang/blob/master/lang/Go/src/sys/CommandLineArgs.go) to develop/test `ffcvt` without invoking `ffmpeg` each time).
## Encoding Help
The detailed guide to choose/provide proper parameters to `ffcvt` have been moved to [wiki](https://github.com/suntong/ffcvt/wiki/). For example,
- [HEVC vs VP9](https://github.com/suntong/ffcvt/wiki/WebM-(VP9)-Encoding#hevc-vs-vp9)
- [Preset Method Comparison](https://github.com/suntong/ffcvt/wiki/HEVC-(x265)-Encoding#preset-method-comparison)
- [The CRF Comparison](https://github.com/suntong/ffcvt/wiki/HEVC-(x265)-Encoding#the-crf-comparison)
- [Example 1: YouTube Encoding](https://github.com/suntong/ffcvt/wiki/Example-1:-YouTube-Encoding)
- [Example 2: Talk Encoding](https://github.com/suntong/ffcvt/wiki/Example-2:-Talk-Encoding)
Please check them out in the [wiki](https://github.com/suntong/ffcvt/wiki/).
## Download/Install
### Download binaries
- The latest binary executables are available under
https://bintray.com/suntong/bin/{{.Name}}/latest
as the result of the Continuous-Integration process.
- I.e., they are built right from the source code during _every_ git commit _automatically_ by [travis-ci](https://travis-ci.org/).
- Pick & choose the binary executable that suits your OS and its architecture. E.g., for Linux, it would most probably be the `{{.Name}}-linux-amd64` file. If your OS and its architecture is not available in the download list, please let me know and I'll add it.
- You may want to rename it to a shorter name instead, e.g., `{{.Name}}`, after downloading it.
### Debian package
Debian package _repo_ is available at https://dl.bintray.com/suntong/deb.
The _browse-able_ repo view is at https://bintray.com/suntong/deb.
```
echo "deb [trusted=yes] https://dl.bintray.com/suntong/deb all main" | sudo tee /etc/apt/sources.list.d/suntong-debs.list
sudo apt-get update
sudo chmod 644 /etc/apt/sources.list.d/suntong-debs.list
apt-cache policy {{.Name}}
sudo apt-get install -y {{.Name}}
```
### Install Source
If you prefer to compile and install `ffcvt` from source, although a manual process, it's pretty straightforward and simple.
0. Get the source via `git clone` or [`go get`](https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies).
0. Do `cd ffcvt`, then issue [`go build`](https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies) without any other parameters.
0. Copy the generated executable somewhere in the PATH
That's it, it's ready to roll.
## Tools Choices
As suggested before, don't use `avconv`, use `ffmpeg` instead (the `avconv` fork was more for political reasons. I personally believe `ffmpeg` is technically superior although might not be politically).
As for video/movie play back, use [mpv](http://mpv.io/). It is a fork of mplayer2 and MPlayer, and is a true *modern* *all-in-one* movie player that can play ANYTHING, and one of the few movie players being actively developed all the time. Download link is in [mpv.io](http://mpv.io/), from which Ubuntu repo I get my Ubuntu `ffmpeg` package as well. If you are unsatisfied with mpv's simple user interface, check out https://wiki.archlinux.org/index.php/Mpv#Front_ends.
## Author(s)
Tong SUN
![suntong from cpan.org](https://img.shields.io/badge/suntong-%40cpan.org-lightgrey.svg "suntong from cpan.org")
All patches welcome.
# ffcvt
[![MIT License](http://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![GoDoc](https://godoc.org/github.com/suntong/ffcvt?status.svg)](http://godoc.org/github.com/suntong/ffcvt)
[![Go Report Card](https://goreportcard.com/badge/github.com/suntong/ffcvt)](https://goreportcard.com/report/github.com/suntong/ffcvt)
[![travis Status](https://travis-ci.org/suntong/ffcvt.svg?branch=master)](https://travis-ci.org/suntong/ffcvt)
## TOC
- [ffcvt - ffmpeg convert wrapper tool](#ffcvt---ffmpeg-convert-wrapper-tool)
- [Introduction](#introduction)
- [Quick Usage](#quick-usage)
- [$ ffcvt](#-ffcvt)
- [Environment Variables](#environment-variables)
- [Encoding Help](#encoding-help)
- [Download/Install](#downloadinstall)
- [Download binaries](#download-binaries)
- [Debian package](#debian-package)
- [Install Source](#install-source)
- [Tools Choices](#tools-choices)
- [Author(s)](#author(s))
## ffcvt - ffmpeg convert wrapper tool
## Introduction
- The next-generation codec like [High Efficiency Video codec (HEVC), H.265](https://goo.gl/IZrDH2) or [VP9](https://developers.google.com/media/vp9/) can produce videos visually comparable to H.264's result, but in [about half the file size](https://trac.ffmpeg.org/wiki/Encode/H.265).
- Meanwhile the [Opus](https://goo.gl/BPUkTf) [audio codec](https://goo.gl/IZrDH2) is becoming the best thing ever for compressing audio -- A 64K Opus audio stream is comparable to mp3 files of 128K to 256K bandwidth.
- Such fantastic high efficiency audio/video codec/encoding capability has long been available in `ffmpeg`, but fewer people know it or use it, partly because the `ffmpeg` command line is not that simple for every one.
- The `ffcvt` is designed to take the burden from normal Joe -- All you need to do to encode a video is to give one parameter to `ffcvt`, i.e., the path and file name of the video to be encoded, and `ffcvt` will take care of the rest, using the recommended values for both audio/video encoding to properly encode it for you.
- It can't be more simpler than that. However, beneath the simple surface, `ffcvt` is versatile and powerful enough to allow you to touch every corner of audio/video encoding. There is a huge list of environment variables (or command-line parameters) which will allow you tweak the encoding methods and parameters to exactly what you prefer instead.
- Moreover, to encode a directory full of video files, including under its sub-directories, you need just to give `ffcvt` one single parameter, the directory location, and `ffcvt` will go ahead and encode all video files under that directory, including all its sub-directories as well.
## Quick Usage
There is a quick usage help that comes with `ffcvt`, produced when it is invoked without any parameters:
### $ ffcvt
```sh
Usage:
ffcvt [flags]
Flags:
-t target type: webm/x265-opus/x264-mp3/youtube (FFCVT_T)
-aes audio encoding method set (FFCVT_AES)
-ves video encoding method set (FFCVT_VES)
-aea audio encoding method append (FFCVT_AEA)
-vea video encoding method append (FFCVT_VEA)
-abr audio bitrate (64k for opus, 256k for mp3) (FFCVT_ABR)
-crf the CRF value: 0-51. Higher CRF gives lower quality
(28 for x265, ~ 23 for x264) (FFCVT_CRF)
-d directory that hold input files (FFCVT_D)
-f input file name (either -d or -f must be specified) (FFCVT_F)
-sym symlinks will be processed as well (FFCVT_SYM)
-exts extension list for all the files to be queued (FFCVT_EXTS)
-suf suffix to the output file names (FFCVT_SUF)
-ext extension for the output file (FFCVT_EXT)
-w work directory that hold output files (FFCVT_W)
-ac copy audio codec (FFCVT_AC)
-vc copy video codec (FFCVT_VC)
-an no audio, output video only (FFCVT_AN)
-vn no video, output audio only (FFCVT_VN)
-vss video: same size (FFCVT_VSS)
-o more options that will pass to ffmpeg program (FFCVT_O)
-ato-opus audio encode to opus, using -abr (FFCVT_ATO_OPUS)
-vto-x265 video video encode to x265, using -crf (FFCVT_VTO_X265)
-p par2create, create par2 files (in work directory) (FFCVT_P)
-nc no clobber, do not queue those already been converted (FFCVT_NC)
-n no exec, dry run (FFCVT_N)
-force overwrite any existing none-empty file (FFCVT_FORCE)
-debug debugging level (FFCVT_DEBUG)
-ffmpeg ffmpeg program executable name (FFCVT_FFMPEG)
Details:
-abr string
audio bitrate (64k for opus, 256k for mp3)
-ac
copy audio codec
-aea string
audio encoding method append
-aes string
audio encoding method set
-an
no audio, output video only
-ato-opus
audio encode to opus, using -abr
-crf string
the CRF value: 0-51. Higher CRF gives lower quality
(28 for x265, ~ 23 for x264)
-d string
directory that hold input files
-debug int
debugging level (default 1)
-ext string
extension for the output file
-exts string
extension list for all the files to be queued (default ".3GP.3G2.ASF.AVI.DAT.DIVX.FLV.M2TS.M4V.MKV.MOV.MPEG.MP4.MPG.RMVB.RM.TS.VOB.WEBM.WMV")
-f string
input file name (either -d or -f must be specified)
-ffmpeg string
ffmpeg program executable name (default "ffmpeg")
-force
overwrite any existing none-empty file
-n no exec, dry run
-nc
no clobber, do not queue those already been converted
-o string
more options that will pass to ffmpeg program
-p par2create, create par2 files (in work directory)
-suf string
suffix to the output file names
-sym
symlinks will be processed as well
-t string
target type: webm/x265-opus/x264-mp3/youtube (default "webm")
-vc
copy video codec
-vea string
video encoding method append
-ves string
video encoding method set
-vn
no video, output audio only
-vss
video: same size (default true)
-vto-x265
video video encode to x265, using -crf
-w string
work directory that hold output files
To reduce output, use `-debug 0`, e.g., `ffcvt -force -debug 0 -f testf.mp4 ...`
```
## Environment Variables
For each `ffcvt` command line parameter, there is a environment variable corresponding to it. For example you can use `export FFCVT_FFMPEG=avconv` to use `avconv` instead of `ffmpeg` (Don't, I use it for my [CommandLineArgs](https://github.com/suntong001/lang/blob/master/lang/Go/src/sys/CommandLineArgs.go) to develop/test `ffcvt` without invoking `ffmpeg` each time).
## Encoding Help
The detailed guide to choose/provide proper parameters to `ffcvt` have been moved to [wiki](https://github.com/suntong/ffcvt/wiki/). For example,
- [HEVC vs VP9](https://github.com/suntong/ffcvt/wiki/WebM-(VP9)-Encoding#hevc-vs-vp9)
- [Preset Method Comparison](https://github.com/suntong/ffcvt/wiki/HEVC-(x265)-Encoding#preset-method-comparison)
- [The CRF Comparison](https://github.com/suntong/ffcvt/wiki/HEVC-(x265)-Encoding#the-crf-comparison)
- [Example 1: YouTube Encoding](https://github.com/suntong/ffcvt/wiki/Example-1:-YouTube-Encoding)
- [Example 2: Talk Encoding](https://github.com/suntong/ffcvt/wiki/Example-2:-Talk-Encoding)
Please check them out in the [wiki](https://github.com/suntong/ffcvt/wiki/).
## Download/Install
### Download binaries
- The latest binary executables are available under
https://bintray.com/suntong/bin/ffcvt/latest
as the result of the Continuous-Integration process.
- I.e., they are built right from the source code during _every_ git commit _automatically_ by [travis-ci](https://travis-ci.org/).
- Pick & choose the binary executable that suits your OS and its architecture. E.g., for Linux, it would most probably be the `ffcvt-linux-amd64` file. If your OS and its architecture is not available in the download list, please let me know and I'll add it.
- You may want to rename it to a shorter name instead, e.g., `ffcvt`, after downloading it.
### Debian package
Debian package _repo_ is available at https://dl.bintray.com/suntong/deb.
The _browse-able_ repo view is at https://bintray.com/suntong/deb.
```
echo "deb [trusted=yes] https://dl.bintray.com/suntong/deb all main" | sudo tee /etc/apt/sources.list.d/suntong-debs.list
sudo apt-get update
sudo chmod 644 /etc/apt/sources.list.d/suntong-debs.list
apt-cache policy ffcvt
sudo apt-get install -y ffcvt
```
### Install Source
If you prefer to compile and install `ffcvt` from source, although a manual process, it's pretty straightforward and simple.
0. Get the source via `git clone` or [`go get`](https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies).
0. Do `cd ffcvt`, then issue [`go build`](https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies) without any other parameters.
0. Copy the generated executable somewhere in the PATH
That's it, it's ready to roll.
## Tools Choices
As suggested before, don't use `avconv`, use `ffmpeg` instead (the `avconv` fork was more for political reasons. I personally believe `ffmpeg` is technically superior although might not be politically).
As for video/movie play back, use [mpv](http://mpv.io/). It is a fork of mplayer2 and MPlayer, and is a true *modern* *all-in-one* movie player that can play ANYTHING, and one of the few movie players being actively developed all the time. Download link is in [mpv.io](http://mpv.io/), from which Ubuntu repo I get my Ubuntu `ffmpeg` package as well. If you are unsatisfied with mpv's simple user interface, check out https://wiki.archlinux.org/index.php/Mpv#Front_ends.
## Author(s)
Tong SUN
![suntong from cpan.org](https://img.shields.io/badge/suntong-%40cpan.org-lightgrey.svg "suntong from cpan.org")
All patches welcome.
VP9-CRF.png

29.4 KB

{
"package": {
"name": "ffcvt",
"repo": "bin",
"subject": "suntong",
"desc": "ffmpeg convert wrapper tool",
"website_url": "https://github.com/suntong/ffcvt",
"issue_tracker_url": "https://github.com/suntong/ffcvt/issues",
"vcs_url": "https://github.com/suntong/ffcvt.git",
"licenses": ["MIT"],
"public_download_numbers": false
},
"version": {
"name": "latest",
"gpgSign": false
},
"files": [{
"includePattern": "out/(.*)", "uploadPattern": "ffcvt/$1",
"matrixParams": {
"override": 1
}
}],
"publish": true
}
{
"package": {
"name": "ffcvt",
"repo": "deb",
"subject": "suntong",
"desc": "ffmpeg convert wrapper tool",
"website_url": "https://github.com/suntong/ffcvt",
"issue_tracker_url": "https://github.com/suntong/ffcvt/issues",
"vcs_url": "https://github.com/suntong/ffcvt.git",
"licenses": ["MIT"],
"public_download_numbers": false
},
"version": {
"name": "$VERSION",
"desc": "Release $VERSION",
"released": "$DATE",
"vcs_tag": "$VERSION",
"gpgSign": true
},
"files": [{
"includePattern": "pkg/(.*)\\.deb",
"uploadPattern": "pool/main/f/$1_$VERSION_amd64.deb",
"matrixParams": {
"deb_distribution": "all",
"deb_component": "main",
"deb_architecture": "amd64",
"override": 1
}
}],
"publish": true
}
// !!! !!!
// WARNING: Code automatically generated. Editing discouraged.
// !!! !!!
package main
import (
"flag"
"fmt"
"os"
)
////////////////////////////////////////////////////////////////////////////
// Constant and data type/structure definitions
const progname = "ffcvt" // os.Args[0]
// The Options struct defines the structure to hold the commandline values
type Options struct {
Target string // target type: webm/x265-opus/x264-mp3/youtube
Encoding // anonymous field to hold encoding values
Directory string // directory that hold input files
File string // input file name (either -d or -f must be specified)
Links bool // symlinks will be processed as well
Exts string // extension list for all the files to be queued
Suffix string // suffix to the output file names
WDirectory string // work directory that hold output files
AC bool // copy audio codec
VC bool // copy video codec
AN bool // no audio, output video only
VN bool // no video, output audio only
VSS bool // video: same size
OptExtra string // more options that will pass to ffmpeg program
A2Opus bool // audio encode to opus, using -abr
V2X265 bool // video video encode to x265, using -crf
Par2C bool // par2create, create par2 files (in work directory)
NoClobber bool // no clobber, do not queue those already been converted
NoExec bool // no exec, dry run
Force bool // overwrite any existing none-empty file
Debug int // debugging level
FFMpeg string // ffmpeg program executable name
PrintV bool // print version then exit
}
////////////////////////////////////////////////////////////////////////////
// Global variables definitions
// Opts holds the actual values from the command line parameters
var Opts Options
////////////////////////////////////////////////////////////////////////////
// Commandline definitions
func init() {
// set default values for command line parameters
flag.StringVar(&Opts.Target, "t", "webm",
"target type: webm/x265-opus/x264-mp3/youtube")
flag.StringVar(&Opts.AES, "aes", "",
"audio encoding method set")
flag.StringVar(&Opts.VES, "ves", "",
"video encoding method set")
flag.StringVar(&Opts.AEA, "aea", "",
"audio encoding method append")
flag.StringVar(&Opts.VEA, "vea", "",
"video encoding method append")
flag.StringVar(&Opts.ABR, "abr", "",
"audio bitrate (64k for opus, 256k for mp3)")
flag.StringVar(&Opts.CRF, "crf", "",
"the CRF value: 0-51. Higher CRF gives lower quality\n\t (28 for x265, ~ 23 for x264)")
flag.StringVar(&Opts.Directory, "d", "",
"directory that hold input files")
flag.StringVar(&Opts.File, "f", "",
"input file name (either -d or -f must be specified)")
flag.BoolVar(&Opts.Links, "sym", false,
"symlinks will be processed as well")
flag.StringVar(&Opts.Exts, "exts", ".3GP.3G2.ASF.AVI.DAT.DIVX.FLV.M2TS.M4V.MKV.MOV.MPEG.MP4.MPG.RMVB.RM.TS.VOB.WEBM.WMV",
"extension list for all the files to be queued")
flag.StringVar(&Opts.Suffix, "suf", "",
"suffix to the output file names")
flag.StringVar(&Opts.Ext, "ext", "",
"extension for the output file")
flag.StringVar(&Opts.WDirectory, "w", "",
"work directory that hold output files")
flag.BoolVar(&Opts.AC, "ac", false,
"copy audio codec")
flag.BoolVar(&Opts.VC, "vc", false,
"copy video codec")
flag.BoolVar(&Opts.AN, "an", false,
"no audio, output video only")
flag.BoolVar(&Opts.VN, "vn", false,
"no video, output audio only")
flag.BoolVar(&Opts.VSS, "vss", true,
"video: same size")
flag.StringVar(&Opts.OptExtra, "o", "",
"more options that will pass to ffmpeg program")
flag.BoolVar(&Opts.A2Opus, "ato-opus", false,
"audio encode to opus, using -abr")
flag.BoolVar(&Opts.V2X265, "vto-x265", false,
"video video encode to x265, using -crf")
flag.BoolVar(&Opts.Par2C, "p", false,
"par2create, create par2 files (in work directory)")
flag.BoolVar(&Opts.NoClobber, "nc", false,
"no clobber, do not queue those already been converted")
flag.BoolVar(&Opts.NoExec, "n", false,
"no exec, dry run")
flag.BoolVar(&Opts.Force, "force", false,
"overwrite any existing none-empty file")
flag.IntVar(&Opts.Debug, "debug", 1,
"debugging level")
flag.StringVar(&Opts.FFMpeg, "ffmpeg", "ffmpeg",
"ffmpeg program executable name")
flag.BoolVar(&Opts.PrintV, "version", false,
"print version then exit")
// Now override those default values from environment variables
if len(Opts.Target) == 0 ||
len(os.Getenv("FFCVT_T")) != 0 {
Opts.Target = os.Getenv("FFCVT_T")
}
if len(Opts.AES) == 0 ||
len(os.Getenv("FFCVT_AES")) != 0 {
Opts.AES = os.Getenv("FFCVT_AES")
}
if len(Opts.VES) == 0 ||
len(os.Getenv("FFCVT_VES")) != 0 {
Opts.VES = os.Getenv("FFCVT_VES")
}
if len(Opts.AEA) == 0 ||
len(os.Getenv("FFCVT_AEA")) != 0 {
Opts.AEA = os.Getenv("FFCVT_AEA")
}
if len(Opts.VEA) == 0 ||
len(os.Getenv("FFCVT_VEA")) != 0 {
Opts.VEA = os.Getenv("FFCVT_VEA")
}
if len(Opts.ABR) == 0 ||
len(os.Getenv("FFCVT_ABR")) != 0 {
Opts.ABR = os.Getenv("FFCVT_ABR")
}
if len(Opts.CRF) == 0 ||
len(os.Getenv("FFCVT_CRF")) != 0 {
Opts.CRF = os.Getenv("FFCVT_CRF")
}
if len(Opts.Directory) == 0 ||
len(os.Getenv("FFCVT_D")) != 0 {
Opts.Directory = os.Getenv("FFCVT_D")
}
if len(Opts.File) == 0 ||
len(os.Getenv("FFCVT_F")) != 0 {
Opts.File = os.Getenv("FFCVT_F")
}
if len(Opts.Exts) == 0 ||
len(os.Getenv("FFCVT_EXTS")) != 0 {
Opts.Exts = os.Getenv("FFCVT_EXTS")
}
if len(Opts.Suffix) == 0 ||
len(os.Getenv("FFCVT_SUF")) != 0 {
Opts.Suffix = os.Getenv("FFCVT_SUF")
}
if len(Opts.Ext) == 0 ||
len(os.Getenv("FFCVT_EXT")) != 0 {
Opts.Ext = os.Getenv("FFCVT_EXT")
}
if len(Opts.WDirectory) == 0 ||
len(os.Getenv("FFCVT_W")) != 0 {
Opts.WDirectory = os.Getenv("FFCVT_W")
}
if len(Opts.OptExtra) == 0 ||
len(os.Getenv("FFCVT_O")) != 0 {
Opts.OptExtra = os.Getenv("FFCVT_O")
}
if len(Opts.FFMpeg) == 0 ||
len(os.Getenv("FFCVT_FFMPEG")) != 0 {
Opts.FFMpeg = os.Getenv("FFCVT_FFMPEG")
}
}
const USAGE_SUMMARY = " -t\ttarget type: webm/x265-opus/x264-mp3/youtube (FFCVT_T)\n -aes\taudio encoding method set (FFCVT_AES)\n -ves\tvideo encoding method set (FFCVT_VES)\n -aea\taudio encoding method append (FFCVT_AEA)\n -vea\tvideo encoding method append (FFCVT_VEA)\n -abr\taudio bitrate (64k for opus, 256k for mp3) (FFCVT_ABR)\n -crf\tthe CRF value: 0-51. Higher CRF gives lower quality\n\t (28 for x265, ~ 23 for x264) (FFCVT_CRF)\n\n -d\tdirectory that hold input files (FFCVT_D)\n -f\tinput file name (either -d or -f must be specified) (FFCVT_F)\n -sym\tsymlinks will be processed as well (FFCVT_SYM)\n -exts\textension list for all the files to be queued (FFCVT_EXTS)\n -suf\tsuffix to the output file names (FFCVT_SUF)\n -ext\textension for the output file (FFCVT_EXT)\n -w\twork directory that hold output files (FFCVT_W)\n\n -ac\tcopy audio codec (FFCVT_AC)\n -vc\tcopy video codec (FFCVT_VC)\n -an\tno audio, output video only (FFCVT_AN)\n -vn\tno video, output audio only (FFCVT_VN)\n -vss\tvideo: same size (FFCVT_VSS)\n -o\tmore options that will pass to ffmpeg program (FFCVT_O)\n -ato-opus\taudio encode to opus, using -abr (FFCVT_ATO_OPUS)\n -vto-x265\tvideo video encode to x265, using -crf (FFCVT_VTO_X265)\n\n -p\tpar2create, create par2 files (in work directory) (FFCVT_P)\n -nc\tno clobber, do not queue those already been converted (FFCVT_NC)\n -n\tno exec, dry run (FFCVT_N)\n\n -force\toverwrite any existing none-empty file (FFCVT_FORCE)\n -debug\tdebugging level (FFCVT_DEBUG)\n -ffmpeg\tffmpeg program executable name (FFCVT_FFMPEG)\n -version\tprint version then exit (FFCVT_VERSION)\n\nDetails:\n\n"
// Usage function shows help on commandline usage
func Usage() {
fmt.Fprintf(os.Stderr,
"\nUsage:\n %s [flags] \n\nFlags:\n\n",
progname)
fmt.Fprintf(os.Stderr, USAGE_SUMMARY)
flag.PrintDefaults()
fmt.Fprintf(os.Stderr,
"\nTo reduce output, use `-debug 0`, e.g., `ffcvt -force -debug 0 -f testf.mp4 ...`\n")
os.Exit(0)
}
////////////////////////////////////////////////////////////////////////////
// Porgram: FfCvt
// Purpose: ffmpeg convert wrapper tool
// Authors: Tong Sun (c) 2015, All rights reserved
////////////////////////////////////////////////////////////////////////////
/*
Transcodes all videos in the given directory and all of it's subdirectories
using ffmpeg.
*/
//go:generate sh -v ffcvt_cli.sh