How to play a soundless video and add a audio file at the same time?
Solution 1
How to play a soundless video and add a audio file at the same time?
I want to play the video and add the sound.
With the (experimental) --input-slave
swtich.
Is there a way to get it done with the command line?
If your video has no audio tracks, then you can simply use something like the following:
vlc example.mp4 --input-slave=example.mp3
If your video does have an audio track, then VLC will use that by default, so you have to specify the alternate track as so:
vlc exmaple.mp4 --input-slave=example.mp3 --audio-track=1
If your video has two audio tracks, then you would use --audio-track=2
and so on (the first track is 0
, so the number you use for the external audio is equal to the number audio tracks in the video).
Also, you can (currently) only specify a single external audio track, so this will not work:
vlc example.mp4 --input-slave=example.mp3 --input-slave=example2.mp3
In this case, VLC only uses the last one specified.
Solution 2
I wanted the same thing it seems. I have an app launcher I wrote in powershell, and of the things I have it doing is to create a random 8-track playlist from my music library and it slaves a random visualization video over the top in fullscreen mode.
Looks something like this: 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++
}
Related videos on Youtube
Atlus
Updated on September 18, 2022Comments
-
Atlus over 1 year
I have a folder with a MP3 audio file and an video file. Both named the same.
- Example.mp3
- Example.mp4
I want to play the video and add the sound.
Both files should stay the same and I do not want any new file with both in it.Is there a way to get it done with the command line?
-
nixda over 10 yearsJust a start for others who want to help: Theoretically VLC can do this via its GUI. Next step would be to find the correct command line syntax
-
Atlus over 10 yearsOK i did manage to find the Command line Syntax its: % vlc audiofile --input-slave videofile
-
nixda over 10 yearsPlease post your solution as an answer. You could and should also accept your own answer
-
user3067533 about 8 yearsNote: input slave is still pretty fussy imo. I left the loop in hopes that in the future, you will be able tp slave more than one file.
-
user3067533 about 8 yearsNote: input slave is slaved to the track not the queue. So your video should be short and sweet with a graceful start-end loop as it can be jarring when the video abruptly resets every track. I muxed a bunch of these together in various orders and it seems to do the trick of randomizing the visualizations dreamscene.org/gallery.php
-
user3067533 about 8 yearsCurrently using these: youtube.com/watch?v=oM_Ibhqx35s