Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
92a26775
Commit
92a26775
authored
Mar 09, 2004
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flv fixes
Originally committed as revision 2863 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
c7516a00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
flvdec.c
libavformat/flvdec.c
+3
-0
flvenc.c
libavformat/flvenc.c
+18
-12
No files found.
libavformat/flvdec.c
View file @
92a26775
...
...
@@ -57,6 +57,8 @@ static int flv_read_header(AVFormatContext *s,
return
AVERROR_NOMEM
;
st
->
codec
.
codec_type
=
CODEC_TYPE_VIDEO
;
st
->
codec
.
codec_id
=
CODEC_ID_FLV1
;
st
->
codec
.
frame_rate
=
ap
->
frame_rate
;
st
->
codec
.
frame_rate_base
=
ap
->
frame_rate_base
;
}
if
((
flags
&
4
))
{
...
...
@@ -83,6 +85,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
type
=
get_byte
(
&
s
->
pb
);
size
=
get_be24
(
&
s
->
pb
);
pts
=
get_be24
(
&
s
->
pb
);
// av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, pts:%d\n", type, size, pts);
if
(
url_feof
(
&
s
->
pb
))
return
-
EIO
;
url_fskip
(
&
s
->
pb
,
4
);
/* reserved */
...
...
libavformat/flvenc.c
View file @
92a26775
...
...
@@ -37,7 +37,7 @@ typedef struct FLVContext {
int
audioInPos
;
int
audioOutPos
;
int
audioSize
;
int
audioRate
;
//
int audioRate;
int
initDelay
;
int
soundDelay
;
uint8_t
*
audioFifo
;
...
...
@@ -98,31 +98,32 @@ static int mp3info(void *data, int *byteSize, int *samplesPerFrame, int *sampleR
}
if
(
!
isPadded
)
{
printf
(
"Fatal error: mp3 data is not padded!
\n
"
);
exit
(
0
);
//
printf("Fatal error: mp3 data is not padded!\n");
//
exit(0);
}
*
isMono
=
((
header
>>
6
)
&
0x03
)
==
0x03
;
if
(
(
header
>>
19
)
&
0x01
)
{
//MPEG1
*
sampleRate
=
sSampleRates
[
0
][
sampleRateID
];
bitRate
=
sBitRates
[
0
][
layerID
][
bitRateID
]
*
1000
;
*
samplesPerFrame
=
sSamplesPerFrame
[
0
][
layerID
];
}
else
{
if
(
(
header
>>
20
)
&
0x01
)
{
//MPEG2
*
sampleRate
=
sSampleRates
[
1
][
sampleRateID
];
bitRate
=
sBitRates
[
1
][
layerID
][
bitRateID
]
*
1000
;
*
samplesPerFrame
=
sSamplesPerFrame
[
1
][
layerID
];
}
else
{
//MPEG2.5
*
sampleRate
=
sSampleRates
[
2
][
sampleRateID
];
bitRate
=
sBitRates
[
1
][
layerID
][
bitRateID
]
*
1000
;
*
samplesPerFrame
=
sSamplesPerFrame
[
2
][
layerID
];
}
}
*
byteSize
=
(
(
(
(
*
samplesPerFrame
*
(
bitRate
/
bitsPerSlot
)
)
/
*
sampleRate
)
+
isPadded
)
);
return
1
;
}
#endif // CONFIG_MP3LAME
...
...
@@ -143,7 +144,7 @@ static int flv_write_header(AVFormatContext *s)
flv
->
audioInPos
=
0
;
flv
->
audioOutPos
=
0
;
flv
->
audioSize
=
0
;
flv
->
audioRate
=
44100
;
//
flv->audioRate = 44100;
flv
->
initDelay
=
-
1
;
flv
->
soundDelay
=
0
;
#endif // CONFIG_MP3LAME
...
...
@@ -270,6 +271,7 @@ static int flv_write_packet(AVFormatContext *s, int stream_index,
#ifdef CONFIG_MP3LAME
if
(
enc
->
codec_id
==
CODEC_ID_MP3
)
{
int
c
=
0
;
for
(;
c
<
size
;
c
++
)
{
flv
->
audioFifo
[(
flv
->
audioOutPos
+
c
)
%
AUDIO_FIFO_SIZE
]
=
buf
[
c
];
}
...
...
@@ -281,13 +283,13 @@ static int flv_write_packet(AVFormatContext *s, int stream_index,
flv
->
initDelay
=
timestamp
;
}
if
(
flv
->
audioTime
==
-
1
)
{
//
if ( flv->audioTime == -1 ) {
flv
->
audioTime
=
timestamp
;
// flv->audioTime = ( ( ( flv->sampleCount - enc->delay ) * 8000 ) / flv->audioRate ) - flv->initDelay - 250;
// if ( flv->audioTime < 0 ) {
// flv->audioTime = 0;
// }
}
//
}
}
for
(
;
flv
->
audioSize
>=
4
;
)
{
...
...
@@ -310,7 +312,7 @@ static int flv_write_packet(AVFormatContext *s, int stream_index,
int
c
=
0
;
FLVFrame
*
frame
=
av_malloc
(
sizeof
(
FLVFrame
));
flv
->
audioRate
=
mp3SampleRate
;
//
flv->audioRate = mp3SampleRate;
switch
(
mp3SampleRate
)
{
case
44100
:
...
...
@@ -332,6 +334,7 @@ static int flv_write_packet(AVFormatContext *s, int stream_index,
frame
->
type
=
8
;
frame
->
flags
=
soundFormat
;
frame
->
timestamp
=
flv
->
audioTime
;
frame
->
timestamp
=
(
1000
*
flv
->
sampleCount
+
mp3SampleRate
/
2
)
/
(
mp3SampleRate
);
frame
->
size
=
mp3FrameSize
;
frame
->
data
=
av_malloc
(
mp3FrameSize
);
...
...
@@ -344,15 +347,18 @@ static int flv_write_packet(AVFormatContext *s, int stream_index,
flv
->
audioInPos
%=
AUDIO_FIFO_SIZE
;
flv
->
sampleCount
+=
mp3SamplesPerFrame
;
// Reset audio for next round
flv
->
audioTime
=
-
1
;
flv
->
audioTime
+=
1000
*
mp3SamplesPerFrame
/
mp3SampleRate
;
// We got audio! Make sure we set this to the global flags on closure
flv
->
hasAudio
=
1
;
InsertSorted
(
flv
,
frame
);
// av_log(NULL,AV_LOG_DEBUG, "insert sound\n");
continue
;
}
// av_log(NULL,AV_LOG_DEBUG, "insuficent data\n");
break
;
}
av_log
(
NULL
,
AV_LOG_DEBUG
,
"head trashed
\n
"
);
flv
->
audioInPos
++
;
flv
->
audioSize
--
;
flv
->
audioInPos
%=
AUDIO_FIFO_SIZE
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment