'Gstreamer: Is there plugins to mux G711 audio into h264 video to a file and also to demux it back to its respective component

The question is as above. Would like to know if there is a plugin within Gstreamer that can mux video and G711 (pcma, pcmu) audio to a file

I have tried with matroskamux but I could not get demux to be correct. below is one cli command that i have tried

 gst-launch-1.0 -e -v \
    filesrc location=20210324_210409_210509.mp4 \
        ! queue \
        ! matroskademux name=demux \
       demux.video_0 \
        ! queue \
        ! rtph264pay config-interval=1 name=pay0 pt=96 \
        ! udpsink host="192.168.50.11" port=3000
       demux.audio_0 \
        ! queue \
        ! rtppcmupay name=pay1 pt=97 \
        ! udpsink host="192.168.50.11" port=3002 

I have also thought about using mpegtsmux and save the stream produced but it required audio to be lpcm(linear pcm). I am not too sure of how to achieve this under gstreamer. Any suggestions?

Thanks



Solution 1:[1]

Short answer: If the result you want is ['cos', '(', 'x', ')'], you need something like '(cos|sin|tan|[)(-*x]|\d+)':

>>> re.findall(r'(cos|sin|tan|[)(-*x]|\d+)', "cos(x)")
['cos', '(', 'x', ')']

From the documentation for findall:

The result depends on the number of capturing groups in the pattern. If there are no groups, return a list of strings matching the whole pattern. If there is exactly one group, return a list of strings matching that group. If multiple groups are present, return a list of tuples of strings matching the groups. Non-capturing groups do not affect the form of the result.

For 'cos(x)', you start with ('cos', '', '') because cos matched, but neither sin nor tan matched. For each of (, x, and ), none of the three capture groups matched, although the bracket expression did. Since it isn't inside a capture group, anything it matches isn't included in your output.

As an aside, [\d+/*x)(-] doesn't include multidigit integers as a match. \d+ is not a regular expression; it's the two characters d and +. (The escape is a no-op, since d has no special meaning inside [...].) As a result, it matches exactly one of the following eight characters:

  1. d
  2. +
  3. /
  4. *
  5. x
  6. )
  7. (
  8. -

Solution 2:[2]

You have three groups (an expression with parentheses) in your regex, so you get tuples with three items. Also you get four results for all substrings that matches with your regex: first for 'cos', second for '(', third for 'x', and the last for ')'. But the last part of your regex doesn't marked as a group, so you don't get this matches in your tuple. If you change your regex like r"(cos)|(sin)|(tan)|([\d+/*x)(-])" you will get tuples with four items. And every tuple will have one non empty item.

Unfortunately, this fix doesn't help you to verify that you have no prohibited lexemes. It's just to understand what's going on.

I would suggest you to convert your regex to a negative form: you may check that you have no anything except allowed lexemes instead of checking that you have some allowed ones. I guess this way should work for simple cases. But, I am afraid, for more sophisticated expression you have to use something other than regex.

Solution 3:[3]

findall returns tuples because your regular expression has capturing groups. To make a group non-capturing, add ?: after the opening parenthesis:

r"(?:cos)|(?:sin)|(?:tan)|[\d+/*x)(-]"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chepner
Solution 2 Kitta
Solution 3 Alain T.