GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



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.

Number of functions: 17



gh_av.update

Description

Updates the sound system. Must be called once per frame.

Languages

Lua - Python

Parameters

This function has no input parameter(s).

Return Values

This function has no return value(s).

Code sample


gh_audio.update()



gh_av.decoder_open

Description

Opens an audio/video file.

Languages

Lua - Python

Parameters

  • filename [STRING]: audio filename.
  • loop_mode [INTEGER]: loop mode: looping (1) or not looping (0).

    Return Values

  • av [INTEGER]: audio-video object identifier.

    Code sample


    av = gh_av.decoder_open(filename, 1)



    gh_av.decoder_close

    Description

    Cleans up and closes an audio-video object.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.decoder_close(av)



    gh_av.video_init_texture

    Description

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

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • texture_id [INTEGER]: texture identifier.

    Code sample


    tex_id = gh_av.video_init_texture(av)



    gh_av.video_update_texture

    Description

    Updates the texture GPU memory with current video frame.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.
  • texture_id [INTEGER]: texture identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.video_update_texture(av, tex_id)



    gh_av.start_audio_video_processing

    Description

    Starts the audio-video processing thread.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.
  • process_video [INTEGER]: process (1) or not process (0) the video stream.
  • process_audio [INTEGER]: process (1) or not process (0) the audio stream.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.start_audio_video_processing(av, 1, 1)



    gh_av.stop_audio_video_processing

    Description

    Stops the audio-video processing thread.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.stop_audio_video_processing(av)



    gh_av.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().

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.
  • process_video [INTEGER]: process (1) or not process (0) the video stream.
  • process_audio [INTEGER]: process (1) or not process (0) the audio stream.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.process_frame(av, 1, 1)



    gh_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.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • video_index, audio_index [INTEGER]: video and audio streams indices: -1 if the stream is not present and >= 0 if the stream is present.

    Code sample


    audio, video = gh_av.get_streams_index(av)



    gh_av.set_volume

    Description

    Sets the volume of the audio stream.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.
  • volume [REAL]: volume from 0.0 to 1.0.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.set_volume(av, 0.7)



    gh_av.pause

    Description

    Pauses an audio-video playback.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.
  • state [INTEGER]: pause (1) or not (0).

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.pause(av, 1)



    gh_av.reset_streams

    Description

    Resets the audio-video streams.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_av.reset_streams(av)



    gh_av.get_elapsed_time

    Description

    Returns the elapsed time since the start of playing.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • elapsed_time [REAL]: elapsed time in seconds since the start of playing.

    Code sample


    elapsed_time = gh_av.get_elapsed_time(av)



    gh_av.get_duration

    Description

    Duration of the audio-video file.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • duration [REAL]: duration in seconds.

    Code sample


    duration = gh_av.get_duration(av)



    gh_av.video_get_resolution

    Description

    Returns the resolution in pixels of video frames.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • width, height [INTEGER]: resolution.

    Code sample


    duration = gh_av.video_get_resolution(av)



    gh_av.get_num_frames

    Description

    Returns the numbers of frames of video and audio streams.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • video_frames, audio_frames [INTEGER]: numbers of frames.

    Code sample


    video_frames, audio_frames = gh_av.get_num_frames(av)



    gh_av.get_codec_name

    Description

    Returns the codec names of video and audio streams.

    Languages

    Lua - Python

    Parameters

  • av [INTEGER]: audio-video object identifier.

    Return Values

  • video_codec, audio_codec [STRING]: codec names.

    Code sample


    video_codec, audio_codec = gh_av.get_codec_name(av)





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.