First, get the video address from the text, download the video to the local, get the video size information
This way is very slow, very troublesome because the first to download this video to the local, in the local access to this video information in the removal of this video (do not delete it can also, mainly time long thing more than a station space)
But did not find a good method can only do so, if there is a good way to ask you to enlighten me very much thank you ...
Second, code:
Package com.soufun.util;
Import It.sauronsoftware.jave.Encoder;
Import It.sauronsoftware.jave.MultimediaInfo;
Import Java.io.DataInputStream;
Import Java.io.DataOutputStream;
Import Java.io.File;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import java.net.HttpURLConnection;
Import java.net.MalformedURLException;
Import java.net.URISyntaxException;
Import Java.net.URL;
Import Java.util.Date; /** * Get the size of the screen * * @author User * * */public class Videosize {public static void main (string[] args) throws Urisynta
Xexception, malformedurlexception {Date begin = new Date (); try {getremotefile ("Http://video2s.soufun.com/2015/04/27/bj/mp4/ef9ba790c9e74742ae5898aefe9232a1.mp4", "d:/
Test1.flv ");
catch (IOException E1) {//TODO auto-generated catch block E1.printstacktrace ();
///download to local video file Source = new file ("d:/test1.flv");
Encoder encoder = new encoder ();
try {//Get multimedia information object Multimediainfo m = encoder.getinfo (source);The call method gets the long ls = m.getduration (); System.out.println ("The length of this video is:" + ls/1000 +) seconds.
");
catch (Exception e) {e.printstacktrace ();
Date end = new Date ();
Long time = End.gettime ()-begin.gettime ();
System.out.println ("time-consuming" + time/1000); private static Boolean Getremotefile (String strurl, String fileName) throws IOException {URL url = new URL (strur
L);
HttpURLConnection conn = (httpurlconnection) url.openconnection ();
DataInputStream input = new DataInputStream (Conn.getinputstream ());
DataOutputStream output = new DataOutputStream (new FileOutputStream (FileName));
byte[] buffer = new byte[1024 * 8];
int count = 0;
while ((count = input.read (buffer)) > 0) {output.write (buffer, 0, count);
} output.close ();
Input.close ();
return true;
}
}
Note: The download address of the Jave package used in the program is as follows:
Click to download jave1.0.1 rack package