summaryrefslogtreecommitdiff
path: root/contrib/ffmpeg/libavformat/flvenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ffmpeg/libavformat/flvenc.c')
-rw-r--r--contrib/ffmpeg/libavformat/flvenc.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/contrib/ffmpeg/libavformat/flvenc.c b/contrib/ffmpeg/libavformat/flvenc.c
index ece585d77..e5270ca32 100644
--- a/contrib/ffmpeg/libavformat/flvenc.c
+++ b/contrib/ffmpeg/libavformat/flvenc.c
@@ -35,8 +35,8 @@ static const AVCodecTag flv_video_codec_ids[] = {
static const AVCodecTag flv_audio_codec_ids[] = {
{CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET},
- {CODEC_ID_PCM_S8, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
- {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_PCM_S8, FLV_CODECID_PCM >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM >> FLV_AUDIO_CODECID_OFFSET},
{CODEC_ID_PCM_S16LE, FLV_CODECID_PCM_LE >> FLV_AUDIO_CODECID_OFFSET},
{CODEC_ID_ADPCM_SWF, FLV_CODECID_ADPCM >> FLV_AUDIO_CODECID_OFFSET},
{CODEC_ID_NONE, 0}
@@ -66,10 +66,12 @@ static int get_audio_flags(AVCodecContext *enc){
break;
case 8000: //nellymoser only
case 5512: //not mp3
- flags |= FLV_SAMPLERATE_SPECIAL;
- break;
+ if(enc->codec_id != CODEC_ID_MP3){
+ flags |= FLV_SAMPLERATE_SPECIAL;
+ break;
+ }
default:
- av_log(enc, AV_LOG_ERROR, "flv doesnt support that sample rate, choose from (44100, 22050, 11025)\n");
+ av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n");
return -1;
}
@@ -82,10 +84,10 @@ static int get_audio_flags(AVCodecContext *enc){
flags |= FLV_CODECID_MP3 | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_S8:
- flags |= FLV_CODECID_PCM_BE | FLV_SAMPLESSIZE_8BIT;
+ flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_8BIT;
break;
case CODEC_ID_PCM_S16BE:
- flags |= FLV_CODECID_PCM_BE | FLV_SAMPLESSIZE_16BIT;
+ flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_S16LE:
flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
@@ -124,7 +126,7 @@ static void put_amf_bool(ByteIOContext *pb, int b) {
static int flv_write_header(AVFormatContext *s)
{
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
int i, width, height, samplerate, samplesize, channels, audiocodecid, videocodecid;
double framerate = 0.0;
@@ -254,7 +256,7 @@ static int flv_write_trailer(AVFormatContext *s)
{
int64_t file_size;
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
file_size = url_ftell(pb);
@@ -271,14 +273,19 @@ static int flv_write_trailer(AVFormatContext *s)
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
FLVContext *flv = s->priv_data;
int size= pkt->size;
- int flags;
+ int flags, flags_size;
// av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
+ if(enc->codec_id == CODEC_ID_VP6 || enc->codec_id == CODEC_ID_VP6F)
+ flags_size= 2;
+ else
+ flags_size= 1;
+
if (enc->codec_type == CODEC_TYPE_VIDEO) {
put_byte(pb, FLV_TAG_TYPE_VIDEO);
@@ -298,19 +305,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
put_byte(pb, FLV_TAG_TYPE_AUDIO);
}
- if ((enc->codec_id == CODEC_ID_VP6) || (enc->codec_id == CODEC_ID_VP6F))
- put_be24(pb,size+2); // include the extra byte needed for VP6 in flv and flags
- else
- put_be24(pb,size+1); // include flags
+ put_be24(pb,size + flags_size);
put_be24(pb,pkt->pts);
- put_be32(pb,flv->reserved);
+ put_byte(pb,pkt->pts >> 24);
+ put_be24(pb,flv->reserved);
put_byte(pb,flags);
if (enc->codec_id == CODEC_ID_VP6)
put_byte(pb,0);
if (enc->codec_id == CODEC_ID_VP6F)
put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
put_buffer(pb, pkt->data, size);
- put_be32(pb,size+1+11); // previous tag size
+ put_be32(pb,size+flags_size+11); // previous tag size
flv->duration = pkt->pts + pkt->duration;
put_flush_packet(pb);
@@ -326,7 +331,7 @@ AVOutputFormat flv_muxer = {
#ifdef CONFIG_LIBMP3LAME
CODEC_ID_MP3,
#else // CONFIG_LIBMP3LAME
- CODEC_ID_NONE,
+ CODEC_ID_ADPCM_SWF,
#endif // CONFIG_LIBMP3LAME
CODEC_ID_FLV1,
flv_write_header,