Search code examples
gstreamerglibvala

Is there a way to disable opening a new window in GStreamer for videos?


I am making an app with gtk. I need a way to play only the audio of a, say, mp4 file.

var player = Gst.ElementFactory.make("playbin", "play");
player.uri = "http://ks4.imslp.info/files/imglnks/usimg/e/ea/IMSLP478767-PMLP776231-Plas_yn_Rhiw.mp4";
player.set_state(Gst.State.PLAYING);

I want only the audio to play; I don't want GStreamer to open a window to display the video.


Solution

  • Check the flags property of playbin:

      flags               : Flags to control behaviour
                            flags: readable, writable
                            Flags "GstPlayFlags" Default: 0x00000617, "soft-colorbalance+deinterlace+soft-volume+text+audio+video"
                               (0x00000001): video            - Render the video stream
                               (0x00000002): audio            - Render the audio stream
                               (0x00000004): text             - Render subtitles
                               (0x00000008): vis              - Render visualisation when no video is present
                               (0x00000010): soft-volume      - Use software volume
                               (0x00000020): native-audio     - Only use native audio formats
                               (0x00000040): native-video     - Only use native video formats
                               (0x00000080): download         - Attempt progressive download buffering
                               (0x00000100): buffering        - Buffer demuxed/parsed data
                               (0x00000200): deinterlace      - Deinterlace video if necessary
                               (0x00000400): soft-colorbalance - Use software color balance
                               (0x00000800): force-filters    - Force audio/video filter(s) to be applied
    

    So when you select a flag combination that excludes the video it should not render the video path.