A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

孔令程

初级黑马

  • 黑马币:18

  • 帖子:8

  • 精华:0

© 孔令程 初级黑马   /  2014-12-11 20:19  /  1481 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

为什么用合并流将两个视频文件合并在一起后,视频清晰度会下降,而且只有被合并视频的第一个?下面是我的代码
import java.io.*;
class SequenceInputStreamDemo
{
        private InputStream r;
        SequenceInputStreamDemo(InputStream r)
        {
                this.r=r;
        }
        //定义计数器
        int count=0;
        //定义指针
        int pos=0;
        //定义缓存区
        byte[] by=new byte[1024*5];
        public  int myRead() throws IOException
        {
                if(count==0)
                {
                        count=r.read(by);
                        if(count<0)
                                return -1;
                        pos=0;
                        byte b=by[pos];
                        pos++;
                        count--;
                        return b&255;
                }
                else if(count>0)
                {
                        byte b=by[pos];
                        pos++;
                        count--;
                        return b&255;
                }
                return -1;
        }

        public void myClose() throws IOException
        {
                r.close();
        }
}

class SequenceInputStreamDemoText
{
        public static void main(String args[]) throws IOException
        {
                FileInputStream fis=new FileInputStream("E:\\孔令程\\5.3gp");
                FileInputStream fiss=new FileInputStream("E:\\孔令程\\6.3gp");
                FileOutputStream fos=new FileOutputStream("E:\\孔令程\\56.3gp");
                BufferedOutputStream bos=new BufferedOutputStream(fos);
                SequenceInputStream sis=new SequenceInputStream(fis,fiss);
                SequenceInputStreamDemo sisd=new SequenceInputStreamDemo(sis);
                int num=0;
                while((num=sisd.myRead())!=-1)
                {
                        bos.write(num);
                }
                bos.close();
                sis.close();
        }
}

4 个回复

倒序浏览
现在没有时间
回复 使用道具 举报
我表示我还是没有看明白,不太董
回复 使用道具 举报
陈均林 发表于 2014-12-11 20:55
我表示我还是没有看明白,不太董

自定义缓存区,来读写视频文件
回复 使用道具 举报
表示不懂啊。。。。。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马