Created
January 15, 2014 20:32
-
-
Save schlomo/8443968 to your computer and use it in GitHub Desktop.
Simple Video Tricks: Concatenate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# concatenate several SOURCE_CONCAT_FILE_NAMES files into a mp4 | |
# FIRST_NAME and second argument are file names or parts of a filename. All files inbetween will be concatenated. | |
START="$1" ; shift | |
END="$1" ; shift | |
COMMON_PREFIX="" | |
# find all input files | |
# input files are all files from FIRST_NAME to LAST_NAME | |
mapfile -t SOURCES < <(ls | sed -n -e "/$START/,/$END/p") | |
# FIRST_NAME and LAST_NAME is input file name without suffix | |
FIRST_NAME="${SOURCES%.*}" | |
LAST_NAME="${SOURCES[@]: -1:1}" | |
LAST_NAME="${LAST_NAME%.*}" | |
RESULT_FILE_NAME="Concat_${FIRST_NAME}___${LAST_NAME}.mp4" | |
SOURCE_CONCAT_FILE_NAMES="concat:$(for s in "${SOURCES[@]}" ; do echo -n "$s|" ; done)" | |
exec avconv -i "$SOURCE_CONCAT_FILE_NAMES" -codec copy "$@" "$RESULT_FILE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment