r - 是否可以在R中读取.wma声音文件?

标签 r audio wma

有没有办法读取R中的.WMA声音文件,或者版权限制不允许这样做?

最终目的是将其转换为另一种格式(MP3 / WAV)

最佳答案

R音频包以一种或另一种方式使用ffmpeg转换器。

请查看以下选项:

  • 下载后,您可以使用R将WMA转换为MP3文件格式
    直接通过system函数调用;
  • 或您可以使用ffmpeg包装程序包进行简单的音频转换。但是,它是面向Linux的,可以轻松转换为与Windows兼容的操作系统。

  • 请参见下面的代码以了解选项2:
    # install.packages("devtools")
    # library(devtools)
    # install_github("pmur002/ffmpeg")
    
    library(ffmpeg)
    
    # set path to your ffmpeg.exe file
    ffmpeg_path <- "C:\\<Path to ffmpeg>\\ffmpeg-20180906-70a7087-win64-static\\bin\\ffmpeg.exe"
    
    ffmpeg_win <- function (inputs, outputs, filters = NULL, overwrite = FALSE, 
                            wait = TRUE, echo = FALSE) {
      if (!is.null(filters)) {
        stop("Filters are currently unsupported")
      }
      if (inherits(inputs, "FFmpeg_input")) {
        inputs <- list(inputs)
      }
      if (inherits(outputs, "FFmpeg_output")) {
        outputs <- list(outputs)
      }
      options <- ""
      if (overwrite) {
        options <- paste0(options, "-y ")
      }
      cmd <- paste(ffmpeg_path, options, do.call(paste, inputs), do.call(paste, 
                                                                         outputs))
      system(cmd, wait = wait)
      if (echo) {
        cat(cmd, "\n")
      }
    }
    
    # just copy to your working directory required file, here is for example "mellow.wma"
    ffmpeg_win(fileInput("mellow.wma"), fileOutput("mellow.mp3"), echo = TRUE)
    

    关于r - 是否可以在R中读取.wma声音文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52224416/

    相关文章:

    javascript - 播放和暂停播放声音

    swift - 如何在底部面板中存储当前音频信息(AVAudioPlayer,Swift)

    windows - 在 CBR 音频编码中指定所需比特率的属性名称

    r - scale_x_date 删除轴上的额外月份(ggplot2 2.2.0.9)

    r - 设置 y 轴位置时向内对齐 y 轴标签 "right"

    r - Shiny 的传单多边形点击事件

    R ggplot2 stat_density2d 网格

    Java AudioSystem 和 TargetDataLine

    .net - 是否可以在不使用Windows Media Player的情况下获取WMA文件的长度?