인터넷에는 많은 자료가 있다.
color bar 영상도 많고 분석하는 프로그램도 많고...
난 단순히 내가 원하는 자료만 필요할 뿐인데 딱히 쓸만한 것이 없어 항상 만들게 된다. (물론 좋은 분들의 도움을 받아서 ^^)
이번에는 소스 코드에 넣을 H.264 1 frame 짜리 데이터가 필요해서 만들었다.
필요한 분들도 쓰세요.

위의 이미지를 ffmpeg을 사용하여 h264 영상로 변환한다.
$ ffmpeg -i smpte169.jpg -vcodec h264 smpte169.h264
재생도 잘 된다.

이 이미지를 소스코드에 넣기 위해서는 Hex 값으로 변환이 필요하다.
직접 프로그램을 만들어 변환해도 되겠지만, 좋은 분의 도움을 받자.
http://tomeko.net/online_tools/file_to_hex.php?lang=en
File to hex converter
File to hexadecimal converter Client-side (javascript, no data is sent to server) file to hexadecimal code conversion. Be careful with files > 1 MB (possible high resource consumption, e.g. Chromium 46 has serious problems when loading few MB of text into
tomeko.net

여기서 좀 더 작업하자.
RTP로 전송해야 하니 Data를 분리하자.
H.264 Stream을 분석하는 여러 프로그램이 있는데, 사실상 좋은 것은 유료이고
Open Source도 여러 개 있지만, 입맛에 맞는 것을 찾기는 쉽지 않다.
일단, 다음 사이트에서 간단히 처리하자.
https://mradionov.github.io/h264-bitstream-viewer/
h264-bitstream-viewer
mradionov.github.io

$ dd skip=4 count=26 if=smpte169.h264 of=h264_sps.dat bs=1
$ dd skip=34 count=5 if=smpte169.h264 of=h264_pps.dat bs=1
$ dd skip=42 count=686 if=smpte169.h264 of=h264_sei.dat bs=1
$ dd skip=731 count=610 if=smpte169.h264 of=h264_idr_pic.dat bs=1
$ hexdump -n 32 h264_sps.dat
0000000 f467 1e00 9b91 1528 3f06 d93c 0000 0003
0000010 0001 0300 3200 160f 962d
000001a
참고로 hexdump의 결과처럼 4 Byte start pattern (00 00 00 01)은 제거했다. 어차피 RTP 전송할 때 빼야 하니.

'놀기 > 잡스러운 것' 카테고리의 다른 글
| 제안요청서 (RFP, request for proposal) (0) | 2021.07.12 |
|---|---|
| 나누어진 문자열 순서 뒤집어 붙이기 (0) | 2021.06.25 |
| Color bars/Display 관련 소스 코드 (0) | 2021.06.25 |
| random 값 만들기 (0) | 2021.06.24 |
| sockaddr_in에 들어 있는 IP 주소 출력 (0) | 2021.06.24 |
댓글