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
728ea23c
Commit
728ea23c
authored
Oct 19, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/decode_video: switch to the new decoding API
parent
f78d360b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
decode_video.c
doc/examples/decode_video.c
+23
-20
No files found.
doc/examples/decode_video.c
View file @
728ea23c
...
...
@@ -54,26 +54,31 @@ static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,
const
char
*
filename
)
{
char
buf
[
1024
];
int
ret
,
got_picture
;
int
ret
;
ret
=
avcodec_send_packet
(
dec_ctx
,
pkt
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error sending a packet for decoding
\n
"
);
exit
(
1
);
}
while
(
pkt
->
size
>
0
)
{
ret
=
avcodec_decode_video2
(
dec_ctx
,
frame
,
&
got_picture
,
pkt
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error while decoding frame %d
\n
"
,
dec_ctx
->
frame_number
);
while
(
ret
>=
0
)
{
ret
=
avcodec_receive_frame
(
dec_ctx
,
frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
return
;
else
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error during decoding
\n
"
);
exit
(
1
);
}
if
(
got_picture
)
{
printf
(
"saving frame %3d
\n
"
,
dec_ctx
->
frame_number
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
free it */
snprintf
(
buf
,
sizeof
(
buf
),
filename
,
dec_ctx
->
frame_number
);
pgm_save
(
frame
->
data
[
0
],
frame
->
linesize
[
0
],
frame
->
width
,
frame
->
height
,
buf
);
}
pkt
->
size
-=
ret
;
pkt
->
data
+=
ret
;
printf
(
"saving frame %3d
\n
"
,
dec_ctx
->
frame_number
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
free it */
snprintf
(
buf
,
sizeof
(
buf
),
filename
,
dec_ctx
->
frame_number
);
pgm_save
(
frame
->
data
[
0
],
frame
->
linesize
[
0
],
frame
->
width
,
frame
->
height
,
buf
);
}
}
...
...
@@ -161,9 +166,7 @@ int main(int argc, char **argv)
}
/* flush the decoder */
avpkt
.
data
=
NULL
;
avpkt
.
size
=
0
;
decode
(
c
,
picture
,
&
avpkt
,
outfilename
);
decode
(
c
,
picture
,
NULL
,
outfilename
);
fclose
(
f
);
...
...
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