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

Implement Cmd string macros #3

Merged
merged 5 commits into from
Jul 12, 2019
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ FFMPEG.exe("-version")
ffmpeg_exe("-version")
ffmpeg_exe(`-version`)
ffprobe_exe("-version") # we wrap FFPROBE too!
ffmpeg`-version` # Cmd string macros too
ffprobe`-version`
# the AV libraries:
FFMPEG.libavcodec
FFMPEG.libavformat
Expand Down
24 changes: 21 additions & 3 deletions src/FFMPEG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using BinaryProvider
const libpath = joinpath(@__DIR__, "..", "deps", "usr", "lib")

if Sys.iswindows()
const execenv = ("PATH" => string(libpath,";", Sys.BINDIR))
const execenv = ("PATH" => string(libpath, ";", Sys.BINDIR))
elseif Sys.isapple()
const execenv = ("DYLD_LIBRARY_PATH" => libpath)
else
Expand All @@ -23,7 +23,7 @@ end
include(depsjl_path)


av_version(v) = VersionNumber(v>>16,(v>>8)&0xff,v&0xff)
av_version(v) = VersionNumber(v >> 16, (v >> 8) & 0xff, v & 0xff)

have_avcodec() = Libdl.dlopen_e(libavcodec) != C_NULL
have_avformat() = Libdl.dlopen_e(libavformat) != C_NULL
Expand Down Expand Up @@ -139,6 +139,24 @@ Execute the given arguments as arguments to the `ffprobe` executable.
"""
ffprobe_exe(args...) = exe(args...; command = ffprobe)

export ffmpeg_exe, @ffmpeg_env, ffprobe_exe, ffmpeg, ffprobe
"""
ffmpeg\`<ARGS>\`

Execute the given arguments as arguments to the `ffmpeg` executable.
"""
macro ffmpeg_cmd(arg)
esc(:(ffmpeg_exe($arg)))
end

"""
ffprobe\`<ARGS>\`

Execute the given arguments as arguments to the `ffprobe` executable.
"""
macro ffprobe_cmd(arg)
esc(:(ffprobe_exe($arg)))
end

export ffmpeg_exe, @ffmpeg_env, ffprobe_exe, ffmpeg, ffprobe, @ffmpeg_cmd, @ffprobe_cmd

end # module
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ end

@testset "FFMPEG.jl" begin
@show FFMPEG.versioninfo()
@test text_execute(()-> FFMPEG.exe("-version"))
@test text_execute(() -> FFMPEG.exe("-version"))
@test text_execute(() -> FFMPEG.exe(`-version`))
@test text_execute(() -> FFMPEG.ffmpeg_exe(`-version`))
@test text_execute(() -> FFMPEG.ffprobe_exe(`-version`))
@test text_execute(() -> ffmpeg`-version`)
@test text_execute(() -> ffprobe`-version`)
@test text_execute(() -> @ffmpeg_env run(`$ffmpeg -version`))
end