Skip to content

Commit

Permalink
feat(Transpose): transpose video for recording on landscape mode
Browse files Browse the repository at this point in the history
fix #6
  • Loading branch information
fjcaetano committed Apr 8, 2021
1 parent 55375b7 commit cdf3169
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ $ ios-simulator-gif [options] {out_file} {-- [ffmpeg options]}
| -r, --rate | Framerate of the output | `6` |
| -f, --format | Output format | `gif` |
| -vf, --video-filter | Video filter for `ffmpeg` | `scale=320:-1` |
| -t, --transpose | Transpose the video for landscape orientation | N/A |
| --no-watermark | Remove watermark from gif | N/A |
| -h, --help | Prints helper message | N/A |
| -v, --version | Prints current version | N/A |

If no file name is given, it will save the gif to `./simulator.gif`

When recording a video in landscape mode you'll need to provide the appropriate transposing argument. It's usually the following:
1. `--transpose 1` when the simulator is rotated 90º (camera to the right)
2. `--transpose 2` when the simulator is rotated 270º (camera to the left)

### Sending extra arguments to `ffmpeg`

If you need to send extra arguments to `ffmpeg`, everything sent after double slashes (`--`) will be
Expand Down
13 changes: 11 additions & 2 deletions bin/ios-simulator-gif
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ VIDEO=/tmp/simulator-gif.mov
##############
main() {
parse_args "$@"
# check_booted
# record
check_booted
record
convert_gif
}

Expand Down Expand Up @@ -87,6 +87,10 @@ convert_gif() {
PALLETE="/tmp/palette.png"
FILTERS="${HIDE_WATERMARK-$WATERMARK_CMD,}${VIDEOFILTER},fps=${RATE}"

if [[ ! -z "${TRANSPOSE}" ]]; then
FILTERS="${FILTERS},transpose=${TRANSPOSE}"
fi

ffmpeg -v warning -i ${VIDEO} -vf "$FILTERS,palettegen=stats_mode=diff" -y ${PALLETE}
ffmpeg -i ${VIDEO} -i ${PALLETE} -lavfi "$FILTERS,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -r $RATE -f $FORMAT -y $FILE_NAME $EXTRA &> /tmp/ffmpeg.log

Expand Down Expand Up @@ -129,6 +133,10 @@ parse_args() {
echo "${PKG_VERSION}"
exit 0
;;
-t|--transpose)
TRANSPOSE="$2"
shift 2
;;
--no-watermark)
HIDE_WATERMARK=''
shift 1
Expand Down Expand Up @@ -165,6 +173,7 @@ display_help() {
echo " -r, --rate Framerate of the output (default: 15)"
echo " -f, --format Output format (default: gif)"
echo " -vf, --video-filter Video filter for ffmpeg (default: scale=320:-1:flags=lanczos)"
echo " -t, --transpose Transpose the video for landscape orientation (usually 1 for 90deg and 2 for 270deg)"
echo " --no-watermark Remove watermark from gif"
echo " -h, --help Outputs this help message"
echo " -v, --version Outputs the version number"
Expand Down

0 comments on commit cdf3169

Please sign in to comment.