
我有一個包含 MP3 音訊檔案和視訊檔案的資料夾。兩者名字相同。
- 範例.mp3
- 範例.mp4
我想播放影片並添加聲音。
兩個文件應該保持不變,我不想要任何包含這兩個文件的新文件。
有沒有辦法透過命令列完成它?
答案1
如何同時播放無聲影片並添加音訊檔案?
我想播放影片並添加聲音。
使用(實驗性)--input-slave
開關。
有沒有辦法透過命令列完成它?
如果您的影片沒有音軌,那麼您可以簡單地使用如下所示的內容:
vlc example.mp4 --input-slave=example.mp3
如果您的影片確實有音軌,則 VLC 將預設使用該音軌,因此您必須按以下方式指定備用軌道:
vlc exmaple.mp4 --input-slave=example.mp3 --audio-track=1
如果您的影片有兩個音軌,那麼您將使用--audio-track=2
等等(第一個音軌是0
,因此您用於外部音訊的數量等於影片中音軌的數量)。
另外,您(目前)只能指定單一外部音軌,因此這不起作用:
vlc example.mp4 --input-slave=example.mp3 --input-slave=example2.mp3
在這種情況下,VLC 僅使用最後指定的一個。
答案2
我似乎想要同樣的東西。我有一個用 powershell 編寫的應用程式啟動器,我用它做的事情就是從我的音樂庫中創建一個隨機的 8 首曲目播放列表,並在全螢幕模式下在頂部播放一個隨機可視化視頻。
看起來像這樣:vlc.ps1
#cache variables
$videopath = "C:\path\to\your\mp4\videos"
$musicpath = "C:\path\to\your\music"
$numtracks = 8
$slave = @()
$slavecount =0
$rand = 0
$track = ""
$i=0
#Grab a random video
Get-Childitem -Path $videopath -Include *.mp4, *.avi, *.mkv -Recurse |
Foreach {
# Flip those slashes around
$slave += $_.Fullname -replace "\\","/"
}
$slavecount = $slave.Count
# Build a random 8-track
Get-Childitem -Path $musicpath -Include *.mp3, *.flac -Recurse |
Get-Random -Count $numtracks |
Foreach {
#Choose a random video from the array of videos
# This only used if they fix VLC to allow multiple slaves
$rand = Get-Random -Minimum 0 -Maximum $slavecount
# Add the double quotes just how vlc likes it
$track = """" + $_.Fullname + """"
if ($i -lt 1) {
#start vlc, queue your first track and slave the random visualization
vlc --started-from-file --play-and-stop $track --input-slave=file:///$slave[$rand] --fullscreen
} else {
#now enqueue the remaining tracks
#if multiple slaves are eventually supported this whole if statement can be removed
vlc --started-from-file --playlist-enqueue $track
}
$i++
}