if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
// else if(!strcmp(key, "width") && vcodec && num_val > 0) vcodec->width = num_val;
// else if(!strcmp(key, "height") && vcodec && num_val > 0) vcodec->height = num_val;
- else if(!strcmp(key, "audiocodecid") && acodec) flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
- else if(!strcmp(key, "videocodecid") && vcodec) flv_set_video_codec(s, vstream, (int)num_val);
- else if(!strcmp(key, "audiosamplesize") && acodec && num_val >= 0) {
+ else if(!strcmp(key, "audiocodecid") && acodec && 0 <= (int)num_val)
+ flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
+ else if(!strcmp(key, "videocodecid") && vcodec && 0 <= (int)num_val)
+ flv_set_video_codec(s, vstream, (int)num_val);
+ else if(!strcmp(key, "audiosamplesize") && acodec && 0 < (int)num_val) {
acodec->bits_per_sample = num_val;
//we may have to rewrite a previously read codecid because FLV only marks PCM endianness.
if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
if (!st)
return NULL;
st->codec->codec_type = is_audio ? CODEC_TYPE_AUDIO : CODEC_TYPE_VIDEO;
- av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
+ av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
return st;
}
av_log(s, AV_LOG_WARNING, "Broken FLV file, which says no streams present, this might fail\n");
}
+ if((flags & (FLV_HEADER_FLAG_HASVIDEO|FLV_HEADER_FLAG_HASAUDIO))
+ != (FLV_HEADER_FLAG_HASVIDEO|FLV_HEADER_FLAG_HASAUDIO))
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
+
if(flags & FLV_HEADER_FLAG_HASVIDEO){
if(!create_stream(s, 0))
return AVERROR(ENOMEM);
static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- int ret, i, type, size, pts, flags, is_audio, next, pos;
+ int ret, i, type, size, flags, is_audio, next, pos;
+ unsigned dts;
AVStream *st = NULL;
for(;;){
url_fskip(s->pb, 4); /* size of previous packet */
type = get_byte(s->pb);
size = get_be24(s->pb);
- pts = get_be24(s->pb);
- pts |= get_byte(s->pb) << 24;
-// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, pts:%d\n", type, size, pts);
+ dts = get_be24(s->pb);
+ dts |= get_byte(s->pb) << 24;
+// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, dts:%d\n", type, size, dts);
if (url_feof(s->pb))
return AVERROR(EIO);
url_fskip(s->pb, 3); /* stream id, always 0 */
if(i == s->nb_streams){
av_log(NULL, AV_LOG_ERROR, "invalid stream\n");
st= create_stream(s, is_audio);
+ s->ctx_flags &= ~AVFMTCTX_NOHEADER;
}
// av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard);
if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || is_audio))
continue;
}
if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY)
- av_add_index_entry(st, pos, pts, size, 0, AVINDEX_KEYFRAME);
+ av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME);
break;
}
/* note: we need to modify the packet size here to handle the last
packet */
pkt->size = ret;
- pkt->pts = pts;
+ pkt->dts = dts;
pkt->stream_index = st->index;
if (is_audio || ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY))
return ret;
}
-static int flv_read_close(AVFormatContext *s)
-{
- return 0;
-}
-
-static int flv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
-{
- AVStream *st = s->streams[stream_index];
- int index = av_index_search_timestamp(st, timestamp, flags);
- if (index < 0)
- return -1;
- url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
-
- return 0;
-}
-
AVInputFormat flv_demuxer = {
"flv",
"flv format",
flv_probe,
flv_read_header,
flv_read_packet,
- flv_read_close,
- flv_read_seek,
.extensions = "flv",
.value = CODEC_ID_FLV1,
};