I am developing an application where i have a startup video
I want this video to be embedded in my executable jar or a separate zip which can be password protected
I have tried to use the following code but its not working
audioPlayer.prepareMedia("zip:///C:/Users/User/Documents/NetBeansProjects/HanumanChalisa/res.zip!/res/startup.mp4");
Please help me for this.
EDIT :
this is the error i am getting
[mov,mp4,m4a,3gp,3g2,mj2 # 000000000053e320] moov atom not found
[000000000d245358] avcodec demux error: Could not open C:\Users\User\Documents\NetBeansProjects\HanumanChalisa\res.zip!\res\startup.mp4: Specified event object handle is invalid
[000000000d245358] ps demux error: cannot peek
[000000000d2390c8] main input error: no suitable demux module for 'zip/:///C:/Users/User/Documents/NetBeansProjects/HanumanChalisa/res.zip!/res/startup.mp4'
[000000000d2390c8] main input error: VLC can't recognize the input's format
[000000000d2390c8] main input error: The format of 'zip:///C:/Users/User/Documents/NetBeansProjects/HanumanChalisa/res.zip!/res/startup.mp4' cannot be detected. Have a look at the log for details.`
This works for me (when I adjust the path obviously), so I don't think there's anything inherently wrong with the code that you've posted. A couple of things to note:
Make sure the path is correct, that includes the case being the same (especially for the part inside the zip file)
Try opening the path just with VLC - if that doesn't work then you know the problem isn't related to your code
Try a zip file with different compression settings - perhaps VLC is struggling to read the format of that particular zip file (which it seems to allude to in its logs, though I'm always weary of following those too closely.)
If the worst comes to the worst, you could always extract the file you need to a tempoary file and then pass that location to VLCJ. Not an ideal workaround, but one that would at least still let you play the file.
Related
I am trying to access the text file in java and the code I have works in other IDEs but in VS code it keeps saying File Not Found - (produced from my exception handling)
I can't find anything about how to access text files with VScode. Is this possible please and does anyone know how?
I have tried to create the file in VScode with the new text file option and also by loading a pre-existing file and get the same result each time
Place the .txt file in the project root directory so that the code reads to the file location. As shown below
If the file is not with the project, use absolute paths in the code.
I have been round and round and round looking for this odd situtation. I have tried various suggestions, mostly related to BOM issues, but I still get this 'BOM-like' error, when running from an executable jar file, that was exported from Eclipse. I don't get the error when running the code in Eclipse. The platform is Windows Server 2012r2
The actual parsing is being done in a Groovy class using the XmlSlurper, whose input is an xml string passed from Java. I am assuming that the problem is in the Java code that creates the string.
I got this error when I ran my first test in Eclipse. Eventualy, I checked the encoding in np++ (used to edit the file, but not create it) and it said "UTF-8 + BOM". I changed that to "UTF-8" rather than refresh my memory on handling BOMs, from some years ago. That solved the problem.
When I export the Eclipse project to an executable jar, I get the ' Content is not allowed' parse exception from the same xml file (OK, it's copied to a different folder).
I have tried using the Apache BOMInputStream to wrap the InputStream from the file (this worked for me in the past). This time it doesn't.
The result from (BomInputStream) #getBOM() is false. But, it's also false when I set the encoding to "UTF-8 + BOM"! (that's running in Eclipse and the jar)
In case it's relevant, the start of the Groovy code is:
def ClientConfig parse (String clientConfigXML) {
def config = new XmlSlurper(false, false).parseText(clientConfigXML);
I'd be delighted to find that someone can help. I haven't included the Java code as it's the normal stuff you find in Q&A for this topic, and it's full of commented-out code right now.
Time for bed...
Best regards, John
[Answer:
If you try to parse a .properties file that starts with a comment, in the belief that it is xml, you get the ".1:1: Content is not allowed..." error from the xml parser. That was due to me being careless. Thanks for the prompt below that got me to check this basic fact.
The good thing to come out of this, is that my code is now BOM-proof. I will keep the use of the BOMInputStream - eliminated a little technical debt.]
I changed the value of -D parameter (for the 'properties' file) in the .bat file that launched the jar file. It was still referring to a .properties file, what I had replaced by an XML file. This error is what you get when you read what should be an XML file, but is, in fact, a properties file.
i have an .MP4 video placed in the "res/media" folder inside my project. I can easily play this video in my application from eclipse using this piece of code:
String url = getClass().getResource("/media/video.mp4").getFile();
url = new File(url).getPath();
showMedia(url); //the method that plays the video
i had to use this code because using only URL url = getClass().getResource("/media/video.mp4"); makes VLCJ can't access the video using this URL.
When creating the executable JAR file, i get these errors in the console:
libdvdnav: Using dvdnav version 5.0.0
libdvdread: Could not open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 with libdvdcss.
libdvdread: Can't open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 for reading
libdvdnav: vm: failed to open/read the DVD
[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)
[1644d0ac] main access error: File reading failed
[1644d0ac] main access error: VLC could not open the file "D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" (Invalid argument).
[1645643c] main input error: open of `file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4' failed
[1645643c] main input error: Your input can't be opened
[1645643c] main input error: VLC is unable to open the MRL 'file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4'. Check the log for details.
The libraries are being successfully loaded, and i can even play any video that is outside my JAR file.
Any suggestions?
And thanks in advance.
A Media Resource Locator (MRL) is not the same as a URL.
The log you posted shows what VLC is trying to open. The informative part is:
[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)
"D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" is clearly not a valid filename?
So this code is flawed:
String url = getClass().getResource("/media/video.mp4").getFile();
This type of thing, without the .getFile(), is usually used to load resources from the application classpath. That's not the case here though when you try and get the file name.
You should just do something like:
String mrl = new File("res/media/video.mp4").getAbsolutePath();
But that of course depends on what is the "current" directory for your application, and won't work inside a jar file.
On the other hand, VLC can play media contained inside zip (and therefore jar) files, with an MRL that looks a little bit like what you posted. Something like:
zip://file.jar!/res/media/video.mp4
I have a simple Java app that is trying to copy a file across the WAN (from Ireland to NY).
I recently modified it to use FileUtils because the native Java file copy was too slow. I researched and found that because Fileutils uses NIO it is better. The file copy now works great but occasionally I need to copy very large files (> 200Mb) and the copy fails with the error:
java.io.IOException: Failed to copy full contents from...
I know the error means that the destination file size is not the same as the source, so initially I figured it was network problems. The process tries repeatedly to copy the file every couple of hours but it is never successful. However, when I copy the file manually through a Windows exploer then it works fine. This would seem to rule out the network...but I'm not really sure.
I have searched but could not find any posts with the exact same issue. Any help would be greatly appreciated.
Thanks!
Addition:
I am using this FileUtils method:
public static void copyFile(java.io.File srcFile, java.io.File destFile) throws java.io.IOException
So I found the issue to be on the destination folder. There is a polling process that is suppose to pick up the file after it gets copied. However, the file was getting moved prior to the copy being completed. This probably wouldn't happen on a windows drive because the file would be locked (i tested locally and i could not delete while file is copying). However, the destination folder is a mounted a celerra share. The unix process under the hood is what grabs the file...I guess it doesn't care if some windows process is still writing to it.
Thanks for your time medPhys-pl!
I'm trying to train Tesseract for a new font which can be used in my Android app. I need to train for digits only, so I had created one training image, box file and unicharset file.
I have followed the training instructions, but when I tried to run tesseract it says, bad read of inttemp!.
What am I doing wrong? How can I diagnose this error?
http://code.google.com/p/tesseract-ocr/issues/detail?id=155
Turns out, tesseract was still going back to the "C:\Program Files\Tesseract-OCR" folder - including using the 3.0 training exes within the training folder there. It made no difference where I was running the command from - guess tesseract ignores that when it has a path variable.
Replaced all of the 3.0 exe and training files in that folder. Dropped in the 2.0.4 files and the extract command worked!!! I should have solved the problem faster for all sorts of reasons, but..
try this
http://www.win.tue.nl/~aeb/linux/ocr/tesseract.html