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
6d8b3263
Commit
6d8b3263
authored
Sep 09, 2012
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffmpeg: use PTS from the AVSubtitle structure.
parent
37bbc9eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
ffmpeg.c
ffmpeg.c
+7
-10
ffmpeg.h
ffmpeg.h
+0
-1
No files found.
ffmpeg.c
View file @
6d8b3263
...
...
@@ -693,15 +693,15 @@ static void pre_process_video_frame(InputStream *ist, AVPicture *picture, void *
static
void
do_subtitle_out
(
AVFormatContext
*
s
,
OutputStream
*
ost
,
InputStream
*
ist
,
AVSubtitle
*
sub
,
int64_t
pts
)
AVSubtitle
*
sub
)
{
int
subtitle_out_max_size
=
1024
*
1024
;
int
subtitle_out_size
,
nb
,
i
;
AVCodecContext
*
enc
;
AVPacket
pkt
;
int64_t
pts
;
if
(
pts
==
AV_NOPTS_VALUE
)
{
if
(
sub
->
pts
==
AV_NOPTS_VALUE
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Subtitle packets must have a pts
\n
"
);
if
(
exit_on_error
)
exit_program
(
1
);
...
...
@@ -723,8 +723,7 @@ static void do_subtitle_out(AVFormatContext *s,
nb
=
1
;
/* shift timestamp to honor -ss and make check_recording_time() work with -t */
pts
=
av_rescale_q
(
pts
,
ist
->
st
->
time_base
,
AV_TIME_BASE_Q
)
-
output_files
[
ost
->
file_index
]
->
start_time
;
pts
=
sub
->
pts
-
output_files
[
ost
->
file_index
]
->
start_time
;
for
(
i
=
0
;
i
<
nb
;
i
++
)
{
ost
->
sync_opts
=
av_rescale_q
(
pts
,
AV_TIME_BASE_Q
,
enc
->
time_base
);
if
(
!
check_recording_time
(
ost
))
...
...
@@ -1657,7 +1656,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
static
int
transcode_subtitles
(
InputStream
*
ist
,
AVPacket
*
pkt
,
int
*
got_output
)
{
AVSubtitle
subtitle
;
int64_t
pts
=
pkt
->
pts
;
int
i
,
ret
=
avcodec_decode_subtitle2
(
ist
->
st
->
codec
,
&
subtitle
,
got_output
,
pkt
);
if
(
ret
<
0
||
!*
got_output
)
{
...
...
@@ -1668,8 +1666,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
if
(
ist
->
fix_sub_duration
)
{
if
(
ist
->
prev_sub
.
got_output
)
{
int
end
=
av_rescale
_q
(
pts
-
ist
->
prev_sub
.
pts
,
ist
->
st
->
time_base
,
(
AVRational
){
1
,
1000
}
);
int
end
=
av_rescale
(
subtitle
.
pts
-
ist
->
prev_sub
.
subtitle
.
pts
,
1000
,
AV_TIME_BASE
);
if
(
end
<
ist
->
prev_sub
.
subtitle
.
end_display_time
)
{
av_log
(
ist
->
st
->
codec
,
AV_LOG_DEBUG
,
"Subtitle duration reduced from %d to %d
\n
"
,
...
...
@@ -1677,7 +1675,6 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
ist
->
prev_sub
.
subtitle
.
end_display_time
=
end
;
}
}
FFSWAP
(
int64_t
,
pts
,
ist
->
prev_sub
.
pts
);
FFSWAP
(
int
,
*
got_output
,
ist
->
prev_sub
.
got_output
);
FFSWAP
(
int
,
ret
,
ist
->
prev_sub
.
ret
);
FFSWAP
(
AVSubtitle
,
subtitle
,
ist
->
prev_sub
.
subtitle
);
...
...
@@ -1696,7 +1693,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
if
(
!
check_output_constraints
(
ist
,
ost
)
||
!
ost
->
encoding_needed
)
continue
;
do_subtitle_out
(
output_files
[
ost
->
file_index
]
->
ctx
,
ost
,
ist
,
&
subtitle
,
pts
);
do_subtitle_out
(
output_files
[
ost
->
file_index
]
->
ctx
,
ost
,
ist
,
&
subtitle
);
}
avsubtitle_free
(
&
subtitle
);
...
...
ffmpeg.h
View file @
6d8b3263
...
...
@@ -232,7 +232,6 @@ typedef struct InputStream {
int
fix_sub_duration
;
struct
{
/* previous decoded subtitle and related variables */
int64_t
pts
;
int
got_output
;
int
ret
;
AVSubtitle
subtitle
;
...
...
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