Difference between revisions of "Modular Media Server/User Guide/Basic Modular Media Server implementation"

From RidgeRun Developer Connection
Jump to: navigation, search
m
m
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
{{Modular Media Server/Top Banner|previous=|next=|keywords=}}
+
{{Modular Media Server/Top Banner|previous=User Guide/Interactive Console|next=Contact_Us|keywords=}}
 
</noinclude>
 
</noinclude>
  
  
 +
== Basic x86 Modular Media Server Implementation ==
 +
In the case that you don't want to use the [[Modular Media Server/User Guide/Interactive Console |command-line interface]], you can use the Media Server class. To show the use Media Server class, let's build the next basic media group.
  
  
 +
[[File:BasicModularMediaServerExample.png|thumb|center|700px|Figure 1: Basic X86 Modular Media Server Implementation media group ]]
 +
<br>
  
 +
To interact with a Modular Media Server, a Media Server instance must be initialized.
 +
<syntaxhighlight lang=python>
 +
logger = ConsoleLogger()
 +
media_server = MediaServer(logger)
 +
</syntaxhighlight>
  
 +
Next, we will create the source, encoder, and file container media group description, as follows:
  
 +
<syntaxhighlight lang=python>
 +
source = [
 +
    {
 +
        "type": "V4L2CaptureEntity",
 +
        "entity": "/dev/video0",
 +
        "input_name": "none",
 +
        "output_name": "0",
 +
    }
 +
]
 +
encoder = [{
 +
        "type": "X86EncoderEntity",
 +
        "entity": "vaapih264enc",
 +
        "input_name": "0",
 +
        "output_name": "1",
 +
    }
 +
]
 +
file = [{
 +
        "type": "FileRecorderEntity",
 +
        "entity": "mp4mux",
 +
        "input_name": "1",
 +
        "output_name": "video_test.mp4",
 +
    }
 +
]
 +
</syntaxhighlight>
  
 +
Next, we are going to create the three media groups:
  
 +
<syntaxhighlight lang=python>
  
 +
media_server.create_media_group("sourcer_media_group", source)
 +
media_server.create_media_group("encoder_media_group", encoder)
 +
media_server.create_media_group("file_media_group", file)
 +
 +
</syntaxhighlight>
  
 +
We start the pipelines and let them run for 25 seconds:
  
 +
<syntaxhighlight lang=python>
  
 +
media_server.start("sourcer_media_group")
 +
media_server.start("encoder_media_group")
 +
media_server.start("file_media_group")
 +
 +
time.sleep(25)
  
 +
</syntaxhighlight>
  
 +
Finally, stop the pipeline. A file with the name of "video_test.mp4" will be generated in the project directory.
 +
<syntaxhighlight lang=python>
  
 +
media_server.stop("sourcer_media_group")
 +
media_server.stop("encoder_media_group")
 +
media_server.stop("file_media_group")
 +
 +
</syntaxhighlight>
  
 
<noinclude>
 
<noinclude>
{{Modular Media Server/Foot||}}
+
{{Modular Media Server/Foot|User Guide/Interactive Console|Contact_Us}}
 
</noinclude>
 
</noinclude>
  
  
[[Category:RidgeRun's Modular Media Server project Templates]]
+
[[Category:Modular Media Server]]

Latest revision as of 09:53, 21 June 2022



Previous: User Guide/Interactive Console Index Next: Contact_Us





Basic x86 Modular Media Server Implementation

In the case that you don't want to use the command-line interface, you can use the Media Server class. To show the use Media Server class, let's build the next basic media group.


Error creating thumbnail: Unable to save thumbnail to destination
Figure 1: Basic X86 Modular Media Server Implementation media group


To interact with a Modular Media Server, a Media Server instance must be initialized.

 
logger = ConsoleLogger()
media_server = MediaServer(logger)

Next, we will create the source, encoder, and file container media group description, as follows:

 
source = [
    {
        "type": "V4L2CaptureEntity",
        "entity": "/dev/video0",
        "input_name": "none",
        "output_name": "0",
    }
]
encoder = [{
        "type": "X86EncoderEntity",
        "entity": "vaapih264enc",
        "input_name": "0",
        "output_name": "1",
    }
]
file = [{
        "type": "FileRecorderEntity",
        "entity": "mp4mux",
        "input_name": "1",
        "output_name": "video_test.mp4",
    }
]

Next, we are going to create the three media groups:

media_server.create_media_group("sourcer_media_group", source)
media_server.create_media_group("encoder_media_group", encoder)
media_server.create_media_group("file_media_group", file)

We start the pipelines and let them run for 25 seconds:

media_server.start("sourcer_media_group")
media_server.start("encoder_media_group")
media_server.start("file_media_group")
 
time.sleep(25)

Finally, stop the pipeline. A file with the name of "video_test.mp4" will be generated in the project directory.

media_server.stop("sourcer_media_group")
media_server.stop("encoder_media_group")
media_server.stop("file_media_group")



Previous: User Guide/Interactive Console Index Next: Contact_Us