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
7a0e689c
Commit
7a0e689c
authored
May 01, 2014
by
ValdikSS
Committed by
Clément Bœsch
May 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/subtitles: introduce stream_index
Signed-off-by:
ValdikSS
<
iam@valdikss.org.ru
>
parent
91736025
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
filters.texi
doc/filters.texi
+13
-0
vf_subtitles.c
libavfilter/vf_subtitles.c
+22
-2
No files found.
doc/filters.texi
View file @
7a0e689c
...
@@ -7725,6 +7725,9 @@ changed.
...
@@ -7725,6 +7725,9 @@ changed.
@item charenc
@item charenc
Set subtitles input character encoding. @code{subtitles} filter only. Only
Set subtitles input character encoding. @code{subtitles} filter only. Only
useful if not UTF-8.
useful if not UTF-8.
@item stream_index, si
Set subtitles stream index. @code{subtitles} filter only.
@end table
@end table
If the first key is not specified, it is assumed that the first value
If the first key is not specified, it is assumed that the first value
...
@@ -7741,6 +7744,16 @@ which is equivalent to:
...
@@ -7741,6 +7744,16 @@ which is equivalent to:
subtitles=filename=sub.srt
subtitles=filename=sub.srt
@end example
@end example
To render the default subtitles stream from file @file{video.mkv}, use:
@example
subtitles=video.mkv
@end example
To render the second subtitles stream from that file, use:
@example
subtitles=video.mkv:si=1
@end example
@section super2xsai
@section super2xsai
Scale the input by 2x and smooth using the Super2xSaI (Scale and
Scale the input by 2x and smooth using the Super2xSaI (Scale and
...
...
libavfilter/vf_subtitles.c
View file @
7a0e689c
...
@@ -51,6 +51,7 @@ typedef struct {
...
@@ -51,6 +51,7 @@ typedef struct {
ASS_Track
*
track
;
ASS_Track
*
track
;
char
*
filename
;
char
*
filename
;
char
*
charenc
;
char
*
charenc
;
int
stream_index
;
uint8_t
rgba_map
[
4
];
uint8_t
rgba_map
[
4
];
int
pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
original_w
,
original_h
;
int
original_w
,
original_h
;
...
@@ -247,7 +248,9 @@ AVFilter ff_vf_ass = {
...
@@ -247,7 +248,9 @@ AVFilter ff_vf_ass = {
static
const
AVOption
subtitles_options
[]
=
{
static
const
AVOption
subtitles_options
[]
=
{
COMMON_OPTIONS
COMMON_OPTIONS
{
"charenc"
,
"set input character encoding"
,
OFFSET
(
charenc
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
CHAR_MIN
,
CHAR_MAX
,
FLAGS
},
{
"charenc"
,
"set input character encoding"
,
OFFSET
(
charenc
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
CHAR_MIN
,
CHAR_MAX
,
FLAGS
},
{
"stream_index"
,
"set stream index"
,
OFFSET
(
stream_index
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
FLAGS
},
{
"si"
,
"set stream index"
,
OFFSET
(
stream_index
),
AV_OPT_TYPE_INT
,
{
.
i64
=
-
1
},
-
1
,
INT_MAX
,
FLAGS
},
{
NULL
},
{
NULL
},
};
};
...
@@ -279,6 +282,7 @@ AVFILTER_DEFINE_CLASS(subtitles);
...
@@ -279,6 +282,7 @@ AVFILTER_DEFINE_CLASS(subtitles);
static
av_cold
int
init_subtitles
(
AVFilterContext
*
ctx
)
static
av_cold
int
init_subtitles
(
AVFilterContext
*
ctx
)
{
{
int
j
,
ret
,
sid
;
int
j
,
ret
,
sid
;
int
k
=
0
;
AVDictionary
*
codec_opts
=
NULL
;
AVDictionary
*
codec_opts
=
NULL
;
AVFormatContext
*
fmt
=
NULL
;
AVFormatContext
*
fmt
=
NULL
;
AVCodecContext
*
dec_ctx
=
NULL
;
AVCodecContext
*
dec_ctx
=
NULL
;
...
@@ -309,7 +313,23 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
...
@@ -309,7 +313,23 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
goto
end
;
goto
end
;
/* Locate subtitles stream */
/* Locate subtitles stream */
ret
=
av_find_best_stream
(
fmt
,
AVMEDIA_TYPE_SUBTITLE
,
-
1
,
-
1
,
NULL
,
0
);
if
(
ass
->
stream_index
<
0
)
ret
=
av_find_best_stream
(
fmt
,
AVMEDIA_TYPE_SUBTITLE
,
-
1
,
-
1
,
NULL
,
0
);
else
{
ret
=
-
1
;
if
(
ass
->
stream_index
<
fmt
->
nb_streams
)
{
for
(
j
=
0
;
j
<
fmt
->
nb_streams
;
j
++
)
{
if
(
fmt
->
streams
[
j
]
->
codec
->
codec_type
==
AVMEDIA_TYPE_SUBTITLE
)
{
if
(
ass
->
stream_index
==
k
)
{
ret
=
j
;
break
;
}
k
++
;
}
}
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Unable to locate subtitle stream in %s
\n
"
,
av_log
(
ctx
,
AV_LOG_ERROR
,
"Unable to locate subtitle stream in %s
\n
"
,
ass
->
filename
);
ass
->
filename
);
...
...
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