-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stacking_LGA_flight_history.R
126 lines (93 loc) · 3.72 KB
/
Stacking_LGA_flight_history.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
###########################################################################################-
###########################################################################################-
##
## Animating LGA flight history ----
##
###########################################################################################-
###########################################################################################-
#=========================================================================================#
# Setting up ----
#=========================================================================================#
#-----------------------------------------------------------------------------------------#
# Loading libraries
#-----------------------------------------------------------------------------------------#
library(tidyverse)
library(lubridate)
library(glue)
library(fs)
#-----------------------------------------------------------------------------------------#
# Which dates are we combining?
#-----------------------------------------------------------------------------------------#
video_date_1 <- "2020-03-16" %>% as_date()
video_date_2 <- "2020-04-06" %>% as_date()
#-----------------------------------------------------------------------------------------#
# Getting video paths
#-----------------------------------------------------------------------------------------#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Paths
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
plots_files <- dir_ls("plots/videos")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Choosing among potential options
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#==== Video 1 ====#
video_1_choices <-
plots_files %>%
str_subset(as.character(video_date_1))
if (length(video_1_choices) > 1) {
video_1 <-
menu(
choices = video_1_choices,
graphics = TRUE,
title = "Which video do you want to use for video_1?"
) %>%
pluck(video_1_choices, .)
} else {
video_1 <- video_1_choices
}
#==== Video 2 ====#
video_2_choices <-
plots_files %>%
str_subset(as.character(video_date_2))
if (length(video_2_choices) > 1) {
video_2 <-
menu(
choices = video_2_choices,
graphics = TRUE,
title = "Which video do you want to use for video_2?"
) %>%
pluck(video_2_choices, .)
} else {
video_2 <- video_2_choices
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Root of the video name
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
video_name_root <-
video_1 %>%
path_file() %>%
path_ext_remove() %>%
str_remove(as.character(video_date_1))
#=========================================================================================#
# Stacking ----
#=========================================================================================#
system(
glue(
"ffmpeg -hide_banner -y",
"-i {video_1}",
"-i {video_2}",
"-filter_complex hstack=inputs=2",
"-c:v libx265",
"-x265-params range=full:qp=20",
"-pix_fmt yuvj420p",
"plots/videos/{video_name_root}-_{video_date_1}_vs._{video_date_2}.mp4",
.sep = " "
)
)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# # ---- THIS IS THE END! ----
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #