diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-08-15 17:41:01 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-08-15 17:55:24 +0400 |
commit | 9e89bc37edfcd1b4b0a22c096c6546df4a9d1c0b (patch) | |
tree | de31fc8aa5b32d28a0143aff2477b4c3ada40318 /doc | |
parent | aee7b88cc0675fb668e39e8f4a50f2b1bd9305d4 (diff) | |
parent | 635ac8e1be91e941908f85642e4bbb609e48193f (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
rtmp: Add support for SWFVerification
api-example: use new video encoding API.
x86: avcodec: Appropriately name files containing only init functions
mpegvideo_mmx_template: drop some commented-out cruft
libavresample: add mix level normalization option
w32pthreads: Add missing #includes to make header compile standalone
rtmp: Gracefully ignore _checkbw errors by tracking them
rtmp: Do not send _checkbw calls as notifications
prores: interlaced ProRes encoding
Conflicts:
doc/examples/decoding_encoding.c
libavcodec/proresenc_kostya.c
libavcodec/w32pthreads.h
libavcodec/x86/Makefile
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/decoding_encoding.c | 71 | ||||
-rw-r--r-- | doc/protocols.texi | 6 |
2 files changed, 51 insertions, 26 deletions
diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c index 6295001f07..919ee489b6 100644 --- a/doc/examples/decoding_encoding.c +++ b/doc/examples/decoding_encoding.c @@ -31,10 +31,10 @@ #include <math.h> -#include <libavutil/imgutils.h> #include <libavutil/opt.h> #include <libavcodec/avcodec.h> #include <libavutil/audioconvert.h> +#include <libavutil/imgutils.h> #include <libavutil/mathematics.h> #include <libavutil/samplefmt.h> @@ -315,11 +315,11 @@ static void video_encode_example(const char *filename, int codec_id) { AVCodec *codec; AVCodecContext *c= NULL; - int i, out_size, x, y, outbuf_size; + int i, ret, x, y, got_output; FILE *f; AVFrame *picture; - uint8_t *outbuf; - int had_output=0; + AVPacket pkt; + uint8_t endcode[] = { 0, 0, 1, 0xb7 }; printf("Encode video file %s\n", filename); @@ -359,17 +359,25 @@ static void video_encode_example(const char *filename, int codec_id) exit(1); } - /* alloc image and output buffer */ - outbuf_size = 100000 + 12*c->width*c->height; - outbuf = malloc(outbuf_size); - /* 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, - c->width, c->height, c->pix_fmt, 1); + ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height, + c->pix_fmt, 32); + if (ret < 0) { + fprintf(stderr, "could not alloc raw picture buffer\n"); + exit(1); + } + + picture->format = c->pix_fmt; + picture->width = c->width; + picture->height = c->height; /* encode 1 second of video */ for(i=0;i<25;i++) { + av_init_packet(&pkt); + pkt.data = NULL; // packet data will be allocated by the encoder + pkt.size = 0; + fflush(stdout); /* prepare a dummy image */ /* Y */ @@ -387,35 +395,46 @@ static void video_encode_example(const char *filename, int codec_id) } } + picture->pts = i; + /* encode the image */ - out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); - had_output |= out_size; - printf("encoding frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); + ret = avcodec_encode_video2(c, &pkt, picture, &got_output); + if (ret < 0) { + fprintf(stderr, "error encoding frame\n"); + exit(1); + } + + if (got_output) { + printf("encoding frame %3d (size=%5d)\n", i, pkt.size); + fwrite(pkt.data, 1, pkt.size, f); + av_free_packet(&pkt); + } } /* get the delayed frames */ - for(; out_size || !had_output; i++) { + for (got_output = 1; got_output; i++) { fflush(stdout); - out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); - had_output |= out_size; - printf("write frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); + ret = avcodec_encode_video2(c, &pkt, NULL, &got_output); + if (ret < 0) { + fprintf(stderr, "error encoding frame\n"); + exit(1); + } + + if (got_output) { + printf("write frame %3d (size=%5d)\n", i, pkt.size); + fwrite(pkt.data, 1, pkt.size, f); + av_free_packet(&pkt); + } } /* add sequence end code to have a real mpeg file */ - outbuf[0] = 0x00; - outbuf[1] = 0x00; - outbuf[2] = 0x01; - outbuf[3] = 0xb7; - fwrite(outbuf, 1, 4, f); + fwrite(endcode, 1, sizeof(endcode), f); fclose(f); - free(outbuf); avcodec_close(c); av_free(c); - av_free(picture->data[0]); + av_freep(&picture->data[0]); av_free(picture); printf("\n"); } diff --git a/doc/protocols.texi b/doc/protocols.texi index 3a82c7fe4b..be19239a46 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -272,6 +272,12 @@ Name of live stream to subscribe to. By default no value will be sent. It is only sent if the option is specified or if rtmp_live is set to live. +@item rtmp_swfhash +SHA256 hash of the decompressed SWF file (32 bytes). + +@item rtmp_swfsize +Size of the decompressed SWF file, required for SWFVerification. + @item rtmp_swfurl URL of the SWF player for the media. By default no value will be sent. |