Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
4ee247a2
Commit
4ee247a2
authored
Oct 19, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flvenc: check packet duration in speex using timestamps
Using AVCodecContext.frame_size is not reliable.
parent
b606a017
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
flvenc.c
libavformat/flvenc.c
+13
-11
No files found.
libavformat/flvenc.c
View file @
4ee247a2
...
@@ -58,7 +58,7 @@ typedef struct FLVContext {
...
@@ -58,7 +58,7 @@ typedef struct FLVContext {
int64_t
filesize_offset
;
int64_t
filesize_offset
;
int64_t
duration
;
int64_t
duration
;
int
delay
;
///< first dts delay for AVC
int
delay
;
///< first dts delay for AVC
int64_t
last_
video_
ts
;
int64_t
last_ts
;
}
FLVContext
;
}
FLVContext
;
static
int
get_audio_flags
(
AVCodecContext
*
enc
){
static
int
get_audio_flags
(
AVCodecContext
*
enc
){
...
@@ -75,11 +75,6 @@ static int get_audio_flags(AVCodecContext *enc){
...
@@ -75,11 +75,6 @@ static int get_audio_flags(AVCodecContext *enc){
av_log
(
enc
,
AV_LOG_ERROR
,
"flv only supports mono Speex audio
\n
"
);
av_log
(
enc
,
AV_LOG_ERROR
,
"flv only supports mono Speex audio
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
enc
->
frame_size
/
320
>
8
)
{
av_log
(
enc
,
AV_LOG_WARNING
,
"Warning: Speex stream has more than "
"8 frames per packet. Adobe Flash "
"Player cannot handle this!
\n
"
);
}
return
FLV_CODECID_SPEEX
|
FLV_SAMPLERATE_11025HZ
|
FLV_SAMPLESSIZE_16BIT
;
return
FLV_CODECID_SPEEX
|
FLV_SAMPLERATE_11025HZ
|
FLV_SAMPLESSIZE_16BIT
;
}
else
{
}
else
{
switch
(
enc
->
sample_rate
)
{
switch
(
enc
->
sample_rate
)
{
...
@@ -220,7 +215,7 @@ static int flv_write_header(AVFormatContext *s)
...
@@ -220,7 +215,7 @@ static int flv_write_header(AVFormatContext *s)
}
}
}
}
flv
->
last_
video_
ts
=
-
1
;
flv
->
last_ts
=
-
1
;
/* write meta_tag */
/* write meta_tag */
avio_w8
(
pb
,
18
);
// tag type META
avio_w8
(
pb
,
18
);
// tag type META
...
@@ -349,7 +344,7 @@ static int flv_write_trailer(AVFormatContext *s)
...
@@ -349,7 +344,7 @@ static int flv_write_trailer(AVFormatContext *s)
AVCodecContext
*
enc
=
s
->
streams
[
i
]
->
codec
;
AVCodecContext
*
enc
=
s
->
streams
[
i
]
->
codec
;
if
(
enc
->
codec_type
==
AVMEDIA_TYPE_VIDEO
&&
if
(
enc
->
codec_type
==
AVMEDIA_TYPE_VIDEO
&&
enc
->
codec_id
==
CODEC_ID_H264
)
{
enc
->
codec_id
==
CODEC_ID_H264
)
{
put_avc_eos_tag
(
pb
,
flv
->
last_
video_
ts
);
put_avc_eos_tag
(
pb
,
flv
->
last_ts
);
}
}
}
}
...
@@ -415,10 +410,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -415,10 +410,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
flv
->
delay
=
-
pkt
->
dts
;
flv
->
delay
=
-
pkt
->
dts
;
ts
=
pkt
->
dts
+
flv
->
delay
;
// add delay to force positive dts
ts
=
pkt
->
dts
+
flv
->
delay
;
// add delay to force positive dts
if
(
enc
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
if
(
flv
->
last_video_ts
<
ts
)
/* check Speex packet duration */
flv
->
last_video_ts
=
ts
;
if
(
enc
->
codec_id
==
CODEC_ID_SPEEX
&&
ts
-
flv
->
last_ts
>
160
)
{
av_log
(
s
,
AV_LOG_WARNING
,
"Warning: Speex stream has more than "
"8 frames per packet. Adobe Flash "
"Player cannot handle this!
\n
"
);
}
}
if
(
flv
->
last_ts
<
ts
)
flv
->
last_ts
=
ts
;
avio_wb24
(
pb
,
size
+
flags_size
);
avio_wb24
(
pb
,
size
+
flags_size
);
avio_wb24
(
pb
,
ts
);
avio_wb24
(
pb
,
ts
);
avio_w8
(
pb
,(
ts
>>
24
)
&
0x7F
);
// timestamps are 32bits _signed_
avio_w8
(
pb
,(
ts
>>
24
)
&
0x7F
);
// timestamps are 32bits _signed_
...
...
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