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

jcodec: a pure java implementation of video/audio codecs.

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

开源软件名称:

jcodec

开源软件地址:

https://gitee.com/HarmonyOS-tpc/jcodec

开源软件介绍:

jcodec - a pure java implementation of video/audio codecs.

Introduction

JCodec is a library implementing a set of popular video and audio codecs.

Currently JCodec supports MP4 Video format.

JCodec is free software distributed under FreeBSD License.

Features supported:

  1. Decode a particular Image frame from a video file.
  2. Performance / quality considerationsBecause JCodec is a pure Java implementation please adjust your performance expectations accordingly. We usually make the best effort to write efficient code but despite this the decoding will typically be an order of magnitude slower than the native implementations (such as FFMpeg). We are currently looking into implementing performance-critical parts in OpenCL but the ETA is unknown.

Expect the encoded quality/bitrate for h.264 (AVC) to be so much worse compared to the well known native encoders (such as x264). This is because very little work has been put so far into developing the encoder and also because encoders usually trade speed for quality, speed is something we don't have in Java, hence the quality. Again we may potentially fix that in the future by introducing OpenCL (RenderScript) code but at this point it's an unknown.

That said the decode quality should be at the industry level. This is because the decoding process is usually specified by the standard and the correct decoder implementations are expected to produce bit-exact outputs.

Usage Instruction

Getting a single frame from a movie ( supports only AVC, H.264 in MP4, ISO BMF, Quicktime container ):

int frameNumber = 42;Picture picture = FrameGrab.getFrameFromFile(new File("/data/user/0/org.jcodec.samples/cache/jcodec_cache/sample.mp4"), frameNumber);//for openharmony (jcodec-openharmony)PixelMap bitmap = HarmonyUtil.toBitmap(picture);IMAGEVIEW.setPixelMap( bitmap);

Read Tape Timecode from MXF file

TapeTimecode timecode = MXFDemuxer.readTapeTimecode(new File("myfile.mxf"));

Parse DPX metadata

DPXMetadata dpx = DPXReader.readFile(firstDpx).parseMetadata();System.out.println(dpx.getTimecodeString());

Parse Apple GPS metadata from MOV or MP4 file

MovieBox moov = MP4Util.parseMovie(new File("gps1.mp4"));UdtaBox udta = NodeBox.findFirst(moov, UdtaBox.class, "udta");String latlng = udta.latlng();assertEquals("-35.2840+149.1215/", latlng);

OR

MovieBox mov = MP4Util.parseMovie(new File("gps2.MOV"));Box found = findDeep(mov, "meta");if (found == null) {    System.out.println("Atom " + atom + " not found.");    return null;} else {    System.out.println("Atom found " + found.toString());}

Extract subtitles from MKV file

MKVDemuxer demuxer = new MKVDemuxer(new AutoFileChannelWrapper(new File("subs.mkv")));DemuxerTrack track = demuxer.getSubtitleTracks().get(0);Packet packet;while (null != (packet = track.nextFrame())) {    String text = takeString(packet.getData());    System.out.println("time: " + packet.pts + " text: " + text);}

MP4/M4A/MOV metadata versions

Some editors (e.g. Final Cut Pro 7) employ a clever hack to support multiple versions of metadata for mp4 files.The trick is to append a new version of moov atom to end of file and set previous version atom name to free.Jcodec supports this hack via org.jcodec.movtool.MoovVersions

See MoovVersionsTest.java for complete usage example.

To list available versions use

MoovVersions.listMoovVersionAtoms(new File("/data/my.mp4"))

To add a version

moov = MP4Util.parseMovie(new File("/data/my.mp4"))//add your modifications to moov hereMoovVersions.addVersion(new File("/data/my.mp4"), moov)

To rollback (undo) to previous version

MoovVersions.undo(new File("/data/my.mp4"))

To rollback to specific version

versions = MoovVersions.listMoovVersionAtoms(new File("my.mp4"))//pick your versionversion = versions.get(Math.random()*versions.size())MoovVersions.rollback(new File("my.mp4"), version)

Installation instruction

JCodec can be used in both standard Java and openharmony. It contains platform-agnostic java classes.

Method 1:

  1. Add the .har package to the lib folder.
  2. Add the following code to the gradle of the entry:implementation fileTree(dir: 'libs', include: ['.jar', '.har'])

Method 2:

allprojects {    repositories {        mavenCentral()    }}dependencies {    implementation 'io.openharmony.tpc.thirdlib:jcodec:1.0.2'    implementation 'io.openharmony.tpc.thirdlib:harmony:1.0.0'}

License

Copyright 2008-2019 JCodecProjectRedistribution  and  use  in   source  and   binary   forms,  with  or  withoutmodification, are permitted provided  that the following  conditions  are  met:Redistributions of  source code  must  retain the above  copyright notice, thislist of conditions and the following disclaimer. Redistributions in binary formmust  reproduce  the above  copyright notice, this  list of conditions  and thefollowing disclaimer in the documentation and/or other  materials provided withthe distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO, THE  IMPLIEDWARRANTIES  OF  MERCHANTABILITY  AND  FITNESS  FOR  A  PARTICULAR  PURPOSE  AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,  OR CONSEQUENTIAL DAMAGES(INCLUDING,  BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE GOODS  OR SERVICES;LOSS OF USE, DATA, OR PROFITS;  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT LIABILITY,  OR TORT(INCLUDING  NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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