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
68990dcc
Commit
68990dcc
authored
May 04, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testhls: decode next.ts after current segment
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
1782d96a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
testhls.cc
src/testhls.cc
+30
-4
No files found.
src/testhls.cc
View file @
68990dcc
...
...
@@ -69,6 +69,15 @@ ff_decode (const string& filename, const TSReader& reader, WavData& out_wav_data
int
c
;
while
((
c
=
fgetc
(
main
))
>=
0
)
fputc
(
c
,
input_tmp_file
);
auto
next_ts
=
reader
.
find
(
"next.ts"
);
if
(
next_ts
)
{
// write next ts
size_t
r
=
fwrite
(
next_ts
->
data
.
data
(),
1
,
next_ts
->
data
.
size
(),
input_tmp_file
);
if
(
r
!=
next_ts
->
data
.
size
())
return
Error
(
string_printf
(
"unable to write ff_decode:next.ts to %s
\n
"
,
input_tmp_file_name
.
c_str
()));
}
fflush
(
input_tmp_file
);
string
cmd
=
string_printf
(
"ffmpeg -v error -y -f mpegts -i %s -f wav %s"
,
input_tmp_file_name
.
c_str
(),
tmp_file_name
.
c_str
());
...
...
@@ -134,6 +143,7 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi
struct
Segment
{
string
name
;
size_t
size
;
map
<
string
,
string
>
vars
;
};
vector
<
Segment
>
segments
;
...
...
@@ -164,7 +174,6 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi
}
line
++
;
}
size_t
prev_size
=
0
;
size_t
start_pos
=
0
;
for
(
auto
&
segment
:
segments
)
{
...
...
@@ -176,10 +185,25 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi
return
1
;
}
printf
(
"%d %zd
\n
"
,
out
.
sample_rate
(),
out
.
n_values
()
/
out
.
n_channels
());
segment
.
size
=
out
.
n_values
()
/
out
.
n_channels
();
segment
.
vars
[
"start_pos"
]
=
string_printf
(
"%zd"
,
start_pos
);
segment
.
vars
[
"prev_size"
]
=
string_printf
(
"%zd"
,
prev_size
);
start_pos
+=
out
.
n_values
()
/
out
.
n_channels
();
prev_size
=
out
.
n_values
()
/
out
.
n_channels
();
segment
.
vars
[
"size"
]
=
string_printf
(
"%zd"
,
segment
.
size
);
start_pos
+=
segment
.
size
;
}
/* fill out next/prev size fields */
for
(
size_t
i
=
0
;
i
<
segments
.
size
();
i
++
)
{
if
(
i
>
0
)
segments
[
i
].
vars
[
"prev_size"
]
=
string_printf
(
"%zd"
,
segments
[
i
-
1
].
size
);
else
segments
[
i
].
vars
[
"prev_size"
]
=
"0"
;
if
(
i
+
1
<
segments
.
size
())
segments
[
i
].
vars
[
"next_size"
]
=
string_printf
(
"%zd"
,
segments
[
i
+
1
].
size
);
else
segments
[
i
].
vars
[
"next_size"
]
=
"0"
;
}
for
(
size_t
i
=
0
;
i
<
segments
.
size
();
i
++
)
{
...
...
@@ -224,10 +248,12 @@ hls_mark (const string& infile, const string& outfile, const string& bits)
size_t
start_pos
=
atoi
(
vars
[
"start_pos"
].
c_str
());
size_t
prev_size
=
atoi
(
vars
[
"prev_size"
].
c_str
());
size_t
next_size
=
atoi
(
vars
[
"next_size"
].
c_str
());
/* erase extra samples caused by concatting with prev.ts */
auto
samples
=
wav_data
.
samples
();
samples
.
erase
(
samples
.
begin
(),
samples
.
begin
()
+
prev_size
*
wav_data
.
n_channels
());
samples
.
erase
(
samples
.
end
()
-
next_size
*
wav_data
.
n_channels
(),
samples
.
end
());
wav_data
.
set_samples
(
samples
);
err
=
ff_encode
(
wav_data
,
outfile
,
start_pos
);
...
...
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