agomezmoron / screen-recorder

Java screen recorder library
MIT License
21 stars 14 forks source link

I'm getting DataSink error when I run below code. #6

Open ashanvabs opened 6 years ago

ashanvabs commented 6 years ago

Hi I'm using java 8 and netbeans to run the project. I have added below code

try {
            // configuration
            VideoRecorderConfiguration.setCaptureInterval(50);
            // 20 frames/sec
            VideoRecorderConfiguration.wantToUseFullScreen(true);
            VideoRecorderConfiguration.setVideoDirectory(new File("F:/test"));
            // home
            VideoRecorderConfiguration.setKeepFrames(false);
            // you can also change the x,y using
            VideoRecorderConfiguration.setCoordinates(10,20);
            VideoRecorder.start("test");

            Thread.sleep(400);

            String videoPath = VideoRecorder.stop();

            // EXECUTE ALL YOU WANT TO BE RECORDED String videoPath = VideoRecorder.stop(); // video created 

            System.out.println(videoPath);

        } catch (Exception ex) {
            ex.printStackTrace();
            Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
        }

and I'm getting below error

Cannot create the DataSink: javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.BasicMux$BasicMuxDataSource@7bfcd12c
Failed to create a DataSink for the given output MediaLocator:

it's really helpfull if you could help me solve this issue.

agomezmoron commented 6 years ago

Hi @ashanvabs,

Can you please provide more detailes?

Thanks!

emilioaraujo commented 5 years ago

Same Issue in Netbeans 8.2 JDK8... Netbeans project attached ! Any update? ScreenRecorder.zip

agomezmoron commented 5 years ago

Hi @emilioaraujo ,

I work on Linux and I cannot reproduce your issue (maybe is related to Windows).

Do you want to add a PR fixing it?

Cheers!

ysnerdogdu commented 5 years ago

Why there is still no answer ??

agomezmoron commented 5 years ago

Because I cannot reproduce and nobody contributed yet. @ysnetdogdu do you want to help us on this?👏

Alphalaneous commented 4 years ago

I have the same issue, using JDK 12 on Windows

nnllnn commented 4 years ago

@agomezmoron On windows the file path supplied to the MediaLocator should be of the form: "file://C:/test.mov" in order for this work. However in to make this to work in the VideoRecorder class on line 237 you should use getPath() instead of getAbsolutePath(). I tried it with that small change and supplied the path in the above format and I no longer get the exception. I am not sure if it works on Linux though. Can you check if it still works on linux if you make that small change?

See this: https://www.databaseusers.com/article/8713876/NoDataSinkException%3F

agomezmoron commented 4 years ago

Thanks @nnllnn,

Could you please perform a PR?

Cheers

python012 commented 1 year ago

@nnllnn I tried to replace all getAbsolutePath() with getPath() in VideoRecorder class, and rebuild jar, and still get the error, could you share your fix which can make it works in Windows? Many thanks!

hello world
[Ljava.lang.StackTraceElement;@1a399483
Cannot create the DataSink: javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.BasicMux$BasicMuxDataSource@3c130745
Failed to create a DataSink for the given output MediaLocator: D:\video11\hello.mov
null

My JUnit test code

    @Test
    public void testVideo() throws InterruptedException, MalformedURLException {
        System.out.println("hello world");

        VideoRecorderConfiguration.setCaptureInterval(50); // 20 frames/sec
        VideoRecorderConfiguration.wantToUseFullScreen(true);
        VideoRecorderConfiguration.setVideoDirectory(new File("D:\\video11")); // home
        VideoRecorderConfiguration.setKeepFrames(false);
        VideoRecorder.start("hello");
        TimeUnit.SECONDS.sleep(5);
        String videoPath = VideoRecorder.stop(); // video created
        System.out.println(videoPath);
    }
python012 commented 1 year ago

I figured out the problem and raised PR.. see https://github.com/agomezmoron/screen-recorder/pull/12