0

我已经在 java 中实现了图像和音频隐写术,现在我想实现视频隐写术。但是,我仍然无法找到用于执行此操作的类,例如允许我以二进制形式查看视频数据的类(因为我将使用 lsb 替换技术)。

4

1 回答 1

2

我去年的毕业证书项目是我使用 netbeans IDE 开发的视频速记,我将在这里发布代码,我是如何完成所有过程的。

package Stegnography;


import java.io.File;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 *
 * @author DeepRocks
 */
public class EmbProcess {
    String embfilename;
    public String emb(String s, String s1)
    {
        try{
        File file = new File(s);
        File file1 = new File(s1);
        FileInputStream fileinputstream = new FileInputStream(s);
        FileOutputStream fileoutputstream = new FileOutputStream("temp");
        byte abyte0[] = new byte[8];
        int i;
        int k;
        for(k = 0; (i = fileinputstream.read(abyte0, 0, 8)) > 0; k = i)
            fileoutputstream.write(abyte0, 0, i);

        fileinputstream.close();
        for(int l = 1; l <= 8 - k; l++)
            fileoutputstream.write(65);

        fileoutputstream.write("DATAFILE".getBytes(), 0, 8);
        System.out.println("File name==="+file1.getName());
        StringBuffer stringbuffer = new StringBuffer(file1.getName());
        stringbuffer.setLength(50);
        fileoutputstream.write(stringbuffer.toString().getBytes(), 0, 50);
        fileinputstream = new FileInputStream(s1);
        int j;
        while((j = fileinputstream.read(abyte0, 0, 8)) > 0) 
            fileoutputstream.write(abyte0, 0, j);
        fileinputstream.close();
        fileoutputstream.close();
        file.delete();
        File file2 = new File("temp");
        file2.renameTo(file);
        embfilename=file.getName();
        }
        catch(Exception e){
            e.printStackTrace();
            embfilename="";
        }
        return embfilename;
    }

    public String demb(String s)
    {
        boolean flag;
        String demfile = "";
        try
        {
            File file = new File(s);
            String outpath=s.substring(0, s.lastIndexOf("\\")+1);
            FileInputStream fileinputstream = new FileInputStream(s);
            char c = '\b';
            byte abyte0[] = new byte[c];
            String s1 = "";
            int i;
            while((i = fileinputstream.read(abyte0, 0, c)) > 0) 
            {
                s1 = new String(abyte0);
                if(s1.equals("DATAFILE"))
                    break;
            }
            if(!s1.equals("DATAFILE"))
            {
                flag=false;
                fileinputstream.close();
                return demfile;
            }
            abyte0 = new byte[50];
            fileinputstream.read(abyte0, 0, 50);
            s1 = new String(abyte0);
            String s2 = s1.trim();
            String fpath = s2.substring(0, s2.lastIndexOf(".") + 1) + "enc";
            System.out.println("fpath------"+fpath);
            FileOutputStream fileoutputstream = new FileOutputStream(outpath+fpath);
            c = '\u5000';
            abyte0 = new byte[c];
            while((i = fileinputstream.read(abyte0, 0, c)) > 0) 
                fileoutputstream.write(abyte0, 0, i);
            fileinputstream.close();
            fileoutputstream.close();
            demfile=fpath;
        }
        catch(Exception exception)
        {
            demfile="";
            exception.printStackTrace();
            System.out.println(exception);
        }
        return demfile;
    }

}**THIS CODE IS FOR EMBEDDING PROCESS**

请清楚你真正想要什么,我会帮你看看我的代码,如果它对你有帮助,我会给你我的项目。

于 2013-08-04T19:06:36.450 回答