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
afd257b4
Commit
afd257b4
authored
Mar 29, 2017
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/examples/filtering_video: switch to new decoding API
parent
b22c4d82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
filtering_video.c
doc/examples/filtering_video.c
+27
-19
No files found.
doc/examples/filtering_video.c
View file @
afd257b4
...
...
@@ -213,7 +213,6 @@ int main(int argc, char **argv)
AVPacket
packet
;
AVFrame
*
frame
=
av_frame_alloc
();
AVFrame
*
filt_frame
=
av_frame_alloc
();
int
got_frame
;
if
(
!
frame
||
!
filt_frame
)
{
perror
(
"Could not allocate frame"
);
...
...
@@ -238,33 +237,42 @@ int main(int argc, char **argv)
break
;
if
(
packet
.
stream_index
==
video_stream_index
)
{
got_frame
=
0
;
ret
=
avcodec_decode_video2
(
dec_ctx
,
frame
,
&
got_frame
,
&
packet
);
ret
=
avcodec_send_packet
(
dec_ctx
,
&
packet
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error
decoding video
\n
"
);
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error
while sending a packet to the decoder
\n
"
);
break
;
}
if
(
got_frame
)
{
frame
->
pts
=
av_frame_get_best_effort_timestamp
(
frame
);
/* push the decoded frame into the filtergraph */
if
(
av_buffersrc_add_frame_flags
(
buffersrc_ctx
,
frame
,
AV_BUFFERSRC_FLAG_KEEP_REF
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while feeding the filtergraph
\n
"
);
while
(
ret
>=
0
)
{
ret
=
avcodec_receive_frame
(
dec_ctx
,
frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
{
break
;
}
else
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while receiving a frame from the decoder
\n
"
);
goto
end
;
}
/* pull filtered frames from the filtergraph */
while
(
1
)
{
ret
=
av_buffersink_get_frame
(
buffersink_ctx
,
filt_frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
if
(
ret
>=
0
)
{
frame
->
pts
=
av_frame_get_best_effort_timestamp
(
frame
);
/* push the decoded frame into the filtergraph */
if
(
av_buffersrc_add_frame_flags
(
buffersrc_ctx
,
frame
,
AV_BUFFERSRC_FLAG_KEEP_REF
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while feeding the filtergraph
\n
"
);
break
;
if
(
ret
<
0
)
goto
end
;
display_frame
(
filt_frame
,
buffersink_ctx
->
inputs
[
0
]
->
time_base
);
av_frame_unref
(
filt_frame
);
}
/* pull filtered frames from the filtergraph */
while
(
1
)
{
ret
=
av_buffersink_get_frame
(
buffersink_ctx
,
filt_frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
break
;
if
(
ret
<
0
)
goto
end
;
display_frame
(
filt_frame
,
buffersink_ctx
->
inputs
[
0
]
->
time_base
);
av_frame_unref
(
filt_frame
);
}
av_frame_unref
(
frame
);
}
av_frame_unref
(
frame
);
}
}
av_packet_unref
(
&
packet
);
...
...
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