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
864e8adc
Commit
864e8adc
authored
Aug 21, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/muxing: update to the new avcodec_encode_video2() API
parent
5ac603df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
muxing.c
doc/examples/muxing.c
+15
-9
No files found.
doc/examples/muxing.c
View file @
864e8adc
...
...
@@ -313,7 +313,7 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
static
void
write_video_frame
(
AVFormatContext
*
oc
,
AVStream
*
st
)
{
int
out_size
,
ret
;
int
ret
;
AVCodecContext
*
c
;
static
struct
SwsContext
*
img_convert_ctx
;
...
...
@@ -362,13 +362,21 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
ret
=
av_interleaved_write_frame
(
oc
,
&
pkt
);
}
else
{
/* encode the image */
out_size
=
avcodec_encode_video
(
c
,
video_outbuf
,
video_outbuf_size
,
picture
);
/* If size is zero, it means the image was buffered. */
if
(
out_size
>
0
)
{
AVPacket
pkt
;
int
got_output
;
av_init_packet
(
&
pkt
);
pkt
.
data
=
NULL
;
// packet data will be allocated by the encoder
pkt
.
size
=
0
;
ret
=
avcodec_encode_video2
(
c
,
&
pkt
,
picture
,
&
got_output
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"error encoding frame
\n
"
);
exit
(
1
);
}
/* If size is zero, it means the image was buffered. */
if
(
got_output
)
{
if
(
c
->
coded_frame
->
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
c
->
coded_frame
->
pts
,
c
->
time_base
,
st
->
time_base
);
...
...
@@ -376,8 +384,6 @@ static void write_video_frame(AVFormatContext *oc, AVStream *st)
pkt
.
flags
|=
AV_PKT_FLAG_KEY
;
pkt
.
stream_index
=
st
->
index
;
pkt
.
data
=
video_outbuf
;
pkt
.
size
=
out_size
;
/* Write the compressed frame to the media file. */
ret
=
av_interleaved_write_frame
(
oc
,
&
pkt
);
...
...
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