summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-25 04:00:43 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-25 04:00:43 +0100
commitb008ac18bb6072acb355445436a999c940538d84 (patch)
tree29d0042d7a4d0bc64f452440c2060a13a1e00e51 /doc
parent7b9d8703f35585b065c32194b52131b7dd90c710 (diff)
parentd6a77e2b97f3968b99798faeb70e873eb5910849 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: docs: use -bsf:[vas] instead of -[vas]bsf. mpegaudiodec: Prevent premature clipping of mp3 input buffer. lavf: move the packet keyframe setting code. oggenc: free comment header for all codecs lcl: error out if uncompressed input buffer is smaller than framesize. mjpeg: abort decoding if packet is too large. golomb: use HAVE_BITS_REMAINING() macro to prevent infloop on EOF. get_bits: add HAVE_BITS_REMAINING macro. lavf/output-example: use new audio encoding API correctly. lavf/output-example: more proper usage of the new API. tiff: Prevent overreads in the type_sizes array. tiff: Make the TIFF_LONG and TIFF_SHORT types unsigned. apetag: do not leak memory if avio_read() fails apetag: propagate errors. SBR DSP x86: implement SSE sbr_hf_g_filt SBR DSP x86: implement SSE sbr_sum_square_sse SBR DSP: use intptr_t for the ixh parameter. Conflicts: doc/bitstream_filters.texi doc/examples/muxing.c doc/ffmpeg.texi libavcodec/golomb.h libavcodec/x86/Makefile libavformat/oggenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'doc')
-rw-r--r--doc/bitstream_filters.texi2
-rw-r--r--doc/examples/muxing.c87
-rw-r--r--doc/ffmpeg.texi4
3 files changed, 38 insertions, 55 deletions
diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index e131f44324..2ee00c134b 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -71,7 +71,7 @@ stream (carrying the AVI1 header ID and lacking a DHT segment) to
produce fully qualified JPEG images.
@example
-ffmpeg -i mjpeg-movie.avi -c:v copy -vbsf mjpeg2jpeg frame_%d.jpg
+ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
exiftran -i -9 frame*.jpg
ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
@end example
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index 8070ea4eb3..5e2bf9f9b0 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -52,8 +52,6 @@ static int sws_flags = SWS_BICUBIC;
static float t, tincr, tincr2;
static int16_t *samples;
-static uint8_t *audio_outbuf;
-static int audio_outbuf_size;
static int audio_input_frame_size;
/*
@@ -63,8 +61,16 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
{
AVCodecContext *c;
AVStream *st;
+ AVCodec *codec;
+
+ /* find the audio encoder */
+ codec = avcodec_find_encoder(codec_id);
+ if (!codec) {
+ fprintf(stderr, "codec not found\n");
+ exit(1);
+ }
- st = avformat_new_stream(oc, NULL);
+ st = avformat_new_stream(oc, codec);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
@@ -72,8 +78,6 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
st->id = 1;
c = st->codec;
- c->codec_id = codec_id;
- c->codec_type = AVMEDIA_TYPE_AUDIO;
/* put sample parameters */
c->sample_fmt = AV_SAMPLE_FMT_S16;
@@ -91,19 +95,11 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
static void open_audio(AVFormatContext *oc, AVStream *st)
{
AVCodecContext *c;
- AVCodec *codec;
c = st->codec;
- /* find the audio encoder */
- codec = avcodec_find_encoder(c->codec_id);
- if (!codec) {
- fprintf(stderr, "codec not found\n");
- exit(1);
- }
-
/* open it */
- if (avcodec_open2(c, codec, NULL) < 0) {
+ if (avcodec_open2(c, NULL, NULL) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
@@ -114,27 +110,12 @@ static void open_audio(AVFormatContext *oc, AVStream *st)
/* increment frequency by 110 Hz per second */
tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
- audio_outbuf_size = 10000;
- audio_outbuf = av_malloc(audio_outbuf_size);
-
- /* ugly hack for PCM codecs (will be removed ASAP with new PCM
- support to compute the input frame size in samples */
- if (c->frame_size <= 1) {
- audio_input_frame_size = audio_outbuf_size / c->channels;
- switch(st->codec->codec_id) {
- case CODEC_ID_PCM_S16LE:
- case CODEC_ID_PCM_S16BE:
- case CODEC_ID_PCM_U16LE:
- case CODEC_ID_PCM_U16BE:
- audio_input_frame_size >>= 1;
- break;
- default:
- break;
- }
- } else {
+ if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
+ audio_input_frame_size = 10000;
+ else
audio_input_frame_size = c->frame_size;
- }
- samples = av_malloc(audio_input_frame_size * 2 * c->channels);
+ samples = av_malloc(audio_input_frame_size * av_get_bytes_per_sample(c->sample_fmt)
+ * c->channels);
}
/* prepare a 16 bit dummy audio frame of 'frame_size' samples and
@@ -158,19 +139,23 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
{
AVCodecContext *c;
AVPacket pkt;
- av_init_packet(&pkt);
+ AVFrame *frame = avcodec_alloc_frame();
+ int got_packet;
+ av_init_packet(&pkt);
c = st->codec;
get_audio_frame(samples, audio_input_frame_size, c->channels);
+ frame->nb_samples = audio_input_frame_size;
+ avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, (uint8_t *)samples,
+ audio_input_frame_size * av_get_bytes_per_sample(c->sample_fmt)
+ * c->channels, 1);
- pkt.size = avcodec_encode_audio2(c, audio_outbuf, audio_outbuf_size, samples);
+ avcodec_encode_audio2(c, &pkt, frame, &got_packet);
+ if (!got_packet)
+ return;
- if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
- pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
- pkt.flags |= AV_PKT_FLAG_KEY;
- pkt.stream_index = st->index;
- pkt.data = audio_outbuf;
+ pkt.stream_index= st->index;
/* write the compressed frame in the media file */
if (av_interleaved_write_frame(oc, &pkt) != 0) {
@@ -184,7 +169,6 @@ static void close_audio(AVFormatContext *oc, AVStream *st)
avcodec_close(st->codec);
av_free(samples);
- av_free(audio_outbuf);
}
/**************************************************************/
@@ -201,7 +185,14 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id)
AVStream *st;
AVCodec *codec;
- st = avformat_new_stream(oc, NULL);
+ /* find the video encoder */
+ codec = avcodec_find_encoder(codec_id);
+ if (!codec) {
+ fprintf(stderr, "codec not found\n");
+ exit(1);
+ }
+
+ st = avformat_new_stream(oc, codec);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
@@ -271,20 +262,12 @@ static AVFrame *alloc_picture(enum PixelFormat pix_fmt, int width, int height)
static void open_video(AVFormatContext *oc, AVStream *st)
{
- AVCodec *codec;
AVCodecContext *c;
c = st->codec;
- /* find the video encoder */
- codec = avcodec_find_encoder(c->codec_id);
- if (!codec) {
- fprintf(stderr, "codec not found\n");
- exit(1);
- }
-
/* open the codec */
- if (avcodec_open2(c, codec, NULL) < 0) {
+ if (avcodec_open2(c, NULL, NULL) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 51a282ef0c..128aceccb0 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1019,10 +1019,10 @@ Set bitstream filters for matching streams. @var{bistream_filters} is
a comma-separated list of bitstream filters. Use the @code{-bsfs} option
to get the list of bitstream filters.
@example
-ffmpeg -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264
+ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
@end example
@example
-ffmpeg -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt
+ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
@end example
@item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{per-stream})