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
094c500c
Commit
094c500c
authored
Jan 08, 2014
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/muxing: set timestamps in output audio packet
In particular, fix trac ticket #3231.
parent
8d22d37e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
muxing.c
doc/examples/muxing.c
+7
-0
No files found.
doc/examples/muxing.c
View file @
094c500c
...
...
@@ -132,6 +132,7 @@ static int max_dst_nb_samples;
uint8_t
**
dst_samples_data
;
int
dst_samples_linesize
;
int
dst_samples_size
;
int
samples_count
;
struct
SwrContext
*
swr_ctx
=
NULL
;
...
...
@@ -269,8 +270,10 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
}
audio_frame
->
nb_samples
=
dst_nb_samples
;
audio_frame
->
pts
=
av_rescale_q
(
samples_count
,
(
AVRational
){
1
,
c
->
sample_rate
},
c
->
time_base
);
avcodec_fill_audio_frame
(
audio_frame
,
c
->
channels
,
c
->
sample_fmt
,
dst_samples_data
[
0
],
dst_samples_size
,
0
);
samples_count
+=
dst_nb_samples
;
ret
=
avcodec_encode_audio2
(
c
,
&
pkt
,
audio_frame
,
&
got_packet
);
if
(
ret
<
0
)
{
...
...
@@ -281,6 +284,10 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
if
(
!
got_packet
)
return
;
/* rescale output packet timestamp values from codec to stream timebase */
pkt
.
pts
=
av_rescale_q_rnd
(
pkt
.
pts
,
c
->
time_base
,
st
->
time_base
,
AV_ROUND_NEAR_INF
|
AV_ROUND_PASS_MINMAX
);
pkt
.
dts
=
av_rescale_q_rnd
(
pkt
.
dts
,
c
->
time_base
,
st
->
time_base
,
AV_ROUND_NEAR_INF
|
AV_ROUND_PASS_MINMAX
);
pkt
.
duration
=
av_rescale_q
(
pkt
.
duration
,
c
->
time_base
,
st
->
time_base
);
pkt
.
stream_index
=
st
->
index
;
/* Write the compressed frame to the media file. */
...
...
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