knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of tidymedia is to provide tools for easily working with media (e.g., image, audio, and video) files within R and the tidyverse.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jmgirard/tidymedia")
tidymedia uses MediaInfo to query information about media files. If you would like to use these functions, you will need to install the command line interface (CLI) version of this program. Links and instructions for doing so are available here. Below are instructions for several popular platforms.
Debian/Ubuntu
sudo apt-get install mediainfo
Windows
C:/Program Files/MediaInfo
tidymedia::set_mediainfo("C:/Program Files/MediaInfo/mediainfo.exe")
Mac
tidymedia uses FFmpeg to encode media files. If you would like to use these functions, you will need to install the command line interface (CLI) version of this program. Links and instructions for doing so are available here. Below are instructions for several popular platforms.
Debian/Ubuntu
sudo apt-get install ffmpeg
Windows
tidymedia
package in R.tidymedia::install_on_win()
in R.macOS Homebrew Install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install ffmpeg
macOS Manual Install
library(tidymedia)
# Interface with the mediainfo CLI mediainfo("--Version")
# Create a row tibble using a built-in template mediainfo_template(file = "C:/example.m4v", template = "brief")
knitr::kable(mediainfo_template(file = "C:/example.m4v", template = "brief"))
# Create a row tibble from specific parameters mediainfo_query( file = "C:/example.m4v", section = "Video", parameters = c("Width", "Height", "DisplayAspectRatio") )
knitr::kable(mediainfo_query( file = "C:/example.m4v", section = "Video", parameters = c("Width", "Height", "DisplayAspectRatio") ))
# Lookup common parameters get_duration(file = "C:/example.m4v", unit = "sec") get_height(file = "C:/example.m4v")
# Interface with the mediainfo CLI ffmpeg("-version")
# Query information about codecs from FFmpeg get_codecs()
# Query information about encoders from FFmpeg get_encoders()
# Create ffmpeg commands by pipeline ffm(input = "C:/example.m4v", output = "C:/example2.m4v") |> ffm_trim(start = 1, end = 5) |> ffm_crop(width = 640, height = 480) |> ffm_codec(video = "libx264") |> ffm_drop(streams = "audio") |> ffm_compile()
# Run ffmpeg commands by pipeline ffm(input = "C:/example.m4v", output = "C:/example2.m4v") |> ffm_trim(start = 1, end = 5) |> ffm_crop(width = 640, height = 480) |> ffm_codec(video = "libx264") |> ffm_drop(streams = "audio") |> ffm_run()
Please note that the tidymedia project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.