html5 video tag codecs attribute - html
I am trying to specify a specific video/audio codec in the video tag using
<video poster="movie.jpg" controls>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'/>
<p>This is fallback content</p>
</video>
but can't find the right codecs statement to play the video , i have downloaded a video analyser and can see that its an avc1 and can see that the audio map.40.2 but can work out the rest of the codec, what does the 4d401e mean in the above ?
Cheers
Toby
The codecs parameter is specified by RFC 6381. Specifically, see section 3.3 for the meaning of avc1 and mp4a values.
In the case of avc1.4D401E, avc1 indicates H.264 video, and this is followed by a dot and three 2-digit hexadecimal numbers defined by the H.264 standard:
profile_idc
the byte containing the constraint_set flags (currently constraint_set0_flag through constraint_set5_flag, and the reserved_zero_2bits)
level_idc
Some examples:
avc1.42E01E: H.264 Constrained Baseline Profile Level 3
avc1.4D401E: H.264 Main Profile Level 3
avc1.64001E: H.264 High Profile Level 3
These are also the second, third, and fourth bytes of the Sequence Parameter Set and the AVC Configuration Box in an MP4 file. You can dump these bytes using a program such as mp4file: mp4file --dump movie.mp4. Look for the avcC (AVC Configuration) Box and the hexadecimal values for AVCProfileIndication, profile_compatibility, and AVCLevelIndication.
As for mp4a.40.2, mp4a indicates MPEG-4 audio. It is followed by a dot and a hexadecimal ObjectTypeIndication (objectTypeId in mp4file output), which can be looked up on the MPEG4 registration site. If this hexadecimal value is 40 (ISO/IEC 14496-3 Audio), it is followed by another dot and an audio object type in decimal. These are listed in the ISO/IEC 14496-3 standard and on Wikipedia, and correspond to the first 5 bits of the DecoderSpecificInfo (decSpecificInfo) (unless these bits equal 31, in which case add 32 to the next 6 bits). mp4a.40.2 indicates AAC LC audio, which is what is usually used with H.264 HTML5 video.
For example, codecs="avc1.42E01E, mp4a.40.2" would be correct for the movie below:
$ mp4file --dump movie.mp4
...
type avcC (moov.trak.mdia.minf.stbl.stsd.avc1.avcC) ◀━━ avc1
configurationVersion = 1 (0x01)
AVCProfileIndication = 66 (0x42) ◀━━ 42
profile_compatibility = 224 (0xe0) ◀━━ E0
AVCLevelIndication = 30 (0x1e) ◀━━ 1E
...
type esds (moov.trak.mdia.minf.stbl.stsd.mp4a.esds) ◀━━ mp4a
version = 0 (0x00)
flags = 0 (0x000000)
ESID = 2 (0x0002)
streamDependenceFlag = 0 (0x0) <1 bits>
URLFlag = 0 (0x0) <1 bits>
OCRstreamFlag = 0 (0x0) <1 bits>
streamPriority = 0 (0x00) <5 bits>
decConfigDescr
objectTypeId = 64 (0x40) ◀━━ 40
streamType = 5 (0x05) <6 bits>
upStream = 0 (0x0) <1 bits>
reserved = 1 (0x1) <1 bits>
bufferSizeDB = 0 (0x000000) <24 bits>
maxBitrate = 78267 (0x000131bb)
avgBitrate = 78267 (0x000131bb)
decSpecificInfo
info = <2 bytes> 11 90 |..| ◀━━ 2 (first 5 bits in decimal)
...
You can use MP4Box tool to find out codec strings in RFC6381 format. Still you have to join them with commas.
You can use this command:
MP4Box -info big.mp4 2>&1 | grep RFC6381 | awk '{print $4}' | paste -sd , -
mark4o gives by far the best explanation I've seen of how to decipher codec information. Excellent.
One piece which may require a little more detail is how to break out the specific audio object type from the decSpecificInfo value. Finding the "mp4a.40" part is very clear, the ".2" section can be a little tricky.
We start with a sequence of single byte hexadecimal values: "11 90" in mark4o’s example or "12 08" in my case. Both of those are a total of 2 bytes... there may be more values but only the first 2 matter for finding the object type (and usually only the first byte). We're looking for individual bits so convert each digit in the hexadecimal values to binary; there should be 4 binary digits for each hexadecimal digit. Take the first 5 binary digits — 4 from the first hex digit, 1 from the next — and convert that binary value to decimal. Here are the steps:
Example 1 (11 90):
Starting value: 11 90
Separate the hex digits: 1 1 9 0
Convert each digit to binary: 0001 0001 1001 0000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
Example 2 (12 08):
Starting value: 12 08
Separate the hex digits: 1 2 0 8
Convert each digit to binary: 0001 0010 0000 1000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
They are the same object type in spite of having different decSpecificInfo values.
You could also simply do this to find the right codec infor:
go to the folder containing your video file, lets assume the file is called movie.mp4,
The run the command:
vlc movie.mp4
assuming you have vlc installed, if the video plays vlc will have the correct codec information,
Click on the tools menu above, a drop down list will be displayed with an option to view the codec information as below.
Related
Displaying raw pixel array on a web page using image tag
I am trying to figure out the best way to put a raw pixel array into an image tag. The pixels are served from a server that does not have a png or jpg compression library so the raw array comes in via an HTTP request. I can control the return headers so I put a mime type in the response. I'd like to do: <img src="http://myserver.com/id/" /> But I don't think I can do that. I could use the src="data:XXXXXX;base64,http://myserver.com/id/" if that works, but I need to know what to do with XXXX. Another idea I've had is using svg if I can set an image equal to SVG. Not sure if i'd have to wrap each pixel in an element. Maybe there is a way to do this with CSS? I can write the data to canvas element with js pretty easily, but I was hoping to have a non-js way. I can do some minor manipulation of the binary structure of the data coming out of the server, so if there is an easy way to tell the jpg or png format that this is uncompressed data, I could do that...I just don't have the horsepower or the time to translate to the png or jpg libraries to the (blockchain) based language I'm having to use.
Relevant links: the zlib RFC, the DEFLATE RFC, and the PNG spec. You may wish to consult these while reading. Let's make a PNG! Start with the image data as an RGBA image, for example for a 2x2 image: 12 34 56 78 9a bc de f0 cd ef 01 23 45 67 89 ab Specify filters For each row of the image, add a null byte to the beginning to set the PNG filter to none. For example, 00 12 34 56 78 9a bc de f0 # row 1 of image 00 cd ef 01 23 45 67 89 ab # row 2 of image DEFLATE encode it While this is a compression format, we don't actually need to compress it! DEFLATE provides a way to encode data without compressing it (see section 3.2.4 of the DEFLATE spec). Find the length of the filtered image data from above as a 16-bit integer (if it is bigger than 65535, then split the image data into 65535-sized chunks, and do this step for each chunk). Create an empty array to hold the DEFLATE data stream. Insert that size as a 16-bit integer in big-endian format into the currently empty DEFLATE data stream. Next, append the bitwise inverse of the length. Finally, insert the filtered image data into the data stream. Wrap it in zlib Next, we need to zlib-encode the data. Start with an empty zlib data stream, and insert 2 null bytes for the header. Next, insert the DEFLATEd data from above. Finally, insert the Adler32 checksum of the uncompressed data. Specifically, the Adler32 checksum should be created from the filtered image data. Wrap it in a PNG format Finally, let's wrap this into a PNG. Replace the width and height values, specify the length of the IDAT chunk as the length of the zlib-encoded data, and replace the CRCs of the IDHR and IDAT chunks by taking the CRC32 checksum of the the chunk name concatenated with the data. # PNG signature 137 80 78 71 13 10 26 10 # IDHR chunk 00 00 00 0d # IDHR length 73 72 68 82 # IDHR type 00 00 00 02 # width: COMPUTE THIS 00 00 00 02 # height: COMPUTE THIS 08 # bit depth: 8 06 # colour type: truecolour with alpha 00 # compression method: zlib 00 # filter method: normal 00 # no interlacing 55 55 55 55 # CRC: COMPUTE THIS from "IDHR" + data # IDAT chunk 55 55 55 55 # IDAT length: COMPUTE THIS 73 68 65 84 # IDAT type [zlib data] 55 55 55 55 # CRC: COMPUTE THIS from the "IDAT" + data # IEND chunk 00 00 00 00 # IEND length 73 69 78 68 # IEND type AE 42 60 82 # CRC (always the same value, doesn't need to be computed)
Austin, I see from your previous comment that the pixel data you are receiving comes in RGBA format with four bytes per pixel (e.g. R, G, B, A). ** If you can provide a sample of the data returned, I can refactor my example to use the RGBA values returned directly. It should actually be easier, as I believe I can plug them directly into the rgba(r, g, b, a) CSS function without having to convert them to hex. I use this exact same process in my console.draw() tool, and it works flawlessly for me, converting raw pixel data into valid <img> tags on demand. If you receive the pixels as an array of colors, you will either have to supply the function you use with the number of pixels per row so it knows where to wrap to the next lines, or more appropriately, use an array of nested arrays, one nested array per row of pixels. Then, draw the array of nested pixel colors to a canvas, row by row, pixel by pixel. Finally, use the HTMLCanvasElement.toDataURL() method to convert the canvas image to a Base64 encoded string which you can assign to the src attribute value of the img tag. If you would like to display the final image pixelated, without any anti-aliasing, make sure to apply the CSS rule image-rendering: pixelated. Here is all of this, put into action: const pixels2Base64 = pixelColors => { const canvas = document.createElement('canvas'); canvas.width = pixelColors[0].length; canvas.height = pixelColors.length; const context = canvas.getContext('2d'); for (let i = 0; i < pixelColors.length; i++) { for (let j = 0; j < pixelColors[i].length; j++) { context.fillStyle = pixelColors[i][j]; context.fillRect(j, i, 1, 1); } } const dataURL = canvas.toDataURL('image/png', 1); canvas.remove(); return dataURL; }; const nyanCat = [["#00000000","#00000000","#00000000","#ff1111ff","#ff1111ff","#ff1111ff","#00000000","#00000000","#00000000","#00000000","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000"],["#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#000000ff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000"],["#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#ff1111ff","#000000ff","#ffd29bff","#ffd29bff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#ffd29bff","#ffd29bff","#ffd29bff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000"],["#ff1111ff","#ff1111ff","#ff1111ff","#fea70aff","#fea70aff","#fea70aff","#ff1111ff","#ff1111ff","#000000ff","#ffd29bff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#ffd29bff","#ffd29bff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000"],["#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#ffd29bff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000"],["#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#fea70aff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#000000ff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#ffd29bff","#000000ff","#00000000","#00000000","#000000ff","#000000ff","#00000000","#00000000"],["#fea70aff","#fea70aff","#fea70aff","#fefe06ff","#fefe06ff","#fefe06ff","#fea70aff","#fea70aff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#fea4feff","#fea4feff","#fea4feff","#ffd29bff","#000000ff","#00000000","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000"],["#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#fea4feff","#fea4feff","#ffd29bff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000"],["#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#fefe06ff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#000000ff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000"],["#fefe06ff","#fefe06ff","#fefe06ff","#48fe0bff","#48fe0bff","#48fe0bff","#fefe06ff","#fefe06ff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000"],["#48fe0bff","#48fe0bff","#48fe0bff","#48fe0bff","#48fe0bff","#48fe0bff","#48fe0bff","#000000ff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff"],["#48fe0bff","#48fe0bff","#48fe0bff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#ffd29bff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#fefefeff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#fefefeff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff"],["#48fe0bff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#a9a7aaff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff"],["#0eadfeff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#000000ff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#fea4a6ff","#fea4a6ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#fea4a6ff","#fea4a6ff","#000000ff"],["#0eadfeff","#0eadfeff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#0eadfeff","#000000ff","#ffd29bff","#fea4feff","#fea4feff","#eb4ab4ff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#fea4a6ff","#fea4a6ff","#a9a7aaff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#a9a7aaff","#fea4a6ff","#fea4a6ff","#000000ff"],["#0eadfeff","#0eadfeff","#0eadfeff","#7543feff","#7543feff","#7543feff","#0eadfeff","#0eadfeff","#000000ff","#ffd29bff","#ffd29bff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#fea4feff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000"],["#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#000000ff","#000000ff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#ffd29bff","#000000ff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000","#00000000"],["#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#7543feff","#000000ff","#a9a7aaff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#00000000"],["#7543feff","#7543feff","#7543feff","#00000000","#00000000","#00000000","#7543feff","#7543feff","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000","#000000ff","#a9a7aaff","#a9a7aaff","#000000ff","#00000000","#00000000","#00000000"],["#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#00000000","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#00000000","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#000000ff","#000000ff","#000000ff","#00000000","#00000000","#00000000"]]; const img = document.querySelector('img'); img.src = pixels2Base64(nyanCat); img { width: 250px; height: auto; image-rendering: pixelated; } <img>
How to get OBD2 Fuel Level reading from Wagon R 2010 model
I want to measure current fuel level inside my car's fuel tank using OBD2 bluetooth/USB adapter. When i try to query that PID i got following data as "NO DATA" while at the same time i can check other PIDS like RPM and all data comes fine. I have small python program which reads its but i am unable to get it. import serial #ser = serial.Serial('COM12',38400,timeout=1) #ser.write("01 2F \r") #speed_hex = ser.readline().split(' ') #print speed_hex #convert hex to decprint ("SpeedHex",speed_hex) #speed = float(int('0x'+speed_hex[3],0)) #print ('Speed',speed,'Km/h') ser1 = serial.Serial("COM12",38400,timeout=1) #ser1.write("ATZ \r") #ser1.write("ATE0 \r") #ser1.write("ATL0 \r") #ser1.write("ATH1 \r") #ser1.write("ATSP 5 \r") ser1.write("01 0C \r") fuel_hex= ser1.readline() print fuel_hex #convert to hex to decprint ("FuelHex",fuel_hex) #fuel = float(int('0x'+fuel_hex[3],0)) #print ("Fuel in Per",fuel) Can any one suggest here how to get fuel level which is their inside in car at this current time. As i can see in my panel with bar sign.
In order to get all the available PIDs in a vehicle, you have to request the following PIDs at first exactly like you ask the rpm of the vehicle: 0x00, 0x20, 0x40, ....0x80 and so on. For instance when you request PID 0x00 the ECU will return you 4 bytes which means if it supports PIDs from 0x01 - 0x20. Each byte has 8 bits in total of 32 bits which is exactly from PID 0x01 to PID 0x20. Now it is time to parse the data. If each bit is 1 it means the ECU will support and 0 no support. It is your duty to do some bitwise operations to translate these bits: Also you can look out this Wikipedia link which shows in graphics! byte 1 bit 1 : availability of PID 0x01 byte 1 bit 2 : availability of PID 0x02 byte 1 bit 3 : availability of PID ox03 .... byte 4 bit 7 : availability of PID 0x1F byte 4 bit 8 : availability of PID 0x20 --> Here the ECU tells you if support any PIDs in next 32 PIDs. If it is 0, you do not need to check anymore! After parsing and gathering all the supported PIDs, then you can have a roadmap to calculate or check each PIDs you want. Do not forget many of conversion rates a formulas in wikipedia is wrong due to the complexity of calculations. You have to read the ISO 15031 part 5 and do NOT forget ECU only gives you the emissions-related diagnostics and not all the data.
Convert a 16 Bit Binary Value to Octal
Hello I would like to know of a quick and easy way to perform a number conversion of this binary value: 1000100000001011 to octal. In hex I can convert fairly quickly by hand to 0xAA0B. To come up with the decimal value of this binary takes a bit more work but eventually you can arrive at 32,768 + 2,048 + 11 = 34,827. I know the octal pattern works like 8 = 10, 9 = 11 .... 16 = 20, 17 = 21 ... 24 = 30, etc. However I am having trouble converting to octal without a large amount of effort. Could anybody clear this up for me and perhaps provide a short-hand method that can help convert binary to octal. Programming examples are nice but I'm really looking for an explanation. Thanks
The quickest method is to break the binary number into 3-bit chunks from the right end, pad with 0's from the left as needed, then convert each chunk to an octal digit. For example, 1000100000001011 -> 001 000 100 000 001 011 [2 0's added to the left] -> 1 0 4 0 1 3 -> 104013
SPS and PPS (aka dwSequenceHeader) in Media Foundation's H264 encoder
I'm using the H264 encoder from Media Foundation (MFT). I extracted the SPS and PPS from it, because I need it for smooth streaming. The MSDN says that the number of bytes used for the length field that appears before each NALU can be 1, 2, or 4. This is all in network byte order. As you can see, the first 4 bytes in the buffer are 0, 0, 0, 1. If we apply any of the possible lengths, we will get nothing. If the number of bytes used for length is 1, then the length is zero, if it is 2, the length is zero again. If it is 4, the length of first NALU is 1?! And, that's not correct. Does anybody know how should I interpret this SPS and PPS concatenated together??
The answer here is simple: the data is valid and formatted according to Annex B, prefixed by start codes 00 00 00 01 and not run length encoding. H.264 extradata (partially) explained - for dummies Annex B format in this format, each NAL is preceeded by a four byte start code: 0x00 0x00 0x00 0x01 thus in order to know where a NAL start and where it stops, you would need to read each byte of the bitstream, looking for these start codes, which can be a pain if you need to convert between this format and the other format. More details on H.264 spec - freely available for download. Page 326 starts with "Annex B - Byte stream format".
Create MDAT from I-frame/P-frame fragments
I am creating an MPEG-4 file from H.264 stream. H.264 stream comes in NAL format (EG: 0,0,0,1,67,...,0,0,1,68,...). Each video frame is transmitted as multiple I-frame/P-frame fragments. For eg: Frame 1 contains approximately 80 I-frame fragments and Frame 2 contains around 10 P-frame fragments. I understand that MDAT atom of the MPEG-4 file is supposed to contain H.264 streams in NAL format. I would like to know how these fragments can be converted to a single I-frame before I can put it into MDAT atom of MPEG-4. I do not want to use any libraries. Thanks for your help.
You are going to convert H.264 Annex B NAL stream into MP4 file packets. In order to do that you need to: Split your original file into NAL units ( 00 00 00 01 yy xx xx ... ); Locate frame boundaries: each H.264 frame typically contains a number of slices and optionally one of these: SPS, PPS, SEI. You'll need to parse the 'yy' octet above to determine what kind of NAL unit you are looking at. Now, in order to know the boundary of a frame you will need to parse the first part of each slice called 'SliceHeader' and compare 'frame_number' of consequitive slices. As soon as you know the frame boundaries you can form MP4 packets. Each packet will contain exactly one frame and and NAL units in this format: l1 l1 l1 l1 yy xx xx ... l2 l2 l2 l2 yy xx xx ... so basically your replace each delimeter '00 00 00 01' with integer holding the length of this NAL unit. Then in order to obtain correct MP4 header you'll need to use MP4 muxer and populate correct 'AvcC' atom inside of a sample entry of your video track. This is a rather tedious process but if you want to get into specifics you can study the source code of JCodec ( http://jcodec.org ): org.jcodec.samples.transcode.TranscodeMain , org.jcodec.containers.mp4.MP4Muxer