沒(méi)錯(cuò)灾锯,我又回來(lái)了,還是為了得到MP3格式文件。
這次得到了質(zhì)的轉(zhuǎn)變他巨,用R語(yǔ)言實(shí)現(xiàn)MP4到MP3的格式轉(zhuǎn)換~
這次用到了一個(gè)很厲害的工具:ffmpeg
菜雞學(xué)習(xí)歷程:
如何下載b站視頻及音頻轉(zhuǎn)換
R腳本實(shí)現(xiàn)bilidown下載的視頻匯總
1 下載ffmpeg
自定義安裝位置。記住安裝位置减江,后面會(huì)用到染突。
2 R腳本
setwd("G:/Bilidown/download/save_folder")
mp3Folder = "E:/badai/MP3"
mp4Folder = "E:/badai/MP4"
do = list.files()
for(i in 1:length(do)){
# copy mp4 files
video_file = list.files(do[i], ".mp4")
cat("copyying flie:", video_file, "\n")
from = paste0(do[i], "/", video_file)
to = paste0(mp4Folder, "/", video_file)
file.copy(from, to)
cat("\n\n\n")
# transcode mp4 to mp3
cat("transcoding flie:", video_file, "\n")
input = paste0(do[i], "/", video_file)
output = paste0(mp3Folder, "/", gsub(".mp4", ".mp3", video_file))
cmd = paste("\"C:/Program Files/ffmpeg/bin/ffmpeg.exe\" -i", input, "-vn", output)
system(cmd)
}
我的fmpeg.exe
路徑是C:/Program Files/ffmpeg/bin/ffmpeg.exe
,這個(gè)要根據(jù)自己軟件的安裝路徑來(lái)決定辈灼,/bin/ffmpeg.exe
是固定的部分份企,前面部分就是你的軟件安裝路徑。
這篇文章寫(xiě)到這的時(shí)候巡莹,我突然想起來(lái)有的下載的視頻是要先剪輯才能用來(lái)轉(zhuǎn)換為MP3的(我只想要正式扒帶的部分)(笑cry)司志,搞那么久,才發(fā)現(xiàn)做的是無(wú)用功降宅,hhhh骂远。
不過(guò)至少學(xué)會(huì)了如何用R來(lái)實(shí)現(xiàn)視頻格式轉(zhuǎn)換了~我不哭
ffmpeg
功能很多,超全教程 --> [總結(jié)]FFMPEG視音頻編解碼零基礎(chǔ)學(xué)習(xí)方法