Test 1 : NvEncoder로 인코딩 된 mp4 영상을 ts로 demux/mux후, 다시 mp4로 demux/mux 하였을 떄, 정상 동작함을 확인 (mp4 -> ts -> mp4)
Test 2 : NvEncoder로 인코딩 시, All-I 형태로 인코딩하여 테스트 (모든 프레임을 Intra Frame으로 인코딩)
Test 3 : 앞서, NvEncoder로 인코딩 된 mp4 영상과 2차례의 demux/mux 과정을 거친 mp4 영상(mp4 -> ts -> mp4)을 비교 (이하 defect영상, normal영상으로 표현 변경)
Test 4 : mp4 container atom
Nal unit에서 제공하는 key frame정보 외에도, mp4 container내 atom 목록에 stss(Sync sample atom)라는 데이터가 존재하며, 해당 데이터는 Payload의 Intra Frame에 대한 정보를 제공하기 위해 존재함을 확인
mp4 atom 확인을 위한 python source (출처 : gpt 4.0)
```python
#!/usr/bin/env python3
#coding : utf-8
import struct
def read_box(f):
size, = struct.unpack(">I", f.read(4))
type = f.read(4).decode("utf-8")
return size, type
def parse_boxes(f, indent=0, parent_type=None):
while True:
try:
start_pos = f.tell()
size, type = read_box(f)
f.seek(start_pos + size)
indent_str = " " * indent
print(f"{indent_str}{type} (Size: {size})")
if type in ['moov', 'trak', 'mdia', 'minf', 'stbl']:
f.seek(start_pos + 8) # Move to the start of child boxes
parse_boxes(f, indent + 1, type)
f.seek(start_pos + size) # Move to the next box's start position
except struct.error:
break
def main(filename):
with open(filename, 'rb') as f:
parse_boxes(f)
if __name__ == "__main__":
# main("defect_test/test_defect.mp4")
main("defect_test/test_normal.mp4")
```
실행 결과 예시
```cpp
...
// Constraint GOP 사용시에만 가능
if (m_nFrameNumber % m_nGop == 0)
packet->flags |= AV_PKT_FLAG_KEY;
else
packet->flags &= ~AV_PKT_FLAG_KEY;
...
```