Last active
August 25, 2020 14:36
-
-
Save ouuan/d026bb11755f4760081c94f2a818aa24 to your computer and use it in GitHub Desktop.
Concat original video and reversed video
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
| 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