You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fix playback of http://www.zonque.org/test-long.ps
better seeking, (not to keyframes but at least to the start of packets ...) Originally committed as revision 3182 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -1080,7 +1080,7 @@ static int mpegts_read_header(AVFormatContext *s,
|
|||||||
MpegTSContext *ts = s->priv_data;
|
MpegTSContext *ts = s->priv_data;
|
||||||
ByteIOContext *pb = &s->pb;
|
ByteIOContext *pb = &s->pb;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[1024];
|
||||||
int len, sid;
|
int len, sid, i;
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
MpegTSService *service;
|
MpegTSService *service;
|
||||||
|
|
||||||
@@ -1135,7 +1135,8 @@ static int mpegts_read_header(AVFormatContext *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tune to first service found */
|
/* tune to first service found */
|
||||||
service = ts->services[0];
|
for(i=0; i<ts->nb_services && ts->set_service_ret; i++){
|
||||||
|
service = ts->services[i];
|
||||||
sid = service->sid;
|
sid = service->sid;
|
||||||
#ifdef DEBUG_SI
|
#ifdef DEBUG_SI
|
||||||
printf("tuning to '%s'\n", service->name);
|
printf("tuning to '%s'\n", service->name);
|
||||||
@@ -1148,8 +1149,9 @@ static int mpegts_read_header(AVFormatContext *s,
|
|||||||
mpegts_set_service(ts, sid, set_service_cb, ts);
|
mpegts_set_service(ts, sid, set_service_cb, ts);
|
||||||
|
|
||||||
handle_packets(ts, MAX_SCAN_PACKETS);
|
handle_packets(ts, MAX_SCAN_PACKETS);
|
||||||
|
}
|
||||||
/* if could not find service, exit */
|
/* if could not find service, exit */
|
||||||
|
|
||||||
if (ts->set_service_ret != 0)
|
if (ts->set_service_ret != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -1324,6 +1326,29 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
|
|||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts){
|
||||||
|
MpegTSContext *ts = s->priv_data;
|
||||||
|
uint8_t buf[TS_PACKET_SIZE];
|
||||||
|
int64_t pos;
|
||||||
|
|
||||||
|
if(av_seek_frame_binary(s, stream_index, target_ts) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pos= url_ftell(&s->pb);
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
url_fseek(&s->pb, pos, SEEK_SET);
|
||||||
|
if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
|
||||||
|
return -1;
|
||||||
|
// pid = ((buf[1] & 0x1f) << 8) | buf[2];
|
||||||
|
if(buf[1] & 0x40) break;
|
||||||
|
pos += ts->raw_packet_size;
|
||||||
|
}
|
||||||
|
url_fseek(&s->pb, pos, SEEK_SET);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/* parsing functions - called from other demuxers such as RTP */
|
/* parsing functions - called from other demuxers such as RTP */
|
||||||
|
|
||||||
@@ -1385,7 +1410,7 @@ AVInputFormat mpegts_demux = {
|
|||||||
mpegts_read_header,
|
mpegts_read_header,
|
||||||
mpegts_read_packet,
|
mpegts_read_packet,
|
||||||
mpegts_read_close,
|
mpegts_read_close,
|
||||||
NULL, //mpegts_read_seek,
|
read_seek,
|
||||||
mpegts_get_pcr,
|
mpegts_get_pcr,
|
||||||
.flags = AVFMT_SHOW_IDS,
|
.flags = AVFMT_SHOW_IDS,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user