ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:18.18KB ,
资源ID:22025087      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22025087.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(decodingencoding文档格式.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

decodingencoding文档格式.docx

1、Audio encodingn); /* find the MP2 encoder 编码器?*/codec = avcodec_find_encoder(CODEC_ID_MP2);/返回0时表明打到了,这个API返回avcodec if (!codec) fprintf(stderr, codec not foundn exit(1); c = avcodec_alloc_context3(codec);/储存上下文环境/*设置参数,都是AVCodecContext的成员变量 put sample parameters */ c-bit_rate = 64000;sample_rate =

2、44100;channels = 2;sample_fmt = AV_SAMPLE_FMT_S16; /* open it 打开流文件*/ if (avcodec_open(c, codec) frame_size; samples = malloc(frame_size * 2 * c-channels); outbuf_size = 10000; outbuf = malloc(outbuf_size);/这些都是自己设置的么? f = fopen(filename, wb/文件f) could not open %sn, filename); /* encode a single ton

3、e sound 编码单色声音?核心代码吧*/ t = 0;/浮点数? tincr = 2 * M_PI * 440.0 / c-sample_rate; for(i=0;i200;i+) for(j=0;j int got_frame = 0;decoded_frame) (decoded_frame = avcodec_alloc_frame() out of memoryn else avcodec_get_frame_defaults(decoded_frame); len = avcodec_decode_audio4(c, decoded_frame, &got_frame, & i

4、f (len channels, decoded_frame-nb_samples,sample_fmt, 1); fwrite(decoded_frame-data0, 1, data_size, outfile); avpkt.size -= len; avpkt.data += len; avpkt.dts = avpkt.pts = AV_NOPTS_VALUE; if (avpkt.size 0) avpkt.size += len; fclose(outfile); av_free(decoded_frame);/* * Video encoding example视频编码*/st

5、atic void video_encode_example(const char *filename, int codec_id) int i, out_size, size, x, y, outbuf_size; AVFrame *picture;Video encodingn /* find the mpeg1 video encoder */ codec = avcodec_find_encoder(codec_id); picture= avcodec_alloc_frame(); /* put sample parameters */bit_rate = 400000; /* re

6、solution must be a multiple of two */width = 352;height = 288; /* frames per second */time_base= (AVRational)1,25;gop_size = 10; /* emit one intra frame every ten frames */max_b_frames=1;pix_fmt = PIX_FMT_YUV420P; if(codec_id = CODEC_ID_H264) av_opt_set(c-priv_data, preset, slow, 0); /* alloc image

7、and output buffer */ outbuf_size = 100000; /* the image can be allocated by any means and av_image_alloc() is * just the most convenient way if av_malloc() is to be used */ av_image_alloc(picture-data, picture-linesize,width, c-height, c-pix_fmt, 1); /* encode 1 second of video */25; fflush(stdout);

8、 /* prepare a dummy image */ /* Y */ for(y=0;yheight;y+) for(x=0;xdata0y * picture-linesize0 + x = x + y + i * 3; /* Cb and Cr */height/2;width/2;data1y * picture-linesize1 + x = 128 + y + i * 2;data2y * picture-linesize2 + x = 64 + x + i * 5; /* encode the image */ out_size = avcodec_encode_video(c

9、, outbuf, outbuf_size, picture);encoding frame %3d (size=%5d)n, i, out_size); /* get the delayed frames */ for(; out_size; i+) out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);write frame %3d (size=%5d)n /* add sequence end code to have a real mpeg file */ outbuf0 = 0x00; outbuf1 = 0x00

10、; outbuf2 = 0x01; outbuf3 = 0xb7; fwrite(outbuf, 1, 4, f); av_free(picture-data0); av_free(picture);n/* * Video decoding example */static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename) int i; f=fopen(filename,w fprintf(f,P5n%d %dn%dn,xsize,ysize,255);ysize;i+) fwri

11、te(buf + i * wrap,1,xsize,f);static void video_decode_example(const char *outfilename, const char *filename) int frame, got_picture, len; uint8_t inbufINBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE; char buf1024; /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams

12、) */ memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);Video decodingn /* find the mpeg1 video decoder */ codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO); if(codec-capabilities&CODEC_CAP_TRUNCATED)flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ /* For some codecs, such

13、 as msmpeg4 and mpeg4, width and height MUST be initialized there because this information is not available in the bitstream. */ /* the codec gives us the frame size, in samples */ frame = 0;) avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); if (avpkt.size = 0) break; /* NOTE1: some codecs are stream ba

14、sed (mpegvideo, mpegaudio) and this is the only method to use them because you cannot know the compressed data size before analysing it. BUT some other codecs (msmpeg4, mpeg4) are inherently frame based, so you must call them with all the data for one frame exactly. You must also initialize width an

15、d height before initializing them. */ /* NOTE2: some codecs allow the raw parameters (frame size, sample rate) to be changed at any frame. We handle this, so you should also take care of it */ /* here, we use a stream based decoder (mpeg1video), so we feed decoder and see if it could decode a frame

16、*/ len = avcodec_decode_video2(c, picture, &got_picture, &Error while decoding frame %dn, frame); if (got_picture) saving frame %3dn /* the picture is allocated by the decoder. no need to free it */ snprintf(buf, sizeof(buf), outfilename, frame); pgm_save(picture-data0, picture-linesize0,height, buf); frame+; /* some codecs, such as MPEG, transmit the I and P frame with a latency of one frame. You must do the following to have a chance to get the last frame of the vi

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1