Check if there is any audio in a Video file in Script

299 views
Skip to first unread message

Nate Zwainlesk

unread,
Apr 27, 2024, 12:33:12 AM4/27/24
to QLab
As part of a larger script I want to be able to check if a video cue has any audio in it, to decide if I need to duplicate it to do different things to the video and audio, but don't want to make those duplications if there is no audio.  I'm guessing there isn't any way of checking this natively in QLab and might need to make calls out to some other program, but my limited coding knowledge is being stretched with writing the script itself.  Any help would be appreciated. 

I'm writing a script to loop a single cue with a crossfade at the end.  The way I've figured to do it is to make a playlist cue with two copies of the same cue, with infinite loop and crossfade them.  I want it to use different crossfade settings for audio and video though. For audio I want a parametric curve to keep levels the same and for video I want it to have it only fade the opacity of the new one up and keep the one that's ending at full opacity until the end.  I'm doing this by having a premade loopSettingsVideo cue and a loopSettingsAudio with these parameters set how I want them, (because they aren't scriptable) and copying (with UI scripting, which is kinda annoying btw) those cues into the workspace, and moving and copying the sourceCue into their respective groups and setting opacity and volumes to zero in their opposite playlists.

But I'd like to not have to do all the duplication if there is no audio in a given video cue.  


~Thanks
Nate Zwainlesk

micpool

unread,
Apr 27, 2024, 6:14:06 AM4/27/24
to QLab
If you look in the QLab Applescript dictionary, you will find that video cues have a property

audio input channels 


Which is the number of audio channels in the first audio track of a video (The only track that QLab will play) This will be a number between 0 and 24.




tell application id "com.figure53.QLab.5" to tell front workspace

set theCues to cues whose q type is "video"

repeat with eachCue in theCues

if the audio input channels of eachCue = 0 then

--do something

set the q color of eachCue to "red"

else

--do something else

set the q color of eachCue to "green"

end if

end repeat

end tell


Mic

Chris Ashworth

unread,
Apr 27, 2024, 8:30:57 AM4/27/24
to micpool, ql...@googlegroups.com
On April 27, 2024 at 6:14:14 AM, micpool (m...@micpool.com) wrote:

Which is the number of audio channels in the first audio track of a video (The only track that QLab will play)


Hi Mic,

(And everyone.)

QLab can now actually play audio from other tracks in a video file as well.

If a video file has multiple audio tracks, you can select the track it plays from the I/O tab’s “audio format” popup button:



D90B2F48-B7D6-4B9C-8EB8-03A12F45BDE4

micpool

unread,
Apr 27, 2024, 10:06:07 AM4/27/24
to QLab
On Saturday, April 27, 2024 at 1:30:57 PM UTC+1 ch...@figure53.com wrote:

QLab can now actually play audio from other tracks in a video file as well.

Ah yes,, since 5.0. 

Thanks Chris

Mic

Nate Zwainlesk

unread,
Apr 27, 2024, 4:08:56 PM4/27/24
to QLab
Sadly that hasn't done the trick.  I'm getting false positives from files from Stock footage vendors that technically contain an audio track but have no audio content.
Message has been deleted

Nate Zwainlesk

unread,
Apr 27, 2024, 4:44:09 PM4/27/24
to QLab
I'm thinking that I could do it with the same tech you, Mic, used in this https://qlab.app/cookbook/level-playing-field/ tutorial, I'm not sure if that will read video files though.

micpool

unread,
Apr 27, 2024, 5:01:53 PM4/27/24
to QLab
The  only way to do this is to script playing  the first 10 secs of each cue  while using an OSC query to see if the audio exceeds a threshold .

A simpler alternative is to create an audio cue that targets the video file, rather than duplicating the video cue.  If the video file lacks an audio track, an error will be triggered

You can script deleting the audio cue if the error occurs

This doesn't solve your outlier files with silent audio tracks, but it is quicker and won't  affect performance to just create a crossfading silent audio cue rather than testing 10 seconds of each cue to detect audio in real time.

I'm also not convinced that it's impossible to find a curve that will give acceptable results for a single video cue that includes audio and video.

micpool

unread,
Apr 27, 2024, 5:04:28 PM4/27/24
to QLab
Yes, that would work as well..

micpool

unread,
Apr 27, 2024, 5:08:42 PM4/27/24
to QLab
although there would be just as many outliers, with audio formats that cli can't handle



Nate Zwainlesk

unread,
Apr 27, 2024, 5:42:28 PM4/27/24
to QLab
"A simpler alternative is to create an audio cue that targets the video file, rather than duplicating the video cue.  If the video file lacks an audio track, an error will be triggered
"
wait... what? I can target a video file with an audio cue to just get audio instead of a video cue with opacity at 0? That is a nice bit of info.  Is it more performant? cause that would be the icing on the cake of this new knowledge. 

Chris Ashworth

unread,
Apr 27, 2024, 5:47:08 PM4/27/24
to Nate Zwainlesk, ql...@googlegroups.com
Yes, an Audio cue will not decode the video portion of a video file, so if you just want the audio from the file that will do it more efficiently.

-C

Nate Zwainlesk

unread,
May 2, 2024, 5:30:14 PM5/2/24
to QLab
I think I might just query the user to answer if there is audio or not.  
The new issue I'm having is with the copy and pasting with the UI scripting.  When I have debugging "display dialog"s it works as expected, but when I take them out and even if I replace them with several second "delay"s it doesn't work.  I have a theory that it might have something to do with moving between cue lists to grab the copy target,  but i'm not certain. 

I've attached the file I'm working from if anyone wants to see or help.

There is an other cue list in there that has examples of the goal and examples of why I want different settings for different types of cues.

A. Johnson

unread,
May 4, 2024, 12:13:18 PM5/4/24
to ql...@googlegroups.com
Not to threadjack too much, but I’ve also been encountering the disparities between video with audo and video without audio a fair amount recently.

In a particular use case, we had sound and projection designers for a show merging cuelists. Projections needed to copy and integrate their cues into the sound cuelist so a single operator could run everything. This led us into a couple of difficulties.
Projections could repatch their cues to the appropriate Stage by selecting all cues, filtering to Video cues, and batch editing. However:
  • Video cues with an audio track (even if the track only contains silence) will not play unless they are patched to a valid audio output. So even though we didn’t care about the audio in any of the video files (the designer was Deaf), any with audio needed to be patched to an audio output before they would play.
  • We were not able to select all and repatch Audio Output with batch editing because any cues without an audio track (including stills, which is a thing I’ve encountered elsewhere) don’t have an audio output, and batch-select only shows attributes that every selected cue has in common. 

In short, the batch editing functionality of Video cues with audio is significantly curtailed if there are any cues without an audio track.

Things that would have made this easier at scale:
  • Being able to, in the dropdown for multiple selected files, select for Video cues with audio vs. Video cues without audio
  • Being able to batch edit audio of selected video cues and have it only apply to files with a valid audio track
  • Being able to play a video file without an audio patch - if it’s possible to have an Audio cue target a video file and not need a video output, why is it not possible to have a Video cue target a video file and not need an audio output?

I run into similar issues in other application as I work at a performing arts center where we’re often receiving a mishmash of files from a rental client rather than coordinated content from designers, and the difference in functionality between video files with audio and video files without audio has been biting me in batch edits a lot lately.

I recognize that all of these are fortunate problems to have, and am very grateful for the batch edit functionality that enables me to do things much faster than I could in earlier versions, but I wanted to interrogate some of the underlying assumptions and see if I’m the only one encountering these issues.

~~~AJ

---
Adam W. Johnson
Sound Designer / Audio and Video Supervisor


--
Contact support anytime: sup...@figure53.com
Follow QLab on Threads: https://threads.net/@QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/fa7d9091-d6ba-48fb-b852-426f3c94c40cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages