Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:45:36+00:00 2026-06-12T08:45:36+00:00

I try to use VLCj to get access to web-cameras. I am using this

  • 0

I try to use VLCj to get access to web-cameras. I am using this code:

public static void main(String[] args) {
    // Create player.
    MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
    DirectMediaPlayer mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(
            320, 240, 
            new RenderCallback() {
                @Override
                public void display(Memory arg0) {
                    // Do nothing.
                }
         });

    // Options setup.
    String[] options = new String[]{};
    String mrl = "v4l2:///dev/video0"; // Linux

    // Start preocessing.
    mediaPlayer.startMedia(mrl, options);

    BufferedImage bufImg;
    for (int i = 0; i < 1000; ++i) {
        bufImg = mediaPlayer.getSnapshot();

        // Do something with BufferedImage...
        // ...
    }

    // Stop precessing.
    mediaPlayer.stop();
    mediaPlayer = null;

    System.out.println("Finish!");
}

And this code partially works — I can get and work with BufferedImage, but:

  • I got an error in to output: [0x7f0a4c001268] main vout display error: Failed to set on top
  • When main loop is finished and camera was disabled program don’t finished! I see Finish! message, but program not return control into IDE or console.

UPD:
I am using openSUSE 12.2 x64, VLC 2.0.3 installed and working properly for all video files, library VLCj 2.1.0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:45:37+00:00Added an answer on June 12, 2026 at 8:45 am

    Re your native window: VLCj opens a shared instance to the VLC library.

    A headless media palyer is NOT intended to have a video or audio output!

    In fact, if you need anything to play (and not to stream to anywhere else) you need to create either an output window or use a direct media player (may be much more complicated)
    So, if a headless player needs to play something it opens a native window to perform the playback!

    Source: http://www.capricasoftware.co.uk/wiki/index.php?title=Vlcj_Media_Players

    Re the error: the video display component MUST be the top component of the panel, window or whereever it is added to. Otherwise it will throw the error

    main vout display error: Failed to set on top

    Furthermore, if you put anything over the component it will destroy the video output which won’t work anymore!

    Anyway, I don’t know how the DirectMediaPlayer works in detail but VLCj has some weird behaviour… Maybe getSnapshot() needs a video display component but I’m not sure.

    Re your not finishing program: you join to finish your own thread. This can’t work because your thread “sleeps” until the other thread who is waited for has been terminated but as this is your own thread it “sleeps” and won’t terminate.
    You can test this behaviour with this short code in a main method:

    System.out.println("Test start");
    Thread.currentThread().join();
    System.out.println("Test stop");
    

    You will NEVER reach the “Test stop” statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try use a integer array in java with the code below: public static
When i try use a webservice i get the following exception. My main question
for synchronizing access to my NHibernate session at web environment I try use Mutex:
I try use ms access as data provider but it give me exception. static
how to generate random number in this code? I try use $RANDOM, but the
I try use string as a regular expression pattern but I've following errors PHP
I try to use a variable in my kshell script but can't get a
i try to use TBXML and getting this error TBXML class method +tbXMLWithURL not
I try to use this: xml2struct when I use this xml: <XMLname attrib1=Some value>
I try use below code to load an URL. URL url = new URL(urlstr);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.