diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-19 13:20:15 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-20 13:06:16 -0400 |
commit | 4ee247a2bdf2fbe81026a428d4affc46c81f28db (patch) | |
tree | 9f2dc75de68eb769f648cf65ee01f10f304c4808 /libavformat/flvenc.c | |
parent | b606a017593b2a7a5f435f2b75b8de163c367ac6 (diff) | |
download | ffmpeg-4ee247a2bdf2fbe81026a428d4affc46c81f28db.tar.gz |
flvenc: check packet duration in speex using timestamps
Using AVCodecContext.frame_size is not reliable.
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r-- | libavformat/flvenc.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 851ce491b0..cf77157636 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -58,7 +58,7 @@ typedef struct FLVContext { int64_t filesize_offset; int64_t duration; int delay; ///< first dts delay for AVC - int64_t last_video_ts; + int64_t last_ts; } FLVContext; static int get_audio_flags(AVCodecContext *enc){ @@ -75,11 +75,6 @@ static int get_audio_flags(AVCodecContext *enc){ av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n"); return -1; } - if (enc->frame_size / 320 > 8) { - av_log(enc, AV_LOG_WARNING, "Warning: Speex stream has more than " - "8 frames per packet. Adobe Flash " - "Player cannot handle this!\n"); - } return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT; } else { switch (enc->sample_rate) { @@ -220,7 +215,7 @@ static int flv_write_header(AVFormatContext *s) } } - flv->last_video_ts = -1; + flv->last_ts = -1; /* write meta_tag */ avio_w8(pb, 18); // tag type META @@ -349,7 +344,7 @@ static int flv_write_trailer(AVFormatContext *s) AVCodecContext *enc = s->streams[i]->codec; if (enc->codec_type == AVMEDIA_TYPE_VIDEO && enc->codec_id == CODEC_ID_H264) { - put_avc_eos_tag(pb, flv->last_video_ts); + put_avc_eos_tag(pb, flv->last_ts); } } @@ -415,10 +410,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) flv->delay = -pkt->dts; ts = pkt->dts + flv->delay; // add delay to force positive dts - if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { - if (flv->last_video_ts < ts) - flv->last_video_ts = ts; + + /* check Speex packet duration */ + if (enc->codec_id == CODEC_ID_SPEEX && ts - flv->last_ts > 160) { + av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than " + "8 frames per packet. Adobe Flash " + "Player cannot handle this!\n"); } + + if (flv->last_ts < ts) + flv->last_ts = ts; + avio_wb24(pb,size + flags_size); avio_wb24(pb,ts); avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_ |