summaryrefslogtreecommitdiff
path: root/libavformat/flvenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r--libavformat/flvenc.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 143c58ca50..98c4170311 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -61,7 +61,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){
@@ -78,11 +78,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) {
@@ -223,7 +218,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
@@ -368,7 +363,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 || enc->codec_id == CODEC_ID_MPEG4)) {
- put_avc_eos_tag(pb, flv->last_video_ts);
+ put_avc_eos_tag(pb, flv->last_ts);
}
}
@@ -434,19 +429,26 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
return -1;
}
- if (!flv->delay && pkt->dts < 0)
- flv->delay = -pkt->dts;
} else if (enc->codec_id == CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n");
return -1;
}
+ if (!flv->delay && pkt->dts < 0)
+ 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_