Conditional encode based on audio language flag
Conditional encode based on audio language flag
Hi I just found this software a couple of weeks ago and I am considering it as an option to a more expensive option like a Telestream Vantage system at the office.
I have one question that has come to mind in my initial investigations, and I'm sore more will come up, but since I don't see a trackable variable to do what I am looking for, learning if this is possible may help me figure out other things.
Is it possible to parse a multi language source file based on an audio track language flag and encode based on the data returned per channel.
(ie. source video file with 2 languages flagged as English and French, and I want to either encode only one language into my output file or set up 2 encodes so 2 versions are encoded)
This may require counting audio streams and then looping through the data to fill a number of variables or an array that match the counted streams, or some similar process.
Is this possible with the tools that are in place? If not, is it possible to add variables to capture this data?
Thanks in advance,
Bern
I have one question that has come to mind in my initial investigations, and I'm sore more will come up, but since I don't see a trackable variable to do what I am looking for, learning if this is possible may help me figure out other things.
Is it possible to parse a multi language source file based on an audio track language flag and encode based on the data returned per channel.
(ie. source video file with 2 languages flagged as English and French, and I want to either encode only one language into my output file or set up 2 encodes so 2 versions are encoded)
This may require counting audio streams and then looping through the data to fill a number of variables or an array that match the counted streams, or some similar process.
Is this possible with the tools that are in place? If not, is it possible to add variables to capture this data?
Thanks in advance,
Bern
Re: Conditional encode based on audio language flag
Hi Bern,
for your example (ie. source video file with 2 languages flagged as English and French, and I want to either encode only one language into my output file or set up 2 encodes so 2 versions are encoded) this is possible by at least three ways:
1. Use the Channel-Mapper-Node ( PickUp -> A/V-Media -> Channel-Mapper -> EncoderNode -> Delivery-Node )
2. Use a custom FFmpeg-Node ( PickUp -> CustomFFmpeg-Node [with custom FFMPEG-commands] -> Delivery-Node ). This enables you to choose the language you want, IF the AudioStream is flagged correctly.
3. Use FFprobe and some CMD in CommandExecutor-Node plus PopulateVariables and Conditional-Node to totally control your Picked-Up-Files ( PickUp -> CommandExecutor with FFprobe-Command ECHO in tmp.txt-File -> CommandExecutor with CMD FOR F (FINDSTR [RegularExpression] in tmp.txt) Echo in var.txt -> PopulateVariables-Node with READ(var.txt) or REGEX(READ(var.txt) [make a user-Variable first] ->
[1st] ConditionalNode with conditions -> Encoder- or CustomFFmpeg-Node on Conditional success |
OnError 1st Conditional-Node [2nd] ConditionalNode with conditions -> Encoder- or CustomFFmpeg-Node on Conditional success |
[...]
-> Delivery-Folder
just my two cents...
Happy coding,
tom
btw: Maybe it´s a good idea to have Language-flags in the Media-Property-Dropdown... (#Steinar...? #emcodem...?)
for your example (ie. source video file with 2 languages flagged as English and French, and I want to either encode only one language into my output file or set up 2 encodes so 2 versions are encoded) this is possible by at least three ways:
1. Use the Channel-Mapper-Node ( PickUp -> A/V-Media -> Channel-Mapper -> EncoderNode -> Delivery-Node )
2. Use a custom FFmpeg-Node ( PickUp -> CustomFFmpeg-Node [with custom FFMPEG-commands] -> Delivery-Node ). This enables you to choose the language you want, IF the AudioStream is flagged correctly.
3. Use FFprobe and some CMD in CommandExecutor-Node plus PopulateVariables and Conditional-Node to totally control your Picked-Up-Files ( PickUp -> CommandExecutor with FFprobe-Command ECHO in tmp.txt-File -> CommandExecutor with CMD FOR F (FINDSTR [RegularExpression] in tmp.txt) Echo in var.txt -> PopulateVariables-Node with READ(var.txt) or REGEX(READ(var.txt) [make a user-Variable first] ->
[1st] ConditionalNode with conditions -> Encoder- or CustomFFmpeg-Node on Conditional success |
OnError 1st Conditional-Node [2nd] ConditionalNode with conditions -> Encoder- or CustomFFmpeg-Node on Conditional success |
[...]
-> Delivery-Folder
just my two cents...
Happy coding,
tom
btw: Maybe it´s a good idea to have Language-flags in the Media-Property-Dropdown... (#Steinar...? #emcodem...?)
Re: Conditional encode based on audio language flag
Hey,
that answer is excellent Thomas, very spot on! ...and Bern please let us know if you have any troubles following what Thomas said.
Starting with Version 1, we will have the option to add new Processors on the fly ("plugin processors"). I would wait a little until this feature is final and released and then come up with a new processor called "media query", that allows you to query for certain values contained in the mediainfo.
Or maybe even better, to have the Mediainfo result json available as a variable and provide some json parsing "functions". But currently we will not implement any more features basically into Version1, just find and solve bugs. <--- we need everybodies help on that, please try/use the latest beta and let us know what you find.
Anyway, any "solution" is far away (some months), so @BernH you will need to use one of the solutions that Thomas provided.
that answer is excellent Thomas, very spot on! ...and Bern please let us know if you have any troubles following what Thomas said.
The problem with langauge tags as "inbuilt variables" is that it is more a "list" than a plain "value". If you watch the current variables closely, there are not yet any "lists" (e.g. audio codec, video codec, it all regards to the "first stream" in the file).Maybe it´s a good idea to have Language-flags in the Media-Property-Dropdown...
Starting with Version 1, we will have the option to add new Processors on the fly ("plugin processors"). I would wait a little until this feature is final and released and then come up with a new processor called "media query", that allows you to query for certain values contained in the mediainfo.
Or maybe even better, to have the Mediainfo result json available as a variable and provide some json parsing "functions". But currently we will not implement any more features basically into Version1, just find and solve bugs. <--- we need everybodies help on that, please try/use the latest beta and let us know what you find.
Anyway, any "solution" is far away (some months), so @BernH you will need to use one of the solutions that Thomas provided.
emcodem, wrapping since 2009 you got the rhyme?
Re: Conditional encode based on audio language flag
Thanks, I have started looking into the options Thomas outlined. Currently I am trying to wrap my head around which solution would be the simplest and still allow me to isolate as required. I usually try not to build Rube Goldberg types of setups, so simpler is usually better and more reliable.
This is going to be a somewhat slow process for me, as I am trying to evaluate this in my free time while working on a TV series that we are currently producing.
I have done some evaluations of Telestream Vantage and Imagine Selenio systems but I am always on the lookout for more cost effective solutions, which is why I started looking at FFastrans as an option.
The Mediainfo query or json parsing sounds like a good idea to me, as that could be a very flexible way to make intelligent processing decisions. This is essentially how the afore mentioned Vantage and Selenio systems work. They allow for a media query and then make the discovered metadata fields available for decision making. This is not limited to just a language field, but includes any found metadata.
Selenio even has a couple of nice "process monitoring nodes" that can be added to the GUI to allow for live sampling of the process, showing little video and audio monitors to help in checking that status at different points in a workflow when designing. While this is not an essential feature, it did make the design process a little easier.
This is going to be a somewhat slow process for me, as I am trying to evaluate this in my free time while working on a TV series that we are currently producing.
I have done some evaluations of Telestream Vantage and Imagine Selenio systems but I am always on the lookout for more cost effective solutions, which is why I started looking at FFastrans as an option.
The Mediainfo query or json parsing sounds like a good idea to me, as that could be a very flexible way to make intelligent processing decisions. This is essentially how the afore mentioned Vantage and Selenio systems work. They allow for a media query and then make the discovered metadata fields available for decision making. This is not limited to just a language field, but includes any found metadata.
Selenio even has a couple of nice "process monitoring nodes" that can be added to the GUI to allow for live sampling of the process, showing little video and audio monitors to help in checking that status at different points in a workflow when designing. While this is not an essential feature, it did make the design process a little easier.
Re: Conditional encode based on audio language flag
Bern,
IF you can be sure that FRENCH is always STREAM(0) AND ENGLISH is always STREAM(1) then I would suggest Workflow [2] with the CustomFFmpeg-Node as the most efficient solution. You will have the least Nodes and overall a maximum control of the encoding-process and the fastest process as the Media-A/V-Node mentioned in Workflow [1] takes some time to evaluate the PickedUp Files.
IF the streams differ from time to time you will have to go like Workflow [3] tailored to your needs.
Hope you can go Workflow [2] this time!
@emcodem: THX! We are all curious what V1 will bring. MediaInfo and tools for using these Values will be a great progression. Looking forward...
Regards,
tom
IF you can be sure that FRENCH is always STREAM(0) AND ENGLISH is always STREAM(1) then I would suggest Workflow [2] with the CustomFFmpeg-Node as the most efficient solution. You will have the least Nodes and overall a maximum control of the encoding-process and the fastest process as the Media-A/V-Node mentioned in Workflow [1] takes some time to evaluate the PickedUp Files.
IF the streams differ from time to time you will have to go like Workflow [3] tailored to your needs.
Hope you can go Workflow [2] this time!
@emcodem: THX! We are all curious what V1 will bring. MediaInfo and tools for using these Values will be a great progression. Looking forward...
Regards,
tom
Re: Conditional encode based on audio language flag
@BernH @ThomasM
Stupid me, i have overseen that the requested functionality is already there in Version 1 Beta7. @Bern, from feeling; if you dont yet have any productive workflow on 094, it is best for you to start with the latest Beta anyway... It is the last beta before release of Version1 and the featureset changed dramatically...
Usage in a populate vars processor in Version 1:
You should maybe use a text file processor to write %s_info_ffprobe% to a file and investigate how it looks like. In above example, i select the "second" streamm (streams[1].tags.language). The first one is typically a video stream. To select the third stream, use streams[2].tags.language.
So the workflow for Bern would probably look like that:
Populate variables processor: set at least 2 user variables, e.g:
s_tag1 = $jsonget('%s_info_ffprobe%',"streams[1].tags.language")
s_tag2 = $jsonget('%s_info_ffprobe%',"streams[2].tags.language")
then use a conditional variable to check the actual value of tag1 and tag2 etc...
Stupid me, i have overseen that the requested functionality is already there in Version 1 Beta7. @Bern, from feeling; if you dont yet have any productive workflow on 094, it is best for you to start with the latest Beta anyway... It is the last beta before release of Version1 and the featureset changed dramatically...
Usage in a populate vars processor in Version 1:
Code: Select all
$jsonget('%s_info_ffprobe%',"streams[1].tags.language")
So the workflow for Bern would probably look like that:
Populate variables processor: set at least 2 user variables, e.g:
s_tag1 = $jsonget('%s_info_ffprobe%',"streams[1].tags.language")
s_tag2 = $jsonget('%s_info_ffprobe%',"streams[2].tags.language")
then use a conditional variable to check the actual value of tag1 and tag2 etc...
emcodem, wrapping since 2009 you got the rhyme?
Re: Conditional encode based on audio language flag
In an attempt to try to understand this json parsing, I have been using your example
populate variable s_tag1 = jsonget('%s_info_ffprobe%',"streams[1].tags.language") as a source for writing the s_tag1 field in a text file generator to ensure I am parsing the correct value before continuing on to design the rest of a workflow, but it always seems to write out the entire ffprobe text.
Do you have a syntax guide for me to reference?
populate variable s_tag1 = jsonget('%s_info_ffprobe%',"streams[1].tags.language") as a source for writing the s_tag1 field in a text file generator to ensure I am parsing the correct value before continuing on to design the rest of a workflow, but it always seems to write out the entire ffprobe text.
Do you have a syntax guide for me to reference?
Re: Conditional encode based on audio language flag
ok, so in your populate proc, on the right side, there is only this, correct?
if that is the case, the variable on the left side should never be able to contain the full ffprobe json. Can you maybe just export your workflow so i can see whats the issue for you?
By the way, instead of a text file, you can just set the variable s_success to the value of interest so you see the value in the job monitor "outcome" column quickly.
The Syntax for the second argument of jsonget function (above "streams[1].tags.language") is just called JSON dot notation, widely known in the programming world. To play around, you can for example use some online tool like this
http://jsonpathfinder.com/
Where you paste your ffprobe json on the left and on the right side, expand and click the value you want to get - it should give you the json dot notated path you need to use.
Code: Select all
$jsonget('%s_info_ffprobe%',"streams[1].tags.language")
By the way, instead of a text file, you can just set the variable s_success to the value of interest so you see the value in the job monitor "outcome" column quickly.
The Syntax for the second argument of jsonget function (above "streams[1].tags.language") is just called JSON dot notation, widely known in the programming world. To play around, you can for example use some online tool like this
http://jsonpathfinder.com/
Where you paste your ffprobe json on the left and on the right side, expand and click the value you want to get - it should give you the json dot notated path you need to use.
emcodem, wrapping since 2009 you got the rhyme?
Re: Conditional encode based on audio language flag
Yes the right side of the populate node only has $jsonget('%s_info_ffprobe%',"streams[1].tags.language"), and it was direct copy and paste from your post. The left the has the user variable s_tag1. I am attaching my simple 3 node workflow I was using to try to parse this info.
I am an electronics and computer technician by trade, not a programmer, but have done some programming in older languages when I was younger and some proprietary languages for A/V control systems, so I do tend to have a logical thought process and like to understand what I am doing. Json notation is relatively new to me, but I have had to parse files in those other languages, so it should be similar, if I can get my head wrapped around it. The link to the json path finder site should help a lot. Then it's just to take action based on those variables, which shouldn't be too difficult.
I am an electronics and computer technician by trade, not a programmer, but have done some programming in older languages when I was younger and some proprietary languages for A/V control systems, so I do tend to have a logical thought process and like to understand what I am doing. Json notation is relatively new to me, but I have had to parse files in those other languages, so it should be similar, if I can get my head wrapped around it. The link to the json path finder site should help a lot. Then it's just to take action based on those variables, which shouldn't be too difficult.
- Attachments
-
- Test Workflow.zip
- (1.25 KiB) Downloaded 391 times
Re: Conditional encode based on audio language flag
got it, thanks. your workflow works as expected for me, e.g. the written file is empty when my input file has no language tag. Is it true that you see the full ffprobe json in the text file?
emcodem, wrapping since 2009 you got the rhyme?