導航:首頁 > 文件處理 > 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壓縮視頻後反轉了相關的資料

熱點內容
日本重生電影最後主角死了沒 瀏覽:137
愛奇電影大全 瀏覽:373
cf美國伺服器如何下載 瀏覽:152
linux後退命令 瀏覽:901
吳京在泰國監牢叫什麼電影 瀏覽:726
男主是中東王儲的小說 瀏覽:587
囚禁百合文推薦 瀏覽:582
李海仁倫理片 瀏覽:316
韓國愛情大尺度電影 瀏覽:131
40部封禁小說都有什麼 瀏覽:720
天資榜第十名葉凌天七殺霸體 瀏覽:713
家庭教師高級課程中的老師是誰 瀏覽:492
近期韓國劇情片 瀏覽:251
誰的電影官網 瀏覽:168
月餅自動包餡機plc編程 瀏覽:129
pdf百度雲盤 瀏覽:356
php和java的優點 瀏覽:232
怎麼進入vim編譯環境 瀏覽:415
程序員做外貿視頻 瀏覽:762
a大尺度電影網址 瀏覽:390