视频上传模块java代码,java实现视频上传功能
怎么用java/web代码播放本地视频
在后台,java中根据路径找目录下所有的视频文件,然后把名字和url返回到前台,前台显示列表,点击后打开播放页,网上很多flash制作的播放器,嵌入到网页中并把视频url传递进去就可以了。博客noday.net我若有时间就写个例子
成都创新互联公司主要为客户提供服务项目涵盖了网页视觉设计、VI标志设计、全网整合营销推广、网站程序开发、HTML5响应式重庆网站建设公司、手机网站开发、微商城、网站托管及成都网站维护公司、WEB系统开发、域名注册、国内外服务器租用、视频、平面设计、SEO优化排名。设计、前端、后端三个建站步骤的完善服务体系。一人跟踪测试的建站服务标准。已经为生料搅拌车行业客户提供了网站营销服务。
用java实现对视频添加水印的代码或思路
package com.jc.ts.services;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
*添加图片水印的服务类
* */
public class WaterMark {
/**
* @param sizeContext添加水印文字
* @param request 请求流对象
* @param request 响应流对象
* */
@SuppressWarnings("deprecation")
public static void createMarkSize(String sizeContext,HttpServletRequest request,HttpServletResponse response) {
try {
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//构建画板
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把源图片写入画板
g.setColor(Color.red);
g.drawString(sizeContext,10,5); // 添加文字
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param localPath 添加水印LOGO路径
* @param request 请求流对象
* @param request 响应流对象
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//构建画板
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把原图片写入画板
g.drawImage(fimg,w-20,h-15,fw,fh,null);//把水印图片写入画板
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* @param localPath 添加水印图片路径
* @param request 请求流对象
* @param request 响应流对象
* @param width 水印图片的宽度
* @param height 水印图片的长度
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response,int width,int height) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);//w为你过滤图片的宽度
int h=src.getHeight(null);//h为你过滤图片的长度
BufferedImage img=new BufferedImage(w+width,h+height,BufferedImage.TYPE_INT_RGB);//构建画板(画板的宽度为两个图片之和)
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把原图片写入画板
g.drawImage(fimg,width,height,fw,fh,null);//把水印图片写入画板
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
注意第三个方法的注释地方g.drawImage(fimg,width,height,fw,fh,null);根据参数你在调调(放原图下面的)
过滤器调用
package com.jc.ts.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jc.ts.services.WaterMark;
public class WaterFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest)arg0;
HttpServletResponse response=(HttpServletResponse)arg1;
//WaterMark.createMarkSize("南京ts", request, response);
//WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response);
WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response,20,30);
//注意路径为绝对路径且三个效果不能同时执行
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
web.xml配置(写在servlet上面)
filter
descriptionThis is the description of my J2EE component/description
display-nameThis is the display name of my J2EE component/display-name
filter-nameWaterFilter/filter-name
filter-classcom.jc.ts.filter.WaterFilter/filter-class
/filter
谁能给我一个JAVA电子相册或音乐播放器的代码啊 急急急
我自己做过一个类似的电子相册,但功能很不够全面,给你参考下...
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class img4 extends Applet
{
static Button btn1,btn2,btn3,btn4,btn5;
public void init()
{
setBackground(Color.cyan);
setVisible(true);
setLayout(null);
img4cvs cvs=new img4cvs();
btn1=new Button("下一页");
btn2=new Button("上一页");
btn4=new Button("自动播放");
btn5=new Button("停止");
add(btn1);
add(btn2);
add(btn4);
add(btn5);
add(cvs);
btn2.setBounds(550,60,60,30);
btn1.setBounds(550,120,60,30);
btn4.setBounds(550,180,60,30);
btn5.setBounds(550,240,60,30);
cvs.setBounds(30,30,500,400);
btn1.addActionListener(cvs);
btn2.addActionListener(cvs);
btn4.addActionListener(cvs);
btn5.addActionListener(cvs);
validate();
}
class Backcolor extends Thread
{
public void run()
{int j=0;int m=0;int n=0;
while(true)
{
try{
if(j255m255n255)
{
j++;
sleep(100);
Color col1=new Color(j,m,n);
setBackground(col1); }
else if(j==255m255)
{
m++;
sleep(100);
Color col2=new Color(j,m,n);
setBackground(col2); }
else if(j==255m==255n255)
{
n++;
sleep(100);
Color col3=new Color(j,m,n);
setBackground(col3);}
else if(j==255m==255n==255)
{
j=55;
m=55;
n=55;
}
}
catch(InterruptedException e){}
}
}
}
public void start()
{
Backcolor thread2=new Backcolor();
thread2.start();
}
}
class img4cvs extends Canvas implements ActionListener
{
Image[] img;
int pg=0;
volatile boolean pleaseStop;
//String FONTS="Serif";
//String TEXT="我们很性感2!!";
img4cvs()
{
img=new Image[12];
Toolkit tl=getToolkit();
for(int i=0;i=11;i++)
{
img[i]=tl.getImage("img0"+i+".JPG");
}
}
class Play extends Thread
{
public void run()
{
while(!pleaseStop)
{
try{
pg++;
if(pg11){pg=0;}
sleep(1500);
}
catch(InterruptedException e){}
repaint();
}
}
}
public void actionPerformed(ActionEvent e)
{
Play thread=new Play();
if(e.getSource()==img4.btn1)
{
pg++;
if(pg11){pg=0;}
repaint();
}
else if(e.getSource()==img4.btn2)
{
pg--;
if(pg0){pg=11;}
repaint();
}
else if(e.getSource()==img4.btn4)
{
pleaseStop=false;
thread.start();
}
else if(e.getSource()==img4.btn5)
{
pleaseStop=true;
}
}
public void paint(Graphics g)
{
/*g.setColor(Color.black);
g.setFont(new Font(FONTS,Font.BOLD+Font.ITALIC,20));
g.drawString(TEXT,0,500);*/
g.drawImage(img[pg],0,0,500,400,this);
}
}
/*
applet code="img4.class" width=650 height=500
/applet
*/
谁知道如何用纯JAVA代码播放视频文件(可以播放一种视频文件,如mp4,就可以了)
你好!我们所说的mp4仅仅只是一种视频封装格式,里面的视频流却有各种编码格式!就像瓶子装水一样,“瓶子”有各种形状,如mp4 avi wmv rmvb等等…而其中装的是什么液体就不一定了!所以,看似都是.mp4文件,它的编码格式可能是H.246编码,也可能是...
完整的Java视频教程
Docker视频免费下载
链接:
提取码:1r9g
Docker视频|走进Docker|从Docker到CaaS(一)Docker集群管理介绍|从Docker到CaaS(三)Kubernetes|从Docker到CaaS(六)微服务与CaaS|从Docker到CaaS(二)Docker 容器管理工具|从 Docker 到 CaaS(五)灵雀云部署 Docker 容器|
怎样用Java代码上传文件到Nexus服务器
common-fileupload是jakarta项目组开发的一个功能很强大的上传文件组件
下面先介绍上传文件到服务器(多文件上传):
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.util.regex.*;
import org.apache.commons.fileupload
分享名称:视频上传模块java代码,java实现视频上传功能
文章链接:http://pwwzsj.com/article/hedjds.html