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
6133149e
Commit
6133149e
authored
Oct 15, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/muxing: add missing error checks
parent
e56b3a5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
muxing.c
doc/examples/muxing.c
+11
-2
No files found.
doc/examples/muxing.c
View file @
6133149e
...
@@ -115,6 +115,10 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)
...
@@ -115,6 +115,10 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)
samples
=
av_malloc
(
audio_input_frame_size
*
samples
=
av_malloc
(
audio_input_frame_size
*
av_get_bytes_per_sample
(
c
->
sample_fmt
)
*
av_get_bytes_per_sample
(
c
->
sample_fmt
)
*
c
->
channels
);
c
->
channels
);
if
(
!
samples
)
{
fprintf
(
stderr
,
"Could not allocate audio samples buffer
\n
"
);
exit
(
1
);
}
}
}
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
...
@@ -139,7 +143,7 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
...
@@ -139,7 +143,7 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
AVCodecContext
*
c
;
AVCodecContext
*
c
;
AVPacket
pkt
=
{
0
};
// data and size must be 0;
AVPacket
pkt
=
{
0
};
// data and size must be 0;
AVFrame
*
frame
=
avcodec_alloc_frame
();
AVFrame
*
frame
=
avcodec_alloc_frame
();
int
got_packet
;
int
got_packet
,
ret
;
av_init_packet
(
&
pkt
);
av_init_packet
(
&
pkt
);
c
=
st
->
codec
;
c
=
st
->
codec
;
...
@@ -152,7 +156,12 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
...
@@ -152,7 +156,12 @@ static void write_audio_frame(AVFormatContext *oc, AVStream *st)
av_get_bytes_per_sample
(
c
->
sample_fmt
)
*
av_get_bytes_per_sample
(
c
->
sample_fmt
)
*
c
->
channels
,
1
);
c
->
channels
,
1
);
avcodec_encode_audio2
(
c
,
&
pkt
,
frame
,
&
got_packet
);
ret
=
avcodec_encode_audio2
(
c
,
&
pkt
,
frame
,
&
got_packet
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error encoding audio frame
\n
"
);
exit
(
1
);
}
if
(
!
got_packet
)
if
(
!
got_packet
)
return
;
return
;
...
...
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