Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
beb5d8f0
Commit
beb5d8f0
authored
12 years ago
by
Nicolas George
Browse files
Options
Downloads
Patches
Plain Diff
ffmpeg: accept "chapters" as forced key frames.
Allow to force a key frame at the beginning of each chapter.
parent
93815219
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/ffmpeg.texi
+9
-1
9 additions, 1 deletion
doc/ffmpeg.texi
ffmpeg.c
+45
-7
45 additions, 7 deletions
ffmpeg.c
with
54 additions
and
8 deletions
doc/ffmpeg.texi
+
9
−
1
View file @
beb5d8f0
...
...
@@ -555,9 +555,17 @@ Deprecated see -bsf
@item -force
_
key
_
frames[:@var
{
stream
_
specifier
}
] @var
{
time
}
[,@var
{
time
}
...] (@emph
{
output,per-stream
}
)
Force key frames at the specified timestamps, more precisely at the first
frames after each specified time.
If one of the times is "@code
{
chapters
}
[@var
{
delta
}
]", it is expanded into
the time of the beginning of all chapters in the file, shifted by
@var
{
delta
}
, expressed as a time in seconds.
This option can be useful to ensure that a seek point is present at a
chapter mark or any other designated place in the output file.
The timestamps must be specified in ascending order.
For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
before the beginning of every chapter:
@example
-force
_
key
_
frames 0:05:00,chapters-0.1
@end example
@item -copyinkf[:@var
{
stream
_
specifier
}
] (@emph
{
output,per-stream
}
)
When doing stream copy, copy also non-key frames found at the
...
...
This diff is collapsed.
Click to expand it.
ffmpeg.c
+
45
−
7
View file @
beb5d8f0
...
...
@@ -1931,19 +1931,25 @@ static InputStream *get_input_stream(OutputStream *ost)
return
NULL
;
}
static
int
compare_int64
(
const
void
*
a
,
const
void
*
b
)
{
int64_t
va
=
*
(
int64_t
*
)
a
,
vb
=
*
(
int64_t
*
)
b
;
return
va
<
vb
?
-
1
:
va
>
vb
?
+
1
:
0
;
}
static
void
parse_forced_key_frames
(
char
*
kf
,
OutputStream
*
ost
,
AVCodecContext
*
avctx
)
{
char
*
p
;
int
n
=
1
,
i
;
int64_t
t
;
int
n
=
1
,
i
,
size
,
index
=
0
;
int64_t
t
,
*
pts
;
for
(
p
=
kf
;
*
p
;
p
++
)
if
(
*
p
==
','
)
n
++
;
ost
->
forced_kf_count
=
n
;
ost
->
forced_kf_
pts
=
av_malloc
(
sizeof
(
*
ost
->
forced_kf_
pts
)
*
n
);
if
(
!
ost
->
forced_kf_
pts
)
{
size
=
n
;
pts
=
av_malloc
(
sizeof
(
*
pts
)
*
size
);
if
(
!
pts
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Could not allocate forced key frames array.
\n
"
);
exit
(
1
);
}
...
...
@@ -1955,11 +1961,43 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost,
if
(
next
)
*
next
++
=
0
;
t
=
parse_time_or_die
(
"force_key_frames"
,
p
,
1
);
ost
->
forced_kf_pts
[
i
]
=
av_rescale_q
(
t
,
AV_TIME_BASE_Q
,
avctx
->
time_base
);
if
(
!
memcmp
(
p
,
"chapters"
,
8
))
{
AVFormatContext
*
avf
=
output_files
[
ost
->
file_index
]
->
ctx
;
int
j
;
if
(
avf
->
nb_chapters
>
INT_MAX
-
size
||
!
(
pts
=
av_realloc_f
(
pts
,
size
+=
avf
->
nb_chapters
-
1
,
sizeof
(
*
pts
))))
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Could not allocate forced key frames array.
\n
"
);
exit
(
1
);
}
t
=
p
[
8
]
?
parse_time_or_die
(
"force_key_frames"
,
p
+
8
,
1
)
:
0
;
t
=
av_rescale_q
(
t
,
AV_TIME_BASE_Q
,
avctx
->
time_base
);
for
(
j
=
0
;
j
<
avf
->
nb_chapters
;
j
++
)
{
AVChapter
*
c
=
avf
->
chapters
[
j
];
av_assert1
(
index
<
size
);
pts
[
index
++
]
=
av_rescale_q
(
c
->
start
,
c
->
time_base
,
avctx
->
time_base
)
+
t
;
}
}
else
{
t
=
parse_time_or_die
(
"force_key_frames"
,
p
,
1
);
av_assert1
(
index
<
size
);
pts
[
index
++
]
=
av_rescale_q
(
t
,
AV_TIME_BASE_Q
,
avctx
->
time_base
);
}
p
=
next
;
}
av_assert0
(
index
==
size
);
qsort
(
pts
,
size
,
sizeof
(
*
pts
),
compare_int64
);
ost
->
forced_kf_count
=
size
;
ost
->
forced_kf_pts
=
pts
;
}
static
void
report_new_stream
(
int
input_index
,
AVPacket
*
pkt
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment