Skip to content

Commit

Permalink
Implement Cmd string macros (#3)
Browse files Browse the repository at this point in the history
* Implement Cmd string macros

* reformat code

* Test the cmd macros

* add missing )'s

* interpolate args in command strings
  • Loading branch information
asinghvi17 authored Jul 12, 2019
1 parent d0c1b06 commit aa18f7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
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

2 comments on commit aa18f7f

@asinghvi17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/1905

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" aa18f7f9462fbeb8db7408f67a52dd21784f907e
git push origin v0.1.0

Please sign in to comment.