Customize nal in h264 encoder library - h.264

I have to encode a video in h264,then transmit it over rtsp,but i have to add an additional nal unit of type unknown,then i have to decode that frames and get the nal unit of type unknown.Someone knows some library that can help me?Possibly in c,java or python

It seems very unclear what you mean with the "unknown" NAL type, but generally you should look at FFmpeg, it should suit your needs. It is a C library and i think there are 3rd party python bindings as well.

Related

Relations and differences between marshall/unmarshal, encoding/decoding, and serialization/deserialization for JSON?

In Go's JSON package, I saw there are marshal, decode and other functions.
I thought that decode is the opposite to marshal, but latter realized that I might be wrong.
I think the fundamental question that I have is:
What are the relations and differences between marshall/unmarshal, encoding/decoding, and serialization/deserialization for JSON?
Thanks.
See an example here Why are json package's Decode and Marshal methods used here?
I would personally say all those terms are synonyms though less so with encoding/decoding. In Go Marshal and Unmarshal happen to be the terms that are used to describe converting json in a string form to an object and vice versa. However in C# these same methods are called serialize and deserialize, as far as I know that terminology isn't in Go at all (at least not in any std lib).
Encoding can be used as an adjective to describe the format in which some data is stored, the most common use is probably character encoding (UTF-8). In Go it's also used as a noun to describe objects that can unmarshal/marshal json. Marshal/Unmarshal are always used as verbs, you take that action on the json.
Encoding is also used in Go to refer to a larger category of packages that deal with the conversion from one encoding to another.
If you told me you were marshalling, marshalling, deserializing or serializing some object or json I would understand exactly what you meant. If you said you were json encoding an object I would ask a clarifying question. If you said the "response is json encoded" I would get what you mean though I would think it's odd that you used those words rather than just saying "the response is json". Hope that is more or less the information you're looking for.
Oh also, just for more clarity
Unmarshal == deserialize == decode
Marshal == serialize == encode
In the encoding/json package, the Marshal function and the inverse Unmarshalfunction return and operate on single fixed bytes slices. They transform single objects to bytes, and vice versa.
There are also the Encoder and Decoder types. These contain the Encode and Decode methods, and they operate on streams of bytes, taking an io.Reader and io.Writer respectively. They also allow multiple objects to be serialized or deserialized with a newline delimiter using those streams.
The underlying mechanisms of Marshal/Unmarshal functions and the Encoder/Decoder types are identical, they both use the same internal encodeState.marshal and decodeState.unmarshal codepaths. The only real difference is they provide alternative access for various usage patterns.

How to calculate MF_MT_MPEG_SEQUENCE_HEADER for MPEG4 Sink in Win7?

I have a MF topology that captures video and audio and encodes it into H264, then writes it to an MPEG4 sink. However, the problem is that my H264 encoder (Intel QuickSync H264 Encoder) does not define a value for MF_MT_MPEG_SEQUENCE_HEADER in its output types. Thus, when I set the video media type of my MPEG4 sink, no sequence header is defined and the sink cannot correctly finalize, as mentioned in the MPEG4 Sink documentation:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd757763(v=vs.85).aspx
After searching around, I learned that I need to get the SPS & PPS values for the MF_MT_MPEG_SEQUENCE_HEADER attribute. I am not sure about how to get these. My application is designed only for Windows 7, but in Windows 8 it seems like you can just set the MF_MPEG4SINK_SPSPPS_PASSTHROUGH attribute to have the sink grab the SPS & PPS from the input samples (see the above link). I have no interest in individual frame samples other than to obtain this value, and currently my application code is not looking at individual H264 samples.
What is an easy way to obtain the SPS & PPS values from a MF H264 stream on Windows 7?
I could explain exactly how to do it. But I believe the how will be confusing if you don't understand the why. I have another post that explains these concepts in pretty good detail, and writing the code to accomplish this should be trivial after understanding the bitstream format.
You should pay specific attention to the AVCC section
Possible Locations for Sequence/Picture Parameter Set(s) for H.264 Stream

Does OpenHevc also provide encoder module to encode a yuv stream

I am working on existing available opensource HEVC encoders, Right now i got reference HEVC encoder from Fraunhofergroup and also a optimized X265 encoder of multicoreware. However i also found OpenHEVC module my question is that in their readme file they only demonstrate decoding of a HEVC stream. Does OpenHEVC has encoder module which can encode a yuv input file in to h265 stream.
Thanks alot in advance
If you have mean this OpenHEVC than no it doesn't have its own HEVC encoder. And it was said about this in first paragraph of README.md:
openHEVC is a fork of Libav with only the files needed to decode HEVC
content, it was created for research purposes. Most people will not
need to use this and should use the libav HEVC decoder available at
https://github.com/OpenHEVC/libav instead (see
https://libav.org/documentation.html for documentation).
No, OpenHEVC does not have Video encoding.
You can use x265 / FFMPEG, if you want to encode videos in HEVC.
(x265 is GPL licensed)

When decoding H264 packages which of the sprop-parameter-sets has higher priority?

I am decoding a streaming video. It is sent as RTP packages.
Before sending the video the receiver gets an SDP file that, among other things, has the sprop parameter sets.
However, the decoding works even if i remove that parameter. That's why I'm presuming the sprop parameter sets are also present in the H264 packages (in the RTP payload).
So, we can have sprop parameter sets on two places, which is considered the prioritized one?
There is no priority. The sprop contains an SPS/PPS. Each SPS/PPS has an id, when needed the NALS in the stream just indicate the specific SPS/PPS it needs. It is also legal for an h.264 encoder to just repeat the same SPS/PPS in the stream for protocols that do not have a method of transmitting out of band data, and require the ability to just a stream in progress (Like over the air TV)

How to generate automatically asn.1 encoded packets?

I want to test my application and I need to generate different load. Application is SUPL RRLP protocol parser, I have ASN.1 specification for this protocol. Packets have a lot of optional fields and number of varians may be over billion - I can't go through all the options manually. I want to automate it.
The first way to generate packets automatically, the other way is to create a lot different value assignments sets and encode each into binary format.
I found some tools, for example libtasn and Asn1Editor, but the first one can't parse existing ASN.1 spec file; the second one can't encode packets by specification.
I'm afraid to create thousandth ASN.1 parser because I can introduce errors in test process.
I hoped it's easy to find something existing, but... I'm capitulating.
Maybe, someone faced with the same problem on stackowerflow and found the solution? Or know something to recommend. I'll thank you.
Please try going to https://asn1.io/asn1playground/ and try your specification there. You can ask it to generate a sample value for a given ASN.1 type. You can encode it and edit either the encoded (hex) data, or decoded values to create additional values.
You can also download a free trial of the OSS ASN.1 Tools from http://www.oss.com/asn1/products/asn1-download.html which includes OSS ASN.1 Studio. This also allows you to generate (and modify) sample values for a given ASN.1 type.
Note that these don't generate thousands of different test values for you automatically, but will parse valid value notation and encode the values for you if you are able to generate valid ASN.1 value notation.