https://github.com/ireader/avcodec
av encoder/decoder/render/player
https://github.com/ireader/avcodec
Last synced: over 1 year ago
JSON representation
av encoder/decoder/render/player
- Host: GitHub
- URL: https://github.com/ireader/avcodec
- Owner: ireader
- License: mit
- Created: 2016-08-19T02:40:48.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T01:31:20.000Z (over 1 year ago)
- Last Synced: 2025-04-12T19:47:46.293Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 19.4 MB
- Stars: 184
- Watchers: 20
- Forks: 94
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# avcodec
1. H.264 bit stream parse
2. H.264 encode by X264
3. H.264 encode by OpenH264
4. FFMPEG video encode/decode
h264_parameter_t param;
param.profile = H264_PROFILE_BASELINE;
param.level = H264_LEVEL_2_0;
param.width = 352;
param.height = 288;
param.format = PICTURE_YUV420;
param.frame_rate = 25000;
param.gop_size = 50;
param.bitrate = 500000;
void* h264 = x264enc_create(& param);
//void* h264 = openh264enc_create(& param);
picture_t pic;
memset(&pic, 0, sizeof(pic));
pic.format = PICTURE_YUV420;
pic.width = 352;
pic.height = 288;
pic.pts = i * 40;
pic.dts = i * 40;
pic.flags = 0; // AVPACKET_FLAG_KEY force IDR frame
pic.data[0] = s_yuv;
pic.linesize[0] = pic.width;
pic.data[1] = pic.data[0] + pic.linesize[0] * pic.height;
pic.linesize[1] = pic.width / 2;
pic.data[2] = pic.data[1] + pic.linesize[1] * pic.height / 2;
pic.linesize[2] = pic.width / 2;
assert(x264enc_input(h264, &pic) > 0);
//assert(openh264enc_input(h264, &pic) > 0);
avpacket_t pkt;
memset(&pkt, 0, sizeof(pkt));
assert(x264enc_getpacket(h264, &pkt) > 0);
//assert(1 == openh264enc_getpacket(h264, &pkt));
// save data
assert(pkt.bytes == fwrite(pkt.data, 1, pkt.bytes, wfp));