A simple video script
The other day, I wanted to prepare some videos of my favorite reggae and soul tunes for uploading them to YouTube. My goal was very simple: prepare a video with the music, and a static image.
After briefly digging for a simple software to do that, which I could not find, I said ``hey, why not doing it with liquidsoap’’? Well, that is fairly easy!
Here is the code:
# Log to stdout
set("log.file",false)
set("log.stdout",true)
set("log.level",4)
# Enable video
set("frame.video.width",640)
set("frame.video.height",480)
"/tmp/bla.mp3"
audio_file = "/tmp/bla.jpg"
video_file =
# Grab file's title
request.create(audio_file)
r =
title = if request.resolve(r) then
request.metadata(r)
meta = "title"]
meta[else
# File not readable
log("Error: cannot decode audio file!")
shutdown () ""
end
title = if title == "" then
"Unknow title"
else
titleend
# The audio song.
request.queue(interactive=false,queue=[r])
audio =
# Create a video source with the image for video track
single(video_file)
video =
# Mux audio and video
#source = mux_audio(audio=audio,video)
mux_video(video=video,audio)
source =
# Disable real-time processing, to process with the maximun speed
clock(sync=false,source)
source =
# Output to a theora file, shutdown on stop
output.file(%ogg(%vorbis,%theora),
id="youtube",fallible=true,
on_stop=shutdown,reopen_on_metadata=true,
"/tmp/#{title}.ogv",
source)
This should produce on file named <title>.ogv
where <title>
is the title metadata of your song.
Inspired from blog.rastageeks.org.