< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_av library

Description

gh_av is the module that manages audio/video playback. This module is based on FFmpeg and is available for all platforms: Windows, Linux, macOS and Raspberry Pi.


Number of functions: 16

  1. gh_av.decoder_open (Lua - Python)
  2. gh_av.decoder_close (Lua - Python)
  3. gh_av.get_codec_name (Lua - Python)
  4. gh_av.get_duration (Lua - Python)
  5. gh_av.get_elapsed_time (Lua - Python)
  6. gh_av.get_num_frames (Lua - Python)
  7. gh_av.get_streams_index (Lua - Python)
  8. gh_av.pause (Lua - Python)
  9. gh_av.process_frame (Lua - Python)
  10. gh_av.reset_streams (Lua - Python)
  11. gh_av.set_volume (Lua - Python)
  12. gh_av.start_audio_video_processing (Lua - Python)
  13. gh_av.stop_audio_video_processing (Lua - Python)
  14. gh_av.video_get_resolution (Lua - Python)
  15. gh_av.video_init_texture (Lua - Python)
  16. gh_av.video_update_texture (Lua - Python)



decoder_open

Description

Opens an audio/video file.


Syntax

av = gh_av.decoder_open(
 filename,
 loop_mode
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
av = gh_av.decoder_open(filename, 1)
            


decoder_close

Description

Cleans up and closes an audio-video object.


Syntax

gh_av.decoder_close(
 av
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.decoder_close(av)
            


get_codec_name

Description

Returns the codec names of video and audio streams.


Syntax

video_codec, audio_codec = gh_av.get_codec_name(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
video_codec, audio_codec = gh_av.get_codec_name(av)
            


get_duration

Description

Duration of the audio-video file.


Syntax

duration = gh_av.get_duration(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
duration = gh_av.get_duration(av)
            


get_elapsed_time

Description

Returns the elapsed time since the start of playing.


Syntax

elapsed_time = gh_av.get_elapsed_time(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
elapsed_time = gh_av.get_elapsed_time(av)
            


get_num_frames

Description

Returns the numbers of frames of video and audio streams.


Syntax

video_frames, audio_frames = gh_av.get_num_frames(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
video_frames, audio_frames = gh_av.get_num_frames(av)
            


get_streams_index

Description

Returns the audio and video stream indices. Useful to know if an audio video file has an audio or a video stream.


Syntax

video_index, audio_index = gh_av.get_streams_index(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
audio, video = gh_av.get_streams_index(av)
            


pause

Description

Pauses an audio-video playback.


Syntax

gh_av.pause(
 av,
 state
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.pause(av, 1)
            


process_frame

Description

Process/fetch the current audio-video frame. You can call this function in a FRAME script if you don not use start_audio_video_processing() / stop_audio_video_processing().


Syntax

gh_av.process_frame(
 av,
 process_video,
 process_audio
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.process_frame(av, 1, 1)
            


reset_streams

Description

Resets the audio-video streams.


Syntax

gh_av.reset_streams(
 av
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.reset_streams(av)
            


set_volume

Description

Sets the volume of the audio stream.


Syntax

gh_av.set_volume(
 av,
 volume
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.set_volume(av, 0.7)
            


start_audio_video_processing

Description

Starts the audio-video processing thread.


Syntax

gh_av.start_audio_video_processing(
 av,
 process_video,
 process_audio
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.start_audio_video_processing(av, 1, 1)
            


stop_audio_video_processing

Description

Stops the audio-video processing thread.


Syntax

gh_av.stop_audio_video_processing(
 av
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.stop_audio_video_processing(av)
            


video_get_resolution

Description

Returns the resolution in pixels of video frames.


Syntax

width, height = gh_av.video_get_resolution(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
duration = gh_av.video_get_resolution(av)
            


video_init_texture

Description

Creates a texture based on video parameters. This texture can be used with all gh_texture functions.


Syntax

texture_id = gh_av.video_init_texture(
 av
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
tex_id = gh_av.video_init_texture(av)
            


video_update_texture

Description

Updates the texture GPU memory with current video frame.


Syntax

gh_av.video_update_texture(
 av,
 texture_id
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_av.video_update_texture(av, tex_id)
            






GeeXLab Rootard Guide | Downloads | Contact | Newsletter