mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
always write duration and file size, fix seeking, progress bar is now active
Originally committed as revision 5939 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
fb2d9140e4
commit
634b8cfaf4
@ -25,6 +25,9 @@ typedef struct FLVContext {
|
||||
int hasAudio;
|
||||
int hasVideo;
|
||||
int reserved;
|
||||
offset_t duration_offset;
|
||||
offset_t filesize_offset;
|
||||
int64_t duration;
|
||||
} FLVContext;
|
||||
|
||||
static int get_audio_flags(AVCodecContext *enc){
|
||||
@ -160,12 +163,11 @@ static int flv_write_header(AVFormatContext *s)
|
||||
|
||||
/* mixed array (hash) with size and string/type/data tuples */
|
||||
put_byte(pb, AMF_MIXED_ARRAY);
|
||||
put_be32(pb, 4*flv->hasVideo + flv->hasAudio + (!!s->file_size) + (s->duration != AV_NOPTS_VALUE && s->duration));
|
||||
put_be32(pb, 4*flv->hasVideo + flv->hasAudio + 2); // +2 for duration and file size
|
||||
|
||||
if (s->duration != AV_NOPTS_VALUE && s->duration) {
|
||||
put_amf_string(pb, "duration");
|
||||
put_amf_double(pb, s->duration / (double)AV_TIME_BASE);
|
||||
}
|
||||
put_amf_string(pb, "duration");
|
||||
flv->duration_offset= url_ftell(pb);
|
||||
put_amf_double(pb, 0); // delayed write
|
||||
|
||||
if(flv->hasVideo){
|
||||
put_amf_string(pb, "width");
|
||||
@ -186,10 +188,9 @@ static int flv_write_header(AVFormatContext *s)
|
||||
put_amf_double(pb, samplerate);
|
||||
}
|
||||
|
||||
if(s->file_size){
|
||||
put_amf_string(pb, "filesize");
|
||||
put_amf_double(pb, s->file_size);
|
||||
}
|
||||
put_amf_string(pb, "filesize");
|
||||
flv->filesize_offset= url_ftell(pb);
|
||||
put_amf_double(pb, 0); // delayed write
|
||||
|
||||
put_amf_string(pb, "");
|
||||
put_byte(pb, 9); // end marker 1 byte
|
||||
@ -217,6 +218,13 @@ static int flv_write_trailer(AVFormatContext *s)
|
||||
flags |= flv->hasVideo ? 1 : 0;
|
||||
url_fseek(pb, 4, SEEK_SET);
|
||||
put_byte(pb,flags);
|
||||
|
||||
/* update informations */
|
||||
url_fseek(pb, flv->duration_offset, SEEK_SET);
|
||||
put_amf_double(pb, flv->duration / (double)1000);
|
||||
url_fseek(pb, flv->filesize_offset, SEEK_SET);
|
||||
put_amf_double(pb, file_size);
|
||||
|
||||
url_fseek(pb, file_size, SEEK_SET);
|
||||
return 0;
|
||||
}
|
||||
@ -250,6 +258,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
put_byte(pb,flags);
|
||||
put_buffer(pb, pkt->data, size);
|
||||
put_be32(pb,size+1+11); // previous tag size
|
||||
flv->duration = pkt->pts + pkt->duration;
|
||||
|
||||
put_flush_packet(pb);
|
||||
return 0;
|
||||
|
@ -125,8 +125,8 @@ stddev: 20.00 PSNR:22.10 bytes:7602176
|
||||
1453500 ./data/a-asv2.avi
|
||||
0b310840a6d3970595983491687669df *./data/out.yuv
|
||||
stddev: 18.82 PSNR:22.63 bytes:7602176
|
||||
2e1647c88d1b7e56d91058484db602da *./data/a-flv.flv
|
||||
658104 ./data/a-flv.flv
|
||||
fc2eaff78828dd0efd6483f754511f33 *./data/a-flv.flv
|
||||
658142 ./data/a-flv.flv
|
||||
4d9c04e7017dc68da7891048c46c1c37 *./data/out.yuv
|
||||
stddev: 8.08 PSNR:29.97 bytes:7602176
|
||||
a7ef4746f27be309138c188e327d3ebe *./data/a-ffv1.avi
|
||||
|
@ -19,8 +19,8 @@ ffmpeg regression test
|
||||
0026c4e2528ff8f71b79ef53d38cc04d *./data/b-libav.ffm
|
||||
389120 ./data/b-libav.ffm
|
||||
./data/b-libav.ffm CRC=0x688bd1eb
|
||||
eb8ff480628c444be572045ef7208528 *./data/b-libav.flv
|
||||
339438 ./data/b-libav.flv
|
||||
1596b6d08a94e6b5519357ed23a48aa3 *./data/b-libav.flv
|
||||
339476 ./data/b-libav.flv
|
||||
./data/b-libav.flv CRC=0x7b9076f8
|
||||
63e05396e2d52135c4025ce14eb090a9 *./data/b-libav.mov
|
||||
369893 ./data/b-libav.mov
|
||||
|
Loading…
Reference in New Issue
Block a user