Skip to content

Instantly share code, notes, and snippets.

@ouuan
Last active August 25, 2020 14:36
Show Gist options
  • Select an option

  • Save ouuan/d026bb11755f4760081c94f2a818aa24 to your computer and use it in GitHub Desktop.

Select an option

Save ouuan/d026bb11755f4760081c94f2a818aa24 to your computer and use it in GitHub Desktop.
Concat original video and reversed video
origin_reversed() {
local tmp_dir=/tmp/concat_original_video_and_reversed_video
local base_name=$(basename "$1")
local mts_path="$tmp_dir/${base_name}.mts"
local reversed_path="$tmp_dir/${base_name}-reversed.mts"
local concat_path="$tmp_dir/${base_name}-concat.mts"
local list_path="$tmp_dir/${base_name}-list"
mkdir -p "$tmp_dir"
ffmpeg -i "$1" -q 0 "$mts_path"
ffmpeg -i "$mts_path" -vf reverse -af areverse "$reversed_path"
echo "file $mts_path\nfile $reversed_path" > "$list_path"
ffmpeg -f concat -safe 0 -i "$list_path" -c copy "$concat_path"
ffmpeg -i "$concat_path" -q 0 "$2"
\rm -r "$tmp_dir"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment