Sorry. I'm new to JNA, and I can't say. I'm assuming that JNA takes care of all garbage collection and freeing memory. I looked through the docs and api now, and can't find any language otherwise. I found this post http://osdir.com/ml/java.jna.user/2008-04/msg00015.html which indicates likewise: "If JNA provides you with memory, it will be automatically freed when the object is GC'd."Do you know if that structure has to be freed natively?
Code: Select all
MOVE: java.awt.event.MouseEvent[MOUSE_MOVED,(276,399),absolute(523,504),button=0,clickCount=0] on canvas0
I needed to add logging to the new versions to help with debugging native crashes, you can disable the logging quite easily:However, it is possible to deactivate the mouse information in the consol.Code: Select all
MOVE: java.awt.event.MouseEvent[MOUSE_MOVED,(276,399),absolute(523,504),button=0,clickCount=0] on canvas0
I'm not sure I understand this, your own application should be controlling the screen size. I play/pause/stop/play again in my own application without any problem. Can you give a bit more explanation as what's going wrong?Another thing, if the window is resized, after put the video on “pause”, when the video restarts “play”, the screen is expand as the native video size.
Is there a way to maintain or to force the screen size.
I don't really know what these sout strings should look like, but in principle you pass options when you play the media, e.g.sherington, can you tell me how can i save a stream to a file with vlcj?
to do this in command line i do something like this:
vlc -vvv rtp://@239.1.1.1:5004 --sout '#standard{mux="ts",access="file",dst="/home/braca/movie.avi"}'
and now, i need to do something similar but with vlcj..
thanks
Code: Select all
String mediaUrl = "rtp://@239.1.1.1:5004";
String[] options = {":sout=#standard{mux=ts,access=file,dst=/home/braca/movie.avi"};
mediaPlayer.playMedia(mediaUrl, options);
Thanks, it workedI don't really know what these sout strings should look like, but in principle you pass options when you play the media, e.g.sherington, can you tell me how can i save a stream to a file with vlcj?
to do this in command line i do something like this:
vlc -vvv rtp://@239.1.1.1:5004 --sout '#standard{mux="ts",access="file",dst="/home/braca/movie.avi"}'
and now, i need to do something similar but with vlcj..
thanksThat worked for me.Code: Select all
String mediaUrl = "rtp://@239.1.1.1:5004"; String[] options = {":sout=#standard{mux=ts,access=file,dst=/home/braca/movie.avi"}; mediaPlayer.playMedia(mediaUrl, options);
The options are ultimately passed to libvlc_media_add_option().
your own application should be controlling the screen size
Code: Select all
private void goToTheNextFrame(){
// you can only move to a frame if your video is on pause, so I make a Boolean to check it
if (this.isPlaying == false){
long longTimeVideo = mediaPlayer.getTime();
float frameRate = mediaPlayer.getFps() ;
// calculate the new frame number to the time since the beginning
// of the video (in milliseconds) + the time of a frame
long newTime = Math.round (longTimeVideo + 1000 / frameRate );
// check if we are not out of the video (for example, we are at the last frame)
if (newTime <= this.mediaPlayer.getLength()){
// we move to the new time
this.mediaPlayer.setTime(newTime);
}
}
}
Code: Select all
void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
if( p_input_thread != NULL )
{
var_TriggerCallback( p_input_thread, "frame-next" );
vlc_object_release( p_input_thread );
}
}
Use:The other option is to increase the video speed (like VLC does, your video can be display at 2x, 3x,…).
Code: Select all
mediaPlayer.setRate(float rate).
Next frame is easy because as you have seen there's a native libvlc function to do that, and you can invoke that through the Java bindings.For moving to the next frame, I write this code (I have a similar for going backward).
But it doesn’t work very well (due to the round I suppose). Sometimes I have to click twice to move to the next frame.
Code: Select all
mediaPlayer.nextFrame().
For this part you should be able to use...Code: Select all
private void goToTheNextFrame(){ // you can only move to a frame if your video is on pause, so I make a Boolean to check it if (this.isPlaying == false){
Code: Select all
mediaPlayer.isPlaying()
What about making vlcj the default Java bindings of VLC?To any vlcj users who may be interested, I made a final 1.1.0 release of vlcj now that vlc 1.1.0 final has been released. Not much has changed if you've been using the recent pre-release 1.1.0x versions.
Please feed back any issues.
http://code.google.com/p/vlcj/
(You also need log4j, jna and the jna platform jars.)
To be honest, I can't see myself having the spare capacity to move my project and development environment from googlecode+svn to something new.What about making vlcj the default Java bindings of VLC?
I had this same problem with JVLC. In fact I do not know how to resolve but I managed to identify that this occurs when you give a second dispose () in dialogs (with video playing).vlcj contains a simple video player implementation built using Swing/AWT, and I use this for testing.
I have discovered a new issue that I am really struggling to solve. I did not see this issue with vlc 1.0.5, nor with vlc 1.1.0pre2, but it is present when running the same Java code against vlc 1.0.6 and vlc 1.1.0pre3. I'm not saying this is a vlc fault I'm just describing my circumstances.
The problem goes like this...
1. Start the test player
2. Use file or stream dialog to open a media source
3. Video starts playing
4. Use file or stream dialog, this time hit cancel (or choose something, it doesn't matter)
5. => Fatal JVM failure, with the text below dumped to the error console
(If you never start a video playing, you can open and cancel as many dialogs as you want and it doesn't crash.)
The fatal JVM failure is most likely as a result of an unhandled exception condition in the native code.Code: Select all
[????????] x11 video output error: X11 request 20.0 failed with error code 3: BadWindow (invalid Window parameter) X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 20 (X_GetProperty) Resource id in failed request: 0x4400042 Serial number of failed request: 2673 Current serial number in output stream: 2673
This happens as soon as the dialog box closes, and is 100% repeatable and I have no idea what to do about it.
I can play movie after movie without any issues if I don't use a dialog box and do it programmatically instead.
Anyone have any ideas?
Code: Select all
package br.ufpb.lavid.GTMDA.Commons.GUI.swing;
import java.awt.Component;
import java.awt.Dialog.ModalityType;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author alexander
*/
public class JFileChooserGTMDA extends JFileChooser{
private JDialog meuDialog = null;
public JFileChooserGTMDA(String path){
super(path);
}
public void setFileFilter(String description, String... formats){
setFileFilter(new MyFileFilter(description, formats));
}
@Override
protected JDialog createDialog(Component parent) throws HeadlessException {
this.meuDialog = super.createDialog(parent);
meuDialog.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
meuDialog.setModalityType(ModalityType.APPLICATION_MODAL);
meuDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
cancelSelection();
}
});
return this.meuDialog;
}
public JDialog getDialog(){
return meuDialog;
}
@Override
public int showDialog(Component parent, String approveButtonText)
throws HeadlessException {
return showDialog(parent, approveButtonText, approveButtonText);
}
/**
* Exibe um jFileChooser.
*
* @param parent a tela pai
* @param approveButtonText o nome a ser exibido do botao de aceitacao
* @param title o titulo do jFileChooser
*
* @return esse eu nao entendi (nao fui eu que fiz esse codigo)
*/
public int showDialog(Component parent, String approveButtonText, String title)
throws HeadlessException {
if(approveButtonText != null) {
setApproveButtonText(approveButtonText);
setDialogType(CUSTOM_DIALOG);
}
meuDialog = createDialog(parent);
meuDialog.setTitle(title);
rescanCurrentDirectory();
meuDialog.show();
firePropertyChange("JFileChooserDialogIsClosingProperty", meuDialog, null);
return CANCEL_OPTION;
}
@Override
public void approveSelection() {
meuDialog.setVisible(false);
}
@Override
public void cancelSelection() {
setSelectedFile(null);
meuDialog.setVisible(false);
}
private class MyFileFilter extends FileFilter {
String description;
String[] formats;
public MyFileFilter(String description, String... formats) {
this.description = description;
this.formats = formats;
}
@Override
public boolean accept(File f) {
for(String ext : formats)
if(f.getName().endsWith('.'+ext))
return true;
return f.isDirectory();
}
@Override
public String getDescription() {
return description;
}
}
}
Very nice workaround, thank you.I had this same problem with JVLC. In fact I do not know how to resolve but I managed to identify that this occurs when you give a second dispose () in dialogs (with video playing).
Try this JFileChooser above that overloads where to dispose() of setVisible (false) and you can "solve" the problem.
Hi sherington, nice work with the VLCJ
The marquee and logo is only possible that way because there are new API functions exposed in libvlc 1.1.0. There's nothing that I know about exposed in the libvlc API for those other effects.I saw that you can add in VLCJ Marquee and Logo in this way. Its possible do this with the video effects ? (Invert, noise ...) Or Change the transcoding line is this way ?
This is a hard problem to pin down since the workaround is not needed with my 1.1 bindings and vlc 1.1.0 - it all works just fine with 1.1.0, and since that's where everyone should be now I guess we can forget about this particular problem.Very nice workaround, thank you.I had this same problem with JVLC. In fact I do not know how to resolve but I managed to identify that this occurs when you give a second dispose () in dialogs (with video playing).
Try this JFileChooser above that overloads where to dispose() of setVisible (false) and you can "solve" the problem.
Code: Select all
Properties p = System.getProperties();
p.setProperty("jna.library.path", p.getProperty("jna.library.path") + File.pathSeparator + "lib");
Code: Select all
String plugin = "--plugin-path=plugins";
this.mediaPlayerFactory = new MediaPlayerFactory(new String[]{plugin});
Code: Select all
No accelerated IMDCT transform found
get_buffer() failed (stride changed)
Invalid memory access of location 0x12e75053000 rip=0x7fff87522120
Java Result: 139
If I knew what to do I would already have done it.I do not know what I gotta do to develop a MacCanvas (similar to what you did with WindowsCanvas). Do you have any tips?
Return to “Development around libVLC”
Users browsing this forum: No registered users and 8 guests