NALU | Keras Implementation of : Neural Arithmetic Logic Units | Machine Learning library

 by   kgrm Python Version: Current License: No License

kandi X-RAY | NALU Summary

kandi X-RAY | NALU Summary

NALU is a Python library typically used in Artificial Intelligence, Machine Learning, Deep Learning, Keras applications. NALU has no bugs, it has no vulnerabilities and it has low support. However NALU build file is not available. You can download it from GitHub.

Initial Keras implementation of the Neural Arithmetic Logic Units.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              NALU has a low active ecosystem.
              It has 130 star(s) with 14 fork(s). There are 9 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 4 open issues and 0 have been closed. On average issues are closed in 766 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of NALU is current.

            kandi-Quality Quality

              NALU has 0 bugs and 10 code smells.

            kandi-Security Security

              NALU has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              NALU code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              NALU does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              NALU releases are not available. You will need to build from source code and install.
              NALU has no build file. You will be need to create the build yourself to build the component from source.
              NALU saves you 36 person hours of effort in developing the same functionality from scratch.
              It has 97 lines of code, 8 functions and 1 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of NALU
            Get all kandi verified functions for this library.

            NALU Key Features

            No Key Features are available at this moment for NALU.

            NALU Examples and Code Snippets

            No Code Snippets are available at this moment for NALU.

            Community Discussions

            QUESTION

            Invalid NAL unit size for MP4 created from NALU with 3-byte start code (0x000001)
            Asked 2020-Sep-09 at 04:19

            I have a mp4 muxer that works fine when the H264 NALU has the 4-byte start code (0x00000001). I am adapting it to support 3-byte start code (0x000001) but I am stuck with a bug that I am not able to identify. The MP4 generated open in VLC and MediaPlayer but no video is displayed. In VLC statistics shows that it is decoding blocks but stays with 0 frames displayed.

            I then ran a error analyzer using ffmpeg (ffmpeg -v error -i myvideo.mp4 -f null - 2>error.log that shows me the following output:

            ...

            ANSWER

            Answered 2020-Sep-09 at 04:19

            The "Invalid NAL unit size" was referring to the Moof->Traf->Trun "sample size" with a value different than the actual mdat payload size (mdat payload = mdat box without the first 8 bytes which are the length and the 'mdat' name).

            That was happening due to my muxer receiving the H264 chunk and using that chunk size as the "sample size" instead of calculating the actual mdat payload size. That bug only got visible when the H264 chunks received by my muxer didn't have a 4-byte NALU start code (since I am using 4 bytes for each NALU length size).

            Source https://stackoverflow.com/questions/63721270

            QUESTION

            Decode an H264 stream using the VideoToolbox API (kVTVideoDecoderBadDataErr)
            Asked 2020-Jun-24 at 15:46

            my goal is to encode the main framebuffer of my Windows machine using nvenc and stream its content to my iPad using the VideoToolbox API

            The code I use to encode the h264 stream is basically a copy/paste of https://github.com/NVIDIA/video-sdk-samples/tree/master/nvEncDXGIOutputDuplicationSample the only change is that instead of writing to a file, I do send the data

            For the decoding I do use https://github.com/zerdzhong/SwfitH264Demo/blob/master/SwiftH264/ViewController.swift#L71

            The encoding work perfectly when I write all the contents to a file, I am able to use a h264->mp4 online converter without issue, the problem is that the decoder gives me the error kVTVideoDecoderBadDataErr in the function decompressionSessionDecodeFrameCallback

            So for what I tried:

            • Firsly using an h264 analyzer I found that the frame order are: 7/8/5/5/5/5/1...
            • I found that nvenc does encode the frames 7/8/5/5/5/5 in only one packet
            • I did try to separate this packet into multiple ones using the sequence (0x00 0x00 0x00 0x01), it gave me the frames 7/8/5 separately
            • As you can see I only got one 5 frame which is around 100KB, the H264 analyzer said that there are four 5 frames (which are something like 40KB, 20KB, 30KB, 10KB)
            • Using a hex file viewer I saw that the sequence separating those 5 frames were (0x00 0x00 0x01) instead, tried to also separate them but I got the exact same VideoToolbox error while decompressing

            here is the code I use to separate and send the frames: The protocol is simply PACKET_SIZE->PACKET_DATA The swift code is able to read the NALU types so I am confident that this is not the issue

            ...

            ANSWER

            Answered 2020-Jun-24 at 15:46

            Alright so as weird as it sounds, my code does work on the simulator but not on my iPad pro. In the end it does work so I'll still mark it as the correct answer

            Source https://stackoverflow.com/questions/62499298

            QUESTION

            Extract raw I frame image data from MPEG-2 Transport Stream (H.264 - Annex B) byte stream
            Asked 2020-Mar-05 at 17:04
            Context

            I'm attempting to extract raw image data for each I-frame from an MPEG-2 Transport Stream with a H.264 annex B codec. This video contains I-frames on every 2 second interval. I've read that an I-frame can be found in after an NALu start code with a type of 5 (e.g. Coded slice of an IDR picture). The byte payload of these NALu's contains all the necessary data to construct a full frame. Albeit to, my understanding, in a H.264 encoded format.

            I would like to build a solution to extract these I-frame from an incoming byte stream, by finding NALu's that contain I-frames, saving the payload and decoding the payload into some ubiquitous raw image format to access pixel data etc.

            Note: I would like to avoid using filesystem dependency binaries like ffmpeg if possible and more importantly if feasible!

            PoC

            So far I have build an PoC in rust to find the byte offset, and byte size of I-frames:

            ...

            ANSWER

            Answered 2020-Mar-05 at 17:04

            “ Is there a decoding step that needs to be performed?”

            Yes. And writing a decoder from scratch is EXTREMELY complicated. The document that describes it (ISO 14496-10) is over 750 pages long. You should use a library. Libavcodec from the ffmpeg is really your only option. (Unless you only need baseline profile, in which you can use the open source decoder from android)

            You can compile a custom version of libavcodec to exclude things you don’t need.

            Source https://stackoverflow.com/questions/60547654

            QUESTION

            Format h264 detected only with low score of 1, misdetection possible
            Asked 2020-Mar-03 at 03:00

            there are a h264 rtp stream passing through server, I catch every rtp packets and extract every nalu by getting rid of rtp header, and then write every nalu to file record.h264 with adding a h264 prefix start code 0x00000001, but file record.h264 cannot be played by ffplay and cannot be parsed by ffprobe, where is wrong?

            here is my record file:https://github.com/sshsu/record_h264_file

            ...

            ANSWER

            Answered 2020-Mar-03 at 03:00

            You might be skipping the decoding of the NAL header within the RtpPacket to it's full format from the aggregated form.

            I have an implementation in C# here: https://github.com/juliusfriedman/net7mma_core/blob/master/RtspServer/MediaTypes/RFC6184Media.cs if it helps you.

            Source https://stackoverflow.com/questions/60499376

            QUESTION

            How to detect and correct errors in x264 NAL Units?
            Asked 2020-Jan-10 at 05:40

            Suppose I am receiving packets containing H264 encoded NAL Units, and each NAL has correct START_CODE (0x00 00 00 01).

            But in some NALUs, the later Bytes of the NAL may have been corrupted. Is there any standard way to validate whether the information represented by a NALU is correct or not?

            And if it can be validated, is there any standard way to correct it according to the H264 standards ?

            Further Clarification:

            The problem to specify is somewhat like this ->

            Server sends a x264 NALU like 0x 00000001abcdefgh and, when I receive the packet, it contains : 0x 00000001abcmnopdefgh.

            This leads to failure of decompression , hence I was looking for a way to eliminate these bad data bytes.

            ...

            ANSWER

            Answered 2020-Jan-09 at 16:55

            The only way to validate it is to parse the entire nal and make sure you have the correct number of bits. Even then some errors may not be detected.

            No there is no way to correct the errors unless the container/file includes erasure codes.

            Source https://stackoverflow.com/questions/59668176

            QUESTION

            H.265 (HEVC) Decoding on iOS - what is the correct NALU order before frames can be decoded
            Asked 2019-Nov-18 at 16:45

            I recently got HEVC / H.265 decoding working using VideoToolbox api in iOS. The incoming RTP stream came from FFMPEG using the x265 codec in libx265.

            After much tinkering, I created my CMFormatDescription using the incoming VPS, SPS and PPS nalus - then I waited for a CRA_NUT nalu (21) keyframe. Once that came through, I could decode the next wave of video packets received. Great!

            However I want to now accept an RTP stream encoded by Nvidia's Video Coding SDK. The difference is though that instead of a CRA_NUT nalu arriving after the sequence parameters - I am now receiving an IDR_W_RADL (19) which VideoToolbox doesn't seem to like - as a result i get kVTVideoDecoderBadDataErr from my decompression session's callback.

            Since the documentation is quite sparse for VideoToolbox - it's quite difficult to debug. Does VideoToolBox always expect a CRA_NUT nalu as a keyframe? Or is there any way to make it accept an IDR_W_RADL keyframe? Is there a standard sequence VideoToolbox expects?

            Conversely, is there any way to configure the nvidia video codec sdk to return a CRA_NUT keyframe? I've looked through the api but can't find anything - i always seem to get IDR_W_RADL along with the sequence parameters.

            ...

            ANSWER

            Answered 2018-Nov-03 at 16:56

            Ok, the issue isn't with VideoToolbox - I had a silly logic error on my part which blocked certain frames getting through to the decoder! VideoToolBox accepts IDR_W_RADL frames with no bother! Works a charm.

            Source https://stackoverflow.com/questions/53124590

            QUESTION

            C/C++ FLV muxer encapsulating H.264 not working as expected
            Asked 2019-Jul-09 at 04:13

            I'm trying to make a FLV muxer. And I'm started to test on a h264 stream I capture from my camera (c920). After encoding the .flv file, it doesn't play correctly.

            First I tried to find NALs in h264 searching for the pattern 0x00 0x00 0x00 0x01... but I found in the internet that there are two patterns to find NALs... So I implemented the searching for 0x00 0x00 0x01 and the other...

            In firsts tests I found that are few NALs starting with four bytes, but after changing the code to search the 3 bytes pattern I found a lot of NALs...

            The references I found in the internet shows code using few NAL types to encapsulate the FLV file, but after the change to detect 3 bytes, the program found a lot of NALs and I don't know how to stream them...

            Some code :-)

            I'm implementing in C++, so I have the classes.

            The FLVWritter

            ...

            ANSWER

            Answered 2019-Jul-09 at 04:13

            WIP (work in progress)

            But I found a lot of new information :-).

            First: The FLV container does not work packing one by one NAL buffers from h264.

            Second: The timestamp needs to be increased just when a new frame is available.

            The problem with the green screen I got is related to the fragmentation on NAL packages with the timestamp issue.

            The difficult part is to detect when the stream is getting a new frame. There are several ways as mentioned here.

            But the h264 stream have data members with different bit sizes in its structure.

            Reading Bits

            ue(v) data type. To read this structure you need to count the leading 0 bits until reach bit 1 and read the same amount of 0 bits after the 1 bit we found.

            The content of this field inside the headers of h264 can vary... one common value is called golomb, and it is calculated with this formula: (1 << leadingZeros) - 1 + readbits(leadingZeros).

            RBSP - Raw Byte Sequence Payload

            We cannot read the stream values directly, because it may contains the emulation prevention bytes. We need to remove the emulation prevention bytes before read the headers.

            The Code

            So to start mitigate the problem first I rewrite the H264 parser as follow:

            Source https://stackoverflow.com/questions/56894728

            QUESTION

            Can H.264 stream in MP4 file contain Annex B startcode emulation?
            Asked 2019-Mar-29 at 11:15

            MP4 file (actually it's HLS stream that uses MP4 format) contains H.264 stream in AVC format: [NALU length][NALU data]. H.264 decoder requires Annex B format: [startcode][NALU data]. In general startcode emulation can happen in AVC format (e.g. 0x00000001 can occur inside encoded data). Does this mean that MP4 file format also can contain H.264 NALUs with startcode emulation? Or should emulation prevention be applied before packaging into MP4?

            ...

            ANSWER

            Answered 2019-Mar-29 at 11:15

            Emulation prevention is always applied to remove 00 00 00-02 sequences from the encoded data (RBSP), so this is unrelated to Annex B: H.264 Annex B format is about start code prefixes prepending NAL units in byte-stream format as opposed to unit lengths.

            A cheat sheet on this:

            Emulation prevention is line 2 with 0x03 values, and Annex B is the bottom line on the image above.

            Source https://stackoverflow.com/questions/55400856

            QUESTION

            MediaMuxer writing H264 stream to mpg file
            Asked 2018-Dec-06 at 16:26

            MediaMuxer has been driving me mad for two days & nights now :-(

            The situation: I receive a H264 encoded 1280x720 video stream via UDP. The h264 stream contains NALU 1 - slice and NALU 5 - keyframe (5 is always preceded by NALU 7 - SPS and NALU 8 - PPS). This stream appears to be stable 30fps with at least one NALU 5 keyframe per second. Bitrate is variable but less than 4Mbps. MediaCodec sucessfully decodes the stream and renders it in a surface view so that part works well.

            But now I need to save the H.264 into a local mpg file. I set up a MediaMuxer with all MediaFormat information that I have, and feed it with the sample data from the stream. Each sample contains one frame (NALU 1 or 5), and the first data sent to MediaMuxer is a keyframe (NALU 5). The presentation time is calculated based on framenumber and framerate. All involved methods are called from the same thread.

            But the mpg file is never created. As you can see in the output below the data in the ByteBuffer does start with NALU headers followed by varying size of data. MediaMuxer seems to "see" frames in the data as it counts the frames. So what is wrong here?

            Minimum API is 21, and I have tested with a Samsung Galaxy S4 running stock Android 5 and a couple of devices running Lineageos Oreo and Nougat.

            Here is the code to setup the MediaMuxer:

            ...

            ANSWER

            Answered 2018-Dec-06 at 16:26

            @greeble31: You are right. The first log entry clearly states "Pictures" and not "Videos". I spent hours looking at this problem without noticing a simple cut&paste mistake in my preferences keys. How stupid is that!!?!

            Note to myself: Coding two days & nights in a row is not heroic but just plain stupid.

            Source https://stackoverflow.com/questions/53637969

            QUESTION

            formatting an AVC/H.264 mdat
            Asked 2018-Nov-29 at 05:34

            Can anyone tell me or point me to a section of the specification(s) that clearly demonstrates how from an elementary stream with a series of NALUs how these should be written into a ISO BMFF mdat?

            I can see looking at samples and other code that I should have something like: AUD, SPS, PPS, SEI, VideoSlice, AUD etc etc

            Things that are not entirely clear to me:

            1. If the SPS and PPS are also stored out of band in the AVCC are they required in the mdat?
            2. If they are required in the mdat when/where should they be written? e.g. just prior to an IDR?
            3. What is the requirement for AUDs?
            4. If I am generating sample sizes for the trun is the calcuation for this? In the example I am working to recreate the first sample in the trun has a size of 22817 however if I look at the first sample in the mdat the NALU size prefix is 22678. The value in the trun appears to be the size of all the NALUs + sizes up to and including the first sample (see my example below)

            >

            ...

            ANSWER

            Answered 2018-Nov-29 at 05:34

            If the SPS and PPS are also stored out of band in the AVCC are they required in the mdat?

            No

            If they are required in the mdat when/where should they be written? e.g. just prior to an IDR?

            Yes, if you choose to include them, but there is no reason to

            What is the requirement for AUDs?

            They are optional

            If I am generating sample sizes for the trun is the calcuation for this?

            The number of bytes in the access unit (AU, aka frame). Which may contain more than one NALU. SPS/PPS/SEI/AUD all counted toward the AU size. The 4 byte size prefixed to each NALUs is also counted in the AU size recored in the trun.

            Source https://stackoverflow.com/questions/53531003

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install NALU

            You can download it from GitHub.
            You can use NALU like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/kgrm/NALU.git

          • CLI

            gh repo clone kgrm/NALU

          • sshUrl

            git@github.com:kgrm/NALU.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link