Java中的视频隐写术 [英] Video Steganography in java
问题描述
我正在为我的项目实施视频隐写术.我从此处.我已经尝试并测试了代码,并且嵌入部分工作正常.但是我遇到了readByte
的问题,这是VideoSteganography
类中的最后一个方法.该方法给出ArrayIndexOutOfBoundsException
.下面是方法.
I am implementing a video steganography for my project. I came across the algorithm from here . i have tried and tested the code and the embedding part is working fine. But i encountered a problem with the readByte
which is the last method in the VideoSteganography
class. The method Gives ArrayIndexOutOfBoundsException
. Below is the method.
我将参数传递为
String fname = jTextField3.getText();
File fil = new File(fname);
String password = "123456";
SteganoInformation cls = new SteganoInformation(fil);
VideoSteganography.retrieveFile(cls, password, true);
方法是
public static boolean retrieveFile(SteganoInformation info, String password, boolean overwrite)
{
File dataFile= null;
features= info.getFeatures();
try
{
masterFile= info.getFile();
byteArrayIn= new byte[(int) masterFile.length()];
DataInputStream in= new DataInputStream(new FileInputStream(masterFile));
in.read(byteArrayIn, 0, (int)masterFile.length());
in.close();
messageSize= info.getDataLength();
byte[] fileArray= new byte[messageSize];
inputOutputMarker= info.getInputMarker();
readBytes(fileArray);
.......
}
请注意上面的方法readBytes,它会引发异常,其编写方式如下
Notice the method readBytes above, it throws the exception and its written as below
private static void readBytes(byte[] bytes)
{
int size= bytes.length;
for(int i=0; i<size ; i++)
{
bytes[i]= byteArrayIn[inputOutputMarker];
inputOutputMarker++;
}
}
推荐答案
@Mazen Wadi,谢谢您的答复.但是我知道是什么引发了异常,并希望分享一些人遇到相同问题的情况.在"VideoSteganography类"和"SteganoInformation类"这两个类中,两个类中的方法restoreBytes()都有两个循环.将循环更改为下面的循环,并确保两个类中的循环大小相符.注意:从两个类的retrieveBytes方法中更改j = 6即可解决问题.
@Mazen Wadi , thanks for your reply. But i figured what triggered the very exception and would like to share in case some one would encounter the same problem. From the two classes "VideoSteganography class" and "SteganoInformation class" , there are two loops from the methods retrieveBytes() from both classes. Change loops to the one below and make sure the loop size tally in both classes. Note: change j=6 from retrieveBytes method of the two classes and your problem is solved.
private static void retrieveBytes(byte[] bytes)
{
int size= bytes.length;
for(int i=0; i< size; i++)
{
byte1= 0;
for(int j=6; j>=0; j-=2)
{
byte2= byteArrayIn[inputOutputMarker];
inputOutputMarker++;
byte2&= 0x03;
byte2<<= j;
byte1|= byte2;
}
bytes[i]= byte1;
}
}
这篇关于Java中的视频隐写术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!