Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
245439e6
Commit
245439e6
authored
Jun 25, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSOutputStream: pass float format samples to libavcodec
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
3fb8c802
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
18 deletions
+4
-18
hlsoutputstream.cc
src/hlsoutputstream.cc
+4
-18
No files found.
src/hlsoutputstream.cc
View file @
245439e6
...
...
@@ -179,7 +179,7 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
nb_samples
=
m_enc
->
frame_size
;
m_frame
=
alloc_audio_frame
(
m_enc
->
sample_fmt
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
);
m_tmp_frame
=
alloc_audio_frame
(
AV_SAMPLE_FMT_
S16
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
);
m_tmp_frame
=
alloc_audio_frame
(
AV_SAMPLE_FMT_
FLT
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
);
/* copy the stream parameters to the muxer */
ret
=
avcodec_parameters_from_context
(
m_st
->
codecpar
,
m_enc
);
...
...
@@ -200,7 +200,7 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
/* set options */
av_opt_set_int
(
m_swr_ctx
,
"in_channel_count"
,
m_enc
->
channels
,
0
);
av_opt_set_int
(
m_swr_ctx
,
"in_sample_rate"
,
m_enc
->
sample_rate
,
0
);
av_opt_set_sample_fmt
(
m_swr_ctx
,
"in_sample_fmt"
,
AV_SAMPLE_FMT_
S16
,
0
);
av_opt_set_sample_fmt
(
m_swr_ctx
,
"in_sample_fmt"
,
AV_SAMPLE_FMT_
FLT
,
0
);
av_opt_set_int
(
m_swr_ctx
,
"out_channel_count"
,
m_enc
->
channels
,
0
);
av_opt_set_int
(
m_swr_ctx
,
"out_sample_rate"
,
m_enc
->
sample_rate
,
0
);
av_opt_set_sample_fmt
(
m_swr_ctx
,
"out_sample_fmt"
,
m_enc
->
sample_fmt
,
0
);
...
...
@@ -219,27 +219,13 @@ AVFrame *
HLSOutputStream
::
get_audio_frame
()
{
AVFrame
*
frame
=
m_tmp_frame
;
int16_t
*
q
=
(
int16_t
*
)
frame
->
data
[
0
];
if
(
m_audio_buffer
.
can_read_frames
()
<
size_t
(
frame
->
nb_samples
))
return
NULL
;
return
nullptr
;
vector
<
float
>
samples
=
m_audio_buffer
.
read_frames
(
frame
->
nb_samples
);
size_t
t
=
0
;
for
(
int
j
=
0
;
j
<
frame
->
nb_samples
;
j
++
)
{
for
(
int
i
=
0
;
i
<
m_enc
->
channels
;
i
++
)
{
if
(
t
<
samples
.
size
())
{
*
q
++
=
(
int
)(
samples
[
t
]
*
32768
);
t
++
;
}
else
*
q
++
=
0
;
}
}
std
::
copy
(
samples
.
begin
(),
samples
.
end
(),
(
float
*
)
frame
->
data
[
0
]);
frame
->
pts
=
m_next_pts
;
m_next_pts
+=
frame
->
nb_samples
;
...
...
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