• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileDataSourceImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.googlecode.mp4parser.FileDataSourceImpl的典型用法代码示例。如果您正苦于以下问题:Java FileDataSourceImpl类的具体用法?Java FileDataSourceImpl怎么用?Java FileDataSourceImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileDataSourceImpl类属于com.googlecode.mp4parser包,在下文中一共展示了FileDataSourceImpl类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: M4AReader

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
/**
 * Creates M4A reader from file input stream, sets up metadata generation flag.
 *
 * @param f                    File input stream
 * @throws IOException on IO error
 */
public M4AReader(File f) throws IOException {
	if (null == f) {
		log.warn("Reader was passed a null file");
		log.debug("{}", ToStringBuilder.reflectionToString(this));
	}
	// create a datasource / channel
	dataSource = new FileDataSourceImpl(f);
	// instance an iso file from mp4parser
	isoFile = new IsoFile(dataSource);
	//decode all the info that we want from the atoms
	decodeHeader();
	//analyze the samples/chunks and build the keyframe meta data
	analyzeFrames();
	//add meta data
	firstTags.add(createFileMeta());
	//create / add the pre-streaming (decoder config) tags
	createPreStreamingTags();
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:25,代码来源:M4AReader.java


示例2: MP4Reader

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
/**
 * Creates MP4 reader from file input stream, sets up metadata generation flag.
 *
 * @param f                    File input stream
 * @throws IOException on IO exception
 */
public MP4Reader(File f) throws IOException {
	if (null == f) {
		log.warn("Reader was passed a null file");
		log.debug("{}", ToStringBuilder.reflectionToString(this));
	}
	if (f.exists() && f.canRead()) {
		// create a datasource / channel
		dataSource = new FileDataSourceImpl(f);
		// instance an iso file from mp4parser
		isoFile = new IsoFile(dataSource);
		//decode all the info that we want from the atoms
		decodeHeader();
		//analyze the samples/chunks and build the keyframe meta data
		analyzeFrames();
		//add meta data
		firstTags.add(createFileMeta());
		//create / add the pre-streaming (decoder config) tags
		createPreStreamingTags(0, false);
	} else {
		log.warn("Reader was passed an unreadable or non-existant file");
	}
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:29,代码来源:MP4Reader.java


示例3: mergeAudioFile

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
private void mergeAudioFile(File recordedFile, File recordedFileTemp) throws IOException {
    if (!recordedFile.exists()) {
        recordedFileTemp.renameTo(new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD).getPath()));
        return;
    }
    final Movie movieA = MovieCreator.build(new FileDataSourceImpl(recordedFileTemp));
    final Movie movieB = MovieCreator.build(new FileDataSourceImpl(recordedFile));
    final Movie finalMovie = new Movie();
    final List<Track> movieOneTracks = movieA.getTracks();
    final List<Track> movieTwoTracks = movieB.getTracks();
    //for (int i = 0; i < movieOneTracks.size() || i < movieTwoTracks.size(); ++i) {
        finalMovie.addTrack(new AppendTrack(movieTwoTracks.get(0), movieOneTracks.get(0)));
    //}
    final Container container = new DefaultMp4Builder().build(finalMovie);
    File recordedFileMerged = new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD_MERGED).getPath());
    if (recordedFileMerged.exists()) {
        recordedFileMerged.delete();
    }
    final FileOutputStream fos = new FileOutputStream(new File(String.format(recordedFileMerged.getPath())));
    final WritableByteChannel bb = Channels.newChannel(fos);
    container.writeContainer(bb);
    fos.close();
    recordedFile.delete();
    recordedFileTemp.delete();
    recordedFileMerged.renameTo(new File(LocalMediaStorage.getOutputMediaFileUri(null, LocalMediaStorage.MEDIA_TYPE_AUDIO_RECORD).getPath()));
}
 
开发者ID:andreaslorentzen,项目名称:Dansk-Datahistorisk-Forening,代码行数:27,代码来源:AudioRecorder.java


示例4: makeMP4

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
/**
 * Creates an MP4 file out of encoded h.264 bytes.
 * 
 * @throws IOException
 */
public static void makeMP4() throws IOException {
	H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("dump.h264"));
	//AACTrackImpl aacTrack = new AACTrackImpl(new FileInputStream("/home/sannies2/Downloads/lv.aac").getChannel());
	Movie m = new Movie();
	m.addTrack(h264Track);
	//m.addTrack(aacTrack);
	Container out = new DefaultMp4Builder().build(m);
	FileOutputStream fos = new FileOutputStream(new File("h264_output.mp4"));
	FileChannel fc = fos.getChannel();
	out.writeContainer(fc);
	fos.close();
}
 
开发者ID:mondain,项目名称:h264app,代码行数:18,代码来源:H264Main.java


示例5: muxerFileDebug

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
public static void muxerFileDebug(){
	try 
	{
		File input = new File(SDCardUtils.getExternalSdCardPath() + "/a.h264");
		File output = new File(SDCardUtils.getExternalSdCardPath() + "/b.mp4");

		H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(input), "eng", UriParser.videoQuality.framerate, 1);
		Movie m = new Movie();
		m.addTrack(h264Track);
		m.setMatrix(Matrix.ROTATE_90);
		Container out = new DefaultMp4Builder().build(m);
		MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
   		mvhd.setMatrix(Matrix.ROTATE_90);
		TrackBox trackBox  = Path.getPath(out, "moov/trak");
		TrackHeaderBox tkhd = trackBox.getTrackHeaderBox();
		tkhd.setMatrix(Matrix.ROTATE_90);
		FileChannel fc = new FileOutputStream(output.getAbsolutePath()).getChannel();
		out.writeContainer(fc);
		fc.close();

	} 
	catch (IOException e) {
	    Log.e("test", "some exception", e);
	}	
}
 
开发者ID:xunboo,项目名称:JJCamera,代码行数:26,代码来源:MP4Muxer.java


示例6: append

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
public static void append(
        final String firstFile,
        final String secondFile,
        final String newFile) throws IOException {
    final Movie movieA = MovieCreator.build(new FileDataSourceImpl(secondFile));
    final Movie movieB = MovieCreator.build(new FileDataSourceImpl(firstFile));

    final Movie finalMovie = new Movie();

    final List<Track> movieOneTracks = movieA.getTracks();
    final List<Track> movieTwoTracks = movieB.getTracks();

    for (int i = 0; i < movieOneTracks.size() || i < movieTwoTracks.size(); ++i) {
        finalMovie.addTrack(new AppendTrack(movieTwoTracks.get(i), movieOneTracks.get(i)));
    }

    final Container container = new DefaultMp4Builder().build(finalMovie);

    final FileOutputStream fos = new FileOutputStream(new File(String.format(newFile)));
    final WritableByteChannel bb = Channels.newChannel(fos);
    container.writeContainer(bb);
    fos.close();
}
 
开发者ID:EnteriseToolkit,项目名称:paperchains,代码行数:24,代码来源:Mp4ParserWrapper.java


示例7: load

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
@Override
public Media load(FileBaseResourceInfo fileBaseResourceInfo) throws IOException {
	Assert.notNull(fileBaseResourceInfo);
	
	File file = fileBaseResourceInfo.getFile();
	
	DataSource dataSource = new FileDataSourceImpl(file);

	try{
		IsoFile isoFile = new IsoFile(dataSource);
		return loadIsoFile(isoFile, fileBaseResourceInfo);
	}finally{
		IOUtils.closeQuietly(dataSource);
	}
	
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:17,代码来源:VideoLoader.java


示例8: startTrim

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
public static void startTrim(File src, File dst, double startTime, double endTime) throws IOException {
    FileDataSourceImpl file = new FileDataSourceImpl(src);
    Movie movie = MovieCreator.build(file);
    List<Track> tracks = movie.getTracks();
    movie.setTracks(new LinkedList<Track>());

    Log.d(TAG, "startTrim: " + startTime + " " + endTime);
    for (Track track : tracks) {
        long currentSample = 0;
        double currentTime = 0;
        long startSample = -1;
        long endSample = -1;
        for (int i = 0; i < track.getSampleDurations().length; i++) {
            if (currentTime <= startTime) {

                // current sample is still before the new starttime
                startSample = currentSample;
            }
            if (currentTime <= endTime) {
                // current sample is after the new start time and still before the new endtime
                endSample = currentSample;
            } else {
                // current sample is after the end of the cropped video
                break;
            }
            currentTime += (double) track.getSampleDurations()[i] / (double) track.getTrackMetaData().getTimescale();
            currentSample++;
        }
        movie.addTrack(new CroppedTrack(track, startSample, endSample));
    }
    Container out = new DefaultMp4Builder().build(movie);
    MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
    mvhd.setMatrix(Matrix.ROTATE_180);
    if (!dst.exists()) {
        dst.createNewFile();
    }
    FileOutputStream fos = new FileOutputStream(dst);
    WritableByteChannel fc = fos.getChannel();
    try {
        out.writeContainer(fc);
    }catch (Exception e){
        e.printStackTrace();
    } finally {
        fc.close();
        fos.close();
        file.close();
    }
}
 
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:49,代码来源:ProcessVideoUtils.java


示例9: testGetBitrate

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
@Test
public void testGetBitrate() throws Exception {
    String f =
            this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile() +
            "Beethoven - Bagatelle op.119 no.11 i.m4a";
    Movie m = MovieCreator.build(new FileDataSourceImpl(f));
    Track t = m.getTracks().get(0);
    AbstractManifestWriter amw = new AbstractManifestWriter(null) {
        public String getManifest(Movie inputs) throws IOException {
            return null;
        }
    };
    Assert.assertEquals(127928, amw.getBitrate(t));
}
 
开发者ID:sannies,项目名称:mp4parser-smooth-streaming,代码行数:15,代码来源:AbstractManifestWriterTest.java


示例10: load

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
@Override
public Media load(FileBaseResourceInfo fileBaseResourceInfo) throws IOException {
	Assert.notNull(fileBaseResourceInfo);
	
	File file = fileBaseResourceInfo.getFile();
	
	DataSource dataSource = new FileDataSourceImpl(file);
	try{
		IsoFile isoFile = new IsoFile(dataSource);
		return loadIsoFile(isoFile, fileBaseResourceInfo);
	}finally{
		IOUtils.closeQuietly(dataSource);
	}
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:15,代码来源:M4aLoader.java


示例11: main

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("data.h264"));
    //AACTrackImpl aacTrack = new AACTrackImpl(new FileInputStream("/home/sannies2/Downloads/lv.aac").getChannel());
    Movie m = new Movie();
    m.addTrack(h264Track);
    //m.addTrack(aacTrack);

    //{
        Container out = new DefaultMp4Builder().build(m);
        FileOutputStream fos = new FileOutputStream(new File("CPR_h264_output.mp4"));
        FileChannel fc = fos.getChannel();
        out.writeContainer(fc);
        fos.close();
   // }
}
 
开发者ID:cprasmu,项目名称:RasCam-Server,代码行数:16,代码来源:H264Test.java


示例12: concatTwoVideos

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
public static boolean concatTwoVideos(File src1, File src2, File dst) {
    try {
        FileDataSourceImpl file1 = new FileDataSourceImpl(src1);
        FileDataSourceImpl file2 = new FileDataSourceImpl(src2);
        Movie result = new Movie();
        Movie movie1 = MovieCreator.build(file1);
        Movie movie2 = MovieCreator.build(file2);

        Movie[] inMovies = new Movie[]{
                movie1, movie2
        };

        List<Track> videoTracks = new LinkedList<Track>();
        List<Track> audioTracks = new LinkedList<Track>();

        for (Movie m : inMovies) {
            for (Track t : m.getTracks()) {
                if (t.getHandler().equals("soun")) {
                    audioTracks.add(t);
                }
                if (t.getHandler().equals("vide")) {
                    videoTracks.add(t);
                }
            }
        }

        if (audioTracks.size() > 0) {

            result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));

        }
        if (videoTracks.size() > 0) {

            result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));

        }

        Container out = new DefaultMp4Builder().build(result);
        MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
        mvhd.setMatrix(Matrix.ROTATE_180);
        if (!dst.exists()) {
            dst.createNewFile();
        }
        FileOutputStream fos = new FileOutputStream(dst);
        WritableByteChannel fc = fos.getChannel();
        try {
            out.writeContainer(fc);
        } finally {
            fc.close();
            fos.close();
            file1.close();
            file2.close();
        }
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:60,代码来源:ProcessVideoUtils.java


示例13: muxerFile

import com.googlecode.mp4parser.FileDataSourceImpl; //导入依赖的package包/类
private static void muxerFile(MP4Info mi){		

		String videoFile = mi.mVideoName, audioFile = mi.mAudioName, outputFile = mi.mMp4Name;
		Matrix mMatrix = mi.mMatrix;

		File fVideo = new File(videoFile), fAudio = new File(audioFile);

		if(fVideo.length()==0){
			fVideo.delete();
        	fAudio.delete();

			return;
		}

		if(fAudio.length()==0){
        	fAudio.delete();
			audioFile = null;
		}	
		
		try {
			Log.i(TAG,  "generate a MP4 file...");
			
			// build a MP4 file
			H264TrackImpl h264Track = null;
			AACTrackImpl aacTrack = null;

			h264Track = new H264TrackImpl(new FileDataSourceImpl(videoFile), "eng", UriParser.videoQuality.framerate, 1);
			if(audioFile != null)
		 		aacTrack = new AACTrackImpl(new FileDataSourceImpl(audioFile));

			Movie movie = new Movie();
			movie.setMatrix(mMatrix);
			movie.addTrack(h264Track);
			h264Track.getTrackMetaData().setMatrix(mMatrix);
			if(aacTrack != null){
				/*
					In AAC there are always samplerate/1024 sample/s so each sample's duration is 1000 * 1024 / samplerate milliseconds.

					48KHz => ~21.3ms
					44.1KHz => ~23.2ms
					By omitting samples from the start you can easily shorten the audio track. Remove as many as you need. You will not be able to match audio and video exactly with that but the human perception is more sensible to early audio than to late audio.
				*/
				Log.i(TAG, "video getDuration " + h264Track.getDuration() );
				Log.i(TAG, "audio getDuration " + aacTrack.getDuration() );
				Log.i(TAG, "video length (ms) " + h264Track.getSamples().size() * 1000 / UriParser.videoQuality.framerate);
				Log.i(TAG, "audio length (ms) " + aacTrack.getSamples().size() * 128);
				//int offset = 10;// 1300/ (1000 * 1024 / 8000);
				//CroppedTrack aacTrackShort = new CroppedTrack(aacTrack, offset, aacTrack.getSamples().size());
				//movie.addTrack(aacTrackShort);
				movie.addTrack(aacTrack);
			}

			Container mp4file = new DefaultMp4Builder().build(movie);

			FileChannel fc = new FileOutputStream(new File(SDCardUtils.getExternalSdCardPathForVideo() + outputFile)).getChannel();
			mp4file.writeContainer(fc);
			fc.close();

			Log.i(TAG, "finish a MP4 file...");
		}
		catch(Exception e) {
			e.printStackTrace();
		}	

		fVideo.delete();
        fAudio.delete();
	}
 
开发者ID:xunboo,项目名称:JJCamera,代码行数:68,代码来源:MP4Muxer.java



注:本文中的com.googlecode.mp4parser.FileDataSourceImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FreeMarkerView类代码示例发布时间:2022-05-22
下一篇:
Java CGraphicsDevice类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap