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
6e9ed7c7
Commit
6e9ed7c7
authored
Jan 28, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/output-example: more proper usage of the new API.
Passing the codec into avformat_new_stream() is preferred.
parent
44736387
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
output-example.c
libavformat/output-example.c
+20
-24
No files found.
libavformat/output-example.c
View file @
6e9ed7c7
...
...
@@ -64,16 +64,22 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
{
AVCodecContext
*
c
;
AVStream
*
st
;
AVCodec
*
codec
;
/* find the audio encoder */
codec
=
avcodec_find_encoder
(
codec_id
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"codec not found
\n
"
);
exit
(
1
);
}
st
=
avformat_new_stream
(
oc
,
NULL
);
st
=
avformat_new_stream
(
oc
,
codec
);
if
(
!
st
)
{
fprintf
(
stderr
,
"Could not alloc stream
\n
"
);
exit
(
1
);
}
c
=
st
->
codec
;
c
->
codec_id
=
codec_id
;
c
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
/* put sample parameters */
c
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
...
...
@@ -91,19 +97,11 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id)
static
void
open_audio
(
AVFormatContext
*
oc
,
AVStream
*
st
)
{
AVCodecContext
*
c
;
AVCodec
*
codec
;
c
=
st
->
codec
;
/* find the audio encoder */
codec
=
avcodec_find_encoder
(
c
->
codec_id
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"codec not found
\n
"
);
exit
(
1
);
}
/* open it */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
if
(
avcodec_open2
(
c
,
NULL
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"could not open codec
\n
"
);
exit
(
1
);
}
...
...
@@ -199,16 +197,22 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum CodecID codec_id)
{
AVCodecContext
*
c
;
AVStream
*
st
;
AVCodec
*
codec
;
/* find the video encoder */
codec
=
avcodec_find_encoder
(
codec_id
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"codec not found
\n
"
);
exit
(
1
);
}
st
=
avformat_new_stream
(
oc
,
NULL
);
st
=
avformat_new_stream
(
oc
,
codec
);
if
(
!
st
)
{
fprintf
(
stderr
,
"Could not alloc stream
\n
"
);
exit
(
1
);
}
c
=
st
->
codec
;
c
->
codec_id
=
codec_id
;
c
->
codec_type
=
AVMEDIA_TYPE_VIDEO
;
/* put sample parameters */
c
->
bit_rate
=
400000
;
...
...
@@ -262,20 +266,12 @@ static AVFrame *alloc_picture(enum PixelFormat pix_fmt, int width, int height)
static
void
open_video
(
AVFormatContext
*
oc
,
AVStream
*
st
)
{
AVCodec
*
codec
;
AVCodecContext
*
c
;
c
=
st
->
codec
;
/* find the video encoder */
codec
=
avcodec_find_encoder
(
c
->
codec_id
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"codec not found
\n
"
);
exit
(
1
);
}
/* open the codec */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
if
(
avcodec_open2
(
c
,
NULL
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"could not open codec
\n
"
);
exit
(
1
);
}
...
...
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