导航:首页 > 文件处理 > java压缩视频后反转了

java压缩视频后反转了

发布时间:2022-10-01 05:27:59

1. java中的控制反转是什么意思

很简单
,就是本来你该做的事情
你不去做了
让系统去做,比如,你获取一个对象的时候,往往需要new出实例来,如果用了控制反转,那这件事情
就不需要你做了,你只需要在配置文件xml中配置好,系统就帮你new
控制反转也叫依赖注入,就是把该用到的东西
提前注入进去,下次直接用
而不是每次都new
这够通俗的了吧
希望你能明白

2. java 如何实现视频高压缩

视频本来就是压缩过的,其中的冗余信息已经去除了,而且是有损的。所以再用zip(jar使用的压缩方式)去压缩一遍没多大意义,还是从选择视频格式方式入手吧。

3. java中传的图片显示的时候倒过来了怎么解决

查看的时候,不要按EXIF来纠正方向,才是真正的方向
~
~
~
~

4. java中怎样将视频文件转换成二进制文件再转换回视频文件求具体代码!

其实x.avi本身也是二进制文件,你只需要按照二进制文件读取方式读取就可以了,所以不理解你这里的x.dat又是什么样的?或者是说轮换成文本文件?如果这样的话你将x.avi一个字符一个字符地读取然后用16进制保存到x.dat中即可。
再转换为y.avi时同理,读取x.dat中的两个文本字符,转换成byte再写入y.avi即可。

5. 几种常用的java 实现反转的方法

1.最简单的方法:
publicstaticStringreverse1(Stringstr)
{
returnnewStringBuffer(str).reverse().toString();
}
2.最常用的方法:
publicstaticStringreverse3(Strings)
{
char[]array=s.toCharArray();
Stringreverse="";//注意这是空串,不是null
for(inti=array.length-1;i>=0;i--)
reverse+=array[i];
returnreverse;
}
3.常用方法的变形:
publicstaticStringreverse2(Strings)
{
intlength=s.length();
Stringreverse="";//注意这是空串,不是null
for(inti=0;i<length;i++)
reverse=s.charAt(i)+reverse;//在字符串前面连接,而非常见的后面
returnreverse;
}
4.C语言中常用的方法:
publicstaticStringreverse5(Stringorig)
{
char[]s=orig.toCharArray();
intn=s.length-1;
inthalfLength=n/2;
for(inti=0;i<=halfLength;i++){
chartemp=s[i];
s[i]=s[n-i];
s[n-i]=temp;
}
returnnewString(s);//知道char数组和String相互转化
}

6. java新人,在学习解压缩文件时,解压文件后,里面的文件变文件夹

file.mkdirs();只有目录才要创建文件夹,如果这个file本应该是文件,你却创建了一个同名文件夹,那自然不能再创建这个文件了(即后面的file.createNewFile();无法创建文件).

另外,对于文件其实是不需要createNewFile的,因为如果你真要解压文件,你要打开对应文件流,并且创一个输出流,输出到目标文件中(这个文件会自动创建的),但你的代码里面没看到这个步骤,给你个完整的解压示例.

importjava.io.File;
importjava.io.FileOutputStream;
importjava.io.IOException;
importjava.io.InputStream;
importjava.io.OutputStream;
importjava.util.Enumeration;
importjava.util.zip.ZipEntry;
importjava.util.zip.ZipFile;

publicclassTest
{
publicstaticvoinZipFiles(StringzipPath,StringdescDir)throwsIOException
{
unZipFiles(newFile(zipPath),descDir);
}

publicstaticvoinZipFiles(FilezipFile,StringdescDir)throwsIOException
{
FilepathFile=newFile(descDir);
if(!pathFile.exists())
{
pathFile.mkdirs();
}
ZipFilezip=newZipFile(zipFile);
for(Enumerationentries=zip.entries();entries.hasMoreElements();)
{
ZipEntryentry=(ZipEntry)entries.nextElement();
StringzipEntryName=entry.getName();
InputStreamin=zip.getInputStream(entry);
StringoutPath=(descDir+zipEntryName).replaceAll("\*","/");

//获取当前file的父路径,这才是文件夹
Filefile=newFile(outPath.substring(0,outPath.lastIndexOf('/')));

//判断路径是否存在,不存在则创建文件路径
if(!file.exists())
{
file.mkdirs();
}
//判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压
if(newFile(outPath).isDirectory())
{
continue;
}
//输出文件路径信息
System.out.println(outPath);

OutputStreamout=newFileOutputStream(outPath);
byte[]buf1=newbyte[1024];
intlen;
while((len=in.read(buf1))>0)
{
out.write(buf1,0,len);
}
in.close();
out.close();
}
System.out.println("******************解压完毕********************");
}

publicstaticvoidmain(String[]args)throwsException
{
unZipFiles(newFile("d:/test.zip"),"e:/");
}
}

7. 新手学习使用Java,尝试着做一个项目使用Java做一个视频图像的处理。

Java图像处理技巧四则
下面代码中用到的sourceImage是一个已经存在的Image对象

图像剪切
对于一个已经存在的Image对象,要得到它的一个局部图像,可以使用下面的步骤:

//import java.awt.*;
//import java.awt.image.*;
Image croppedImage;
ImageFilter cropFilter;
CropFilter =new CropImageFilter(25,30,75,75); //四个参数分别为图像起点坐标和宽高,即CropImageFilter(int x,int y,int width,int height),详细情况请参考API
CroppedImage= Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(sourceImage.getSource(),cropFilter));

如果是在Component的子类中使用,可以将上面的Toolkit.getDefaultToolkit().去掉。FilteredImageSource是一个ImageProcer对象。
图像缩放
对于一个已经存在的Image对象,得到它的一个缩放的Image对象可以使用Image的getScaledInstance方法:

Image scaledImage=sourceImage. getScaledInstance(100,100, Image.SCALE_DEFAULT); //得到一个100X100的图像
Image doubledImage=sourceImage. getScaledInstance(sourceImage.getWidth(this)*2,sourceImage.getHeight(this)*2, Image.SCALE_DEFAULT); //得到一个放大两倍的图像,这个程序一般在一个swing的组件中使用,而类Jcomponent实现了图像观察者接口ImageObserver,所有可以使用this。
//其它情况请参考API

灰度变换
下面的程序使用三种方法对一个彩色图像进行灰度变换,变换的效果都不一样。一般而言,灰度变换的算法是将象素的三个颜色分量使用R*0.3+G*0.59+ B*0.11得到灰度值,然后将之赋值给红绿蓝,这样颜色取得的效果就是灰度的。另一种就是取红绿蓝三色中的最大值作为灰度值。java核心包也有一种算法,但是没有看源代码,不知道具体算法是什么样的,效果和上述不同。

/* GrayFilter.java*/
/*@author:cherami */
/*email:[email protected]*/
import java.awt.image.*;
public class GrayFilter extends RGBImageFilter {
int modelStyle;
public GrayFilter() {
modelStyle=GrayModel.CS_MAX;
canFilterIndexColorModel=true;
}
public GrayFilter(int style) {
modelStyle=style;
canFilterIndexColorModel=true;
}
public void setColorModel(ColorModel cm) {
if (modelStyle==GrayModel
else if (modelStyle==GrayModel
}
public int filterRGB(int x,int y,int pixel) {
return pixel;
}
}
/* GrayModel.java*/
/*@author:cherami */
/*email:[email protected]*/
import java.awt.image.*;
public class GrayModel extends ColorModel {
public static final int CS_MAX=0;
public static final int CS_FLOAT=1;
ColorModel sourceModel;
int modelStyle;

public GrayModel(ColorModel sourceModel) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
modelStyle=0;
}

public GrayModel(ColorModel sourceModel,int style) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
modelStyle=style;
}

public void setGrayStyle(int style) {
modelStyle=style;
}

protected int getGrayLevel(int pixel) {
if (modelStyle==CS_MAX) {
return Math.max(sourceModel.getRed(pixel),Math.max(sourceModel.getGreen(pixel),sourceModel.getBlue(pixel)));
}
else if (modelStyle==CS_FLOAT){
return (int)(sourceModel.getRed(pixel)*0.3+sourceModel.getGreen(pixel)*0.59+sourceModel.getBlue(pixel)*0.11);
}
else {
return 0;
}
}

public int getAlpha(int pixel) {
return sourceModel.getAlpha(pixel);
}

public int getRed(int pixel) {
return getGrayLevel(pixel);
}

public int getGreen(int pixel) {
return getGrayLevel(pixel);
}

public int getBlue(int pixel) {
return getGrayLevel(pixel);
}

public int getRGB(int pixel) {
int gray=getGrayLevel(pixel);
return (getAlpha(pixel)<<24)+(gray<<16)+(gray<<8)+gray;
}
}

如果你有自己的算法或者想取得特殊的效果,你可以修改类GrayModel的方法getGrayLevel()。
色彩变换
根据上面的原理,我们也可以实现色彩变换,这样的效果就很多了。下面是一个反转变换的例子:

/* ReverseColorModel.java*/
/*@author:cherami */
/*email:[email protected]*/
import java.awt.image.*;
public class ReverseColorModel extends ColorModel {
ColorModel sourceModel;
public ReverseColorModel(ColorModel sourceModel) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
}

public int getAlpha(int pixel) {
return sourceModel.getAlpha(pixel);
}

public int getRed(int pixel) {
return ~sourceModel.getRed(pixel);
}

public int getGreen(int pixel) {
return ~sourceModel.getGreen(pixel);
}

public int getBlue(int pixel) {
return ~sourceModel.getBlue(pixel);
}

public int getRGB(int pixel) {
return (getAlpha(pixel)<<24)+(getRed(pixel)<<16)+(getGreen(pixel)<<8)+getBlue(pixel);
}
}
/* ReverseColorModel.java*/
/*@author:cherami */
/*email:[email protected]*/
import java.awt.image.*;
public class ReverseFilter extends RGBImageFilter {
public ReverseFilter() {
canFilterIndexColorModel=true;
}

public void setColorModel(ColorModel cm) {
substituteColorModel(cm,new ReverseColorModel(cm));
}

public int filterRGB(int x,int y,int pixel) {
return pixel;
}
}

要想取得自己的效果,需要修改ReverseColorModel.java中的三个方法,getRed、getGreen、getBlue。
下面是上面的效果的一个总的演示程序。

/*GrayImage.java*/
/*@author:cherami */
/*email:[email protected]*/
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.color.*;
public class GrayImage extends JFrame{
Image source,gray,gray3,clip,bigimg;
BufferedImage bimg,gray2;
GrayFilter filter,filter2;
ImageIcon ii;
ImageFilter cropFilter;
int iw,ih;

public GrayImage() {
ii=new ImageIcon(\"images/11.gif\");
source=ii.getImage();
iw=source.getWidth(this);
ih=source.getHeight(this);
filter=new GrayFilter();
filter2=new GrayFilter(GrayModel.CS_FLOAT);
gray=createImage(new FilteredImageSource(source.getSource(),filter));
gray3=createImage(new FilteredImageSource(source.getSource(),filter2));
cropFilter=new CropImageFilter(5,5,iw-5,ih-5);
clip=createImage(new FilteredImageSource(source.getSource(),cropFilter));
bigimg=source.getScaledInstance(iw*2,ih*2,Image.SCALE_DEFAULT);
MediaTracker mt=new MediaTracker(this);
mt.addImage(gray,0);
try {
mt.waitForAll();
} catch (Exception e) {
}

8. java实现压缩视频文件,但是压缩后并解压,提示文件损坏,我该怎么修改代码

(1)网络传输状况不好(如断线过多,开的线程过多,服务器人太多导致不能连接太多等)导致下载下来的文件损坏!
(2)站点提供的的RAR压缩包本来就是损坏的(这个本站可以保证,所上传的视频及软件等都经过好几遍测试,绝对没问题)。
(3)所使用的下载工具不够完善,比如有的下载工具多开了几个线程后,下载的收尾工作很慢,有些时候下载到99%时数据就不再传输了,一定要人工操作才能结束(先停止下载接着再开始)。笔者就碰到过好几次这样的情况。结果是文件下载下来以后解压缩到快结束时CRC出错。
解决方法:本站为防止这样的事情发生,在每个压缩包里又加了一个备份,防止因以上原因导致的下载后不能用,还得重新下载的问题,只要你下载下来的那个压缩包里的备份是好的那就能把压缩包里的文件恢复能用。
步骤一:双击打开需要解压修复的压缩包,选择:工具——修复压缩文件。
步骤二:出现下边图片的修复框,等待修复完成,关闭窗口及解压缩窗口就可以了。
步骤三:这时你会发现你需要解压的压缩包旁边多了一个压缩包,名称为:fixed.***(你下载的视频名称).rar ,这个压缩包就是修复后的解压缩包,如果修复成功,解压这个名称为:fixed.***(你下载的视频名称).rar 的压缩包就可以了。
如果修复不成功,你再修复几次看看,如果不行,只有再重新下载了

9. java实现压缩单个视频文件,但是好像没有压缩进去,这哪里错了

你ZipOutputStream的流没有关闭。你只关闭了单个条目的流。

执行一下

zip.close()

10. 视频剪辑合并后视频倒过来了

不会的 应该是你把视频前后位置放错了或者就是把“反转视频”点上对好了
不点反转视频就可以了

阅读全文

与java压缩视频后反转了相关的资料

热点内容
怎么测试doh加密 浏览:209
欧美 小说 图片 浏览:908
西安程序员未来的发展趋势 浏览:173
叫阿能的电影 浏览:261
客车购票小程序源码 浏览:645
程序员用数据表白灵魂伴侣 浏览:485
spin命令行 浏览:376
百合txt下载 浏览:61
房贷结清合同是不是解压了 浏览:109
小说资源链接 浏览:447
马桶app怎么开通 浏览:593
军官和程序员哪个更好一点 浏览:245
一个和尚和一个女人的电影叫什么 浏览:510
手机外网服务器地址是多少 浏览:31
单片机外接锂电池供电 浏览:357
文件夹u盘锁 浏览:313
家佳源电影票 浏览:758
人间中不用解压 浏览:704
哪些网站可以免费看会员 浏览:309
python函数提示 浏览:524