Skip to content

Commit 100263f

Browse files
committed
remove ari dependency
1 parent bc7a0e6 commit 100263f

File tree

9 files changed

+40
-22
lines changed

9 files changed

+40
-22
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Title: Dynamic Spectrogram Visualizations
44
Version: 1.0.4
55
Description: A set of tools to generate dynamic spectrogram visualizations in video format.
66
License: GPL (>= 2)
7-
Imports: utils, grDevices, graphics, seewave, tuneR, grid, png, ggplot2, viridis, scales, ari, gganimate, warbleR
7+
Imports: utils, grDevices, graphics, seewave, tuneR, grid, png, ggplot2, viridis, scales, gganimate, warbleR
88
Depends: R (>= 3.2.1)
99
LazyData: TRUE
1010
SystemRequirements: ffmpeg

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Fixed destFolder parameter in prep_static_ggspectro() and paged_spectro()
33
* Should have more expected results for file save locations outside the working directory
44
* Fixed issue where extra page sometimes created with paged_spectro()
5+
* Remove 'ari' package dependency
56

67
# *dynaSpec 1.0.3*
78

R/dynaSpec-package.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#' @importFrom png readPNG
1111
#' @importFrom warbleR pblapply_wrblr_int
1212
#' @importFrom scales modulus_trans
13-
#' @importFrom ari have_ffmpeg_exec ffmpeg_exec
1413
#' @importFrom png readPN
1514
#' @importFrom grid grid.raster
1615
#' @importFrom parallel makePSOCKcluster

R/internal_functions.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,25 @@ warning2 <- function (...)
1111
warning(..., call. = FALSE)
1212
}
1313

14+
# functions adopted from ari to check if ffmpeg is installed
15+
ffmpeg_exec2 <- function(quote = FALSE) {
16+
candidates <- c(Sys.getenv("ffmpeg"), Sys.which("ffmpeg"))
17+
ffmpeg <- candidates[nchar(candidates) > 0][1]
18+
if (is.na(ffmpeg)) {
19+
stop("Could not find ffmpeg")
20+
}
21+
if (!ffmpeg %in% c("ffmpeg", "ffmpeg.exe")) {
22+
ffmpeg = normalizePath(ffmpeg, winslash = "/")
23+
}
24+
if (quote) {
25+
ffmpeg = shQuote(ffmpeg)
26+
}
27+
return(ffmpeg)
28+
}
1429

30+
have_ffmpeg_exec2 <- function(){
31+
exec = try({
32+
ffmpeg_exec2()
33+
}, silent = TRUE)
34+
!inherits(exec, "try-error")
35+
}

R/paged_spectro.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ paged_spectro <- function(specParams,
6666
{
6767
xmin <- ymin <- xmax <- ymax <- NULL
6868
#This ^^ suppresses note about "no visible binding for global variable ‘xmax’"
69-
if (!ari::have_ffmpeg_exec()) {
69+
if (!have_ffmpeg_exec2()) {
7070
cat("\n*****This script needs ffmpeg to work*****\n")
7171
cat("If you have a mac, with HomeBrew installed, you can fix this easily
7272
in terminal with:\n")
7373
cat("\n>\tbrew install ffmpeg\n")
74+
cat("If you have are on a linux computer:\n")
75+
cat("\n>\tsudo apt install ffmpeg\n")
76+
7477
cat("\nIf not, download and install it from ffmpeg.org")
7578
} else{
7679
if (is.null(destFolder)) {
@@ -330,7 +333,7 @@ paged_spectro <- function(specParams,
330333
#slight stutter for continuous sounds across segments, but the alternative step below doesn't work quite right, so good enough
331334
system(
332335
paste0(
333-
ari::ffmpeg_exec(),
336+
ffmpeg_exec2(),
334337
' -f concat -ss 00:00:00.000 -safe 0 -i "',
335338
fs::path(tempdir, "mp4Segments.txt"),
336339
'" -codec copy -y "',
@@ -343,11 +346,11 @@ paged_spectro <- function(specParams,
343346
#Concat Step 2
344347
#Add audio track back in (couldn't figure how to combine these steps)
345348
#THIS STEP CURRENTLY DOESN'T WORK WELL (DROPS LAST FEW FRAMES B/C MISMATCH IN A/V LENGTHS)
346-
# system(paste0(ari::ffmpeg_exec(),' -ss 0 -i "',paste0(tempdir,"deleteme.mp4"),'" -i "',newWavOut,'" -c:v libx264 -map 0:v:0 -map 1:a:0 -c:a aac -ac 1 -b:a 192k -y -vsync 1 -t ',cropFileDur3,' "',vidName,'"'))
349+
# system(paste0(ffmpeg_exec2(),' -ss 0 -i "',paste0(tempdir,"deleteme.mp4"),'" -i "',newWavOut,'" -c:v libx264 -map 0:v:0 -map 1:a:0 -c:a aac -ac 1 -b:a 192k -y -vsync 1 -t ',cropFileDur3,' "',vidName,'"'))
347350

348351

349352
#Old Concat Step 1 (when step 2 is implemented); results in deleteme.mp4 intermediate
350-
# system(paste0(ari::ffmpeg_exec(),' -f concat -safe 0 -i "',paste0(tempdir,"mp4Segments.txt"),'" -codec copy -y "',paste0(tempdir,"deleteme.mp4"),'"'))
353+
# system(paste0(ffmpeg_exec2(),' -f concat -safe 0 -i "',paste0(tempdir,"mp4Segments.txt"),'" -codec copy -y "',paste0(tempdir,"deleteme.mp4"),'"'))
351354

352355

353356
}

dynaSpec.Rproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Version: 1.0
2-
ProjectId: 22075ac6-f94b-45d1-b337-4bfd98a13a4f
2+
ProjectId: b11678cd-19a3-4ba7-b4b3-3ec4cf6295df
33

44
RestoreWorkspace: Default
55
SaveWorkspace: Default

man/paged_spectro.Rd

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/prep_static_ggspectro.Rd

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scrolling_spectro.Rd

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)