Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: use ffmpeg from Rtools when available #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- {os: macos-14, r: 'release'}
- {os: windows-latest, r: '4.1'}
- {os: windows-latest, r: '4.2'}
- {os: windows-latest, r: '4.3'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-24.04, r: 'release'}
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.9.4
- Windows: use ffmpeg from Rtools when available

0.9.3
- Fixes for ffmpeg 7.1
- Cleanup configure script
Expand Down
20 changes: 16 additions & 4 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
PKG_CONFIG_NAME = libavfilter
PKG_CONFIG ?= $(BINPREF)pkg-config
PKG_LIBS := $(shell $(PKG_CONFIG) --libs $(PKG_CONFIG_NAME))

# See https://bugs.r-project.org/show_bug.cgi?id=18835
ifneq ($(findstring mp3lame,$(PKG_LIBS)),)
$(info using ffmpeg from Rtools)
PKG_CPPFLAGS := $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_NAME))
else
RWINLIB = ../windows/ffmpeg
PKG_CPPFLAGS = -I$(RWINLIB)/include -D__USE_MINGW_ANSI_STDIO=1 -DR_NO_REMAP -DSTRICT_R_HEADERS
PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,$(COMPILED_BY)}$(R_ARCH) \
Expand All @@ -6,11 +15,14 @@ PKG_LIBS = -L$(RWINLIB)/lib${subst gcc,,$(COMPILED_BY)}$(R_ARCH) \
-lvorbis -lvorbisenc -logg -lvpx \
-lbz2 -lsecur32 -lws2_32 -liconv -lz -lmp3lame -lx264 \
-lxvidcore -pthread -lole32 -lm -luser32 -lbcrypt -lmfplat -lmfuuid -lstrmiids
endif

all: winlibs clean
all: $(SHLIB)

clean:
rm -f $(SHLIB) $(OBJECTS)
$(OBJECTS): $(RWINLIB)

winlibs:
$(RWINLIB):
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"

clean:
rm -f $(SHLIB) $(OBJECTS)
2 changes: 1 addition & 1 deletion tests/testthat/test-audio.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("Audio can be converted to various formats", {
input_info <- av_media_info(wonderland)

# Convert mp3 to mkv (defaults to libvorbis audio)
expect_equal(av_audio_convert(wonderland, tmp_mkv, verbose = FALSE), tmp_mkv)
expect_equal(av_audio_convert(wonderland, tmp_mkv, verbose = FALSE, sample_rate = 24000), tmp_mkv)
expect_true(file.exists(tmp_mkv))
mkv_info <- av_media_info(tmp_mkv)
expect_equal(input_info$duration, mkv_info$duration, tolerance = 0.1)
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-fft.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ test_that("Audio FFT", {
av_log_level(16) # muffle some warnings about ac3 vbr
for(ext in extensions){
filename <- paste0('wonderland.', ext)
av_audio_convert(wonderland, filename, verbose = FALSE)
# libopus on fedora does not do support input sample_rate 44100
av_audio_convert(wonderland, filename, verbose = FALSE, sample_rate = 48000)
data <- read_audio_fft(filename, window = hanning(2048))
expect_equal(dim(data)[1], 1024)
expect_equal(dim(data)[2], 2584, tol = 0.001)
expect_equal(dim(data)[2], 2813, tol = 0.001)
unlink(filename)
}
})
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ test_that("Listing formats", {
expect_equal(names(decoders), c("type", "name", "description", "format"))
expect_equal(names(filters), c("name", "description"))
})

test_that("Critical encoders", {
encoders <- av_encoders()
expect_contains(encoders$name, 'libmp3lame')
expect_contains(encoders$name, 'libvorbis')
expect_contains(encoders$name, 'libxvid')
skip_on_os('linux')
# libx264 is not supported on Fedora libavfilter-free-devel
expect_contains(encoders$name, 'libx264')
})
Loading