Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
preview-generator
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
mediaflix
preview-generator
Commits
65e7174d
Verified
Commit
65e7174d
authored
2 weeks ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Avoid decoding packets with no relevant timestamps
parent
91e04057
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/ffmpeg_api/src/api.rs
+4
-0
4 additions, 0 deletions
lib/ffmpeg_api/src/api.rs
src/lib.rs
+43
-25
43 additions, 25 deletions
src/lib.rs
with
47 additions
and
25 deletions
lib/ffmpeg_api/src/api.rs
+
4
−
0
View file @
65e7174d
...
@@ -223,6 +223,10 @@ impl AVPacket {
...
@@ -223,6 +223,10 @@ impl AVPacket {
unsafe
{
self
.base
.as_ref
()
}
.unwrap_or_else
(||
panic!
(
"AVPacket base unexpectedly null"
))
unsafe
{
self
.base
.as_ref
()
}
.unwrap_or_else
(||
panic!
(
"AVPacket base unexpectedly null"
))
}
}
pub
fn
duration
(
&
self
)
->
i64
{
self
.as_ref
()
.duration
}
pub
fn
pts
(
&
self
)
->
i64
{
pub
fn
pts
(
&
self
)
->
i64
{
self
.as_ref
()
.pts
self
.as_ref
()
.pts
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
43
−
25
View file @
65e7174d
...
@@ -91,6 +91,23 @@ pub fn extract(
...
@@ -91,6 +91,23 @@ pub fn extract(
while
avformat_context
.read_frame
(
&
mut
packet
)
.is_ok
()
{
while
avformat_context
.read_frame
(
&
mut
packet
)
.is_ok
()
{
if
packet
.stream_index
()
==
index
{
if
packet
.stream_index
()
==
index
{
let
duration
=
media_time
::
MediaTime
::
from_rational
(
packet
.duration
(),
&
time_base
)
?
;
let
start
=
media_time
::
MediaTime
::
from_rational
(
packet
.pts
(),
&
time_base
)
?
;
let
end
=
start
+
duration
;
let
mut
skip
=
true
;
if
let
Some
(
spritesheet_manager
)
=
&
mut
spritesheet_manager
{
if
spritesheet_manager
.fulfils_frame_interval
(
end
)
{
skip
=
false
;
}
}
if
let
Some
(
timelens_manager
)
=
&
mut
timelens_manager
{
if
timelens_manager
.fulfils_frame_interval
(
end
)
{
skip
=
false
;
}
}
if
!
skip
{
codec_context
codec_context
.in_packet
(
&
mut
packet
)
.in_packet
(
&
mut
packet
)
.map_err
(|
error
|
format_err!
(
"Could not load packet: {}"
,
error
))
?
;
.map_err
(|
error
|
format_err!
(
"Could not load packet: {}"
,
error
))
?
;
...
@@ -124,6 +141,7 @@ pub fn extract(
...
@@ -124,6 +141,7 @@ pub fn extract(
}
}
}
}
}
}
}
if
let
Some
(
spritesheet_manager
)
=
&
mut
spritesheet_manager
{
if
let
Some
(
spritesheet_manager
)
=
&
mut
spritesheet_manager
{
spritesheet_manager
.end_frame
(
duration
);
spritesheet_manager
.end_frame
(
duration
);
...
...
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