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
70b671a2
Commit
70b671a2
authored
Sep 13, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/decoding_encoding: apply various message log fixes
parent
8ad54a44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
decoding_encoding.c
doc/examples/decoding_encoding.c
+26
-26
No files found.
doc/examples/decoding_encoding.c
View file @
70b671a2
...
...
@@ -116,7 +116,7 @@ static void audio_encode_example(const char *filename)
/* find the MP2 encoder */
codec
=
avcodec_find_encoder
(
AV_CODEC_ID_MP2
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"
c
odec not found
\n
"
);
fprintf
(
stderr
,
"
C
odec not found
\n
"
);
exit
(
1
);
}
...
...
@@ -128,7 +128,7 @@ static void audio_encode_example(const char *filename)
/* check that the encoder supports s16 pcm input */
c
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
if
(
!
check_sample_fmt
(
codec
,
c
->
sample_fmt
))
{
fprintf
(
stderr
,
"
encoder does not suppor
t %s"
,
fprintf
(
stderr
,
"
Encoder does not support sample forma
t %s"
,
av_get_sample_fmt_name
(
c
->
sample_fmt
));
exit
(
1
);
}
...
...
@@ -140,20 +140,20 @@ static void audio_encode_example(const char *filename)
/* open it */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"
c
ould not open codec
\n
"
);
fprintf
(
stderr
,
"
C
ould not open codec
\n
"
);
exit
(
1
);
}
f
=
fopen
(
filename
,
"wb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"
c
ould not open %s
\n
"
,
filename
);
fprintf
(
stderr
,
"
C
ould not open %s
\n
"
,
filename
);
exit
(
1
);
}
/* frame containing input raw audio */
frame
=
avcodec_alloc_frame
();
if
(
!
frame
)
{
fprintf
(
stderr
,
"
c
ould not allocate audio frame
\n
"
);
fprintf
(
stderr
,
"
C
ould not allocate audio frame
\n
"
);
exit
(
1
);
}
...
...
@@ -167,7 +167,7 @@ static void audio_encode_example(const char *filename)
c
->
sample_fmt
,
0
);
samples
=
av_malloc
(
buffer_size
);
if
(
!
samples
)
{
fprintf
(
stderr
,
"
c
ould not allocate %d bytes for samples buffer
\n
"
,
fprintf
(
stderr
,
"
C
ould not allocate %d bytes for samples buffer
\n
"
,
buffer_size
);
exit
(
1
);
}
...
...
@@ -175,7 +175,7 @@ static void audio_encode_example(const char *filename)
ret
=
avcodec_fill_audio_frame
(
frame
,
c
->
channels
,
c
->
sample_fmt
,
(
const
uint8_t
*
)
samples
,
buffer_size
,
0
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
c
ould not setup audio frame
\n
"
);
fprintf
(
stderr
,
"
C
ould not setup audio frame
\n
"
);
exit
(
1
);
}
...
...
@@ -197,7 +197,7 @@ static void audio_encode_example(const char *filename)
/* encode the samples */
ret
=
avcodec_encode_audio2
(
c
,
&
pkt
,
frame
,
&
got_output
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
e
rror encoding audio frame
\n
"
);
fprintf
(
stderr
,
"
E
rror encoding audio frame
\n
"
);
exit
(
1
);
}
if
(
got_output
)
{
...
...
@@ -210,7 +210,7 @@ static void audio_encode_example(const char *filename)
for
(
got_output
=
1
;
got_output
;
i
++
)
{
ret
=
avcodec_encode_audio2
(
c
,
&
pkt
,
NULL
,
&
got_output
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
e
rror encoding frame
\n
"
);
fprintf
(
stderr
,
"
E
rror encoding frame
\n
"
);
exit
(
1
);
}
...
...
@@ -247,7 +247,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
/* find the mpeg audio decoder */
codec
=
avcodec_find_decoder
(
AV_CODEC_ID_MP2
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"
c
odec not found
\n
"
);
fprintf
(
stderr
,
"
C
odec not found
\n
"
);
exit
(
1
);
}
...
...
@@ -255,13 +255,13 @@ static void audio_decode_example(const char *outfilename, const char *filename)
/* open it */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"
c
ould not open codec
\n
"
);
fprintf
(
stderr
,
"
C
ould not open codec
\n
"
);
exit
(
1
);
}
f
=
fopen
(
filename
,
"rb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"
c
ould not open %s
\n
"
,
filename
);
fprintf
(
stderr
,
"
C
ould not open %s
\n
"
,
filename
);
exit
(
1
);
}
outfile
=
fopen
(
outfilename
,
"wb"
);
...
...
@@ -279,7 +279,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
if
(
!
decoded_frame
)
{
if
(
!
(
decoded_frame
=
avcodec_alloc_frame
()))
{
fprintf
(
stderr
,
"
out of memory
\n
"
);
fprintf
(
stderr
,
"
Could not allocate audio frame
\n
"
);
exit
(
1
);
}
}
else
...
...
@@ -341,7 +341,7 @@ static void video_encode_example(const char *filename, int codec_id)
/* find the mpeg1 video encoder */
codec
=
avcodec_find_encoder
(
codec_id
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"
c
odec not found
\n
"
);
fprintf
(
stderr
,
"
C
odec not found
\n
"
);
exit
(
1
);
}
...
...
@@ -363,13 +363,13 @@ static void video_encode_example(const char *filename, int codec_id)
/* open it */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"
c
ould not open codec
\n
"
);
fprintf
(
stderr
,
"
C
ould not open codec
\n
"
);
exit
(
1
);
}
f
=
fopen
(
filename
,
"wb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"
c
ould not open %s
\n
"
,
filename
);
fprintf
(
stderr
,
"
C
ould not open %s
\n
"
,
filename
);
exit
(
1
);
}
...
...
@@ -387,7 +387,7 @@ static void video_encode_example(const char *filename, int codec_id)
ret
=
av_image_alloc
(
picture
->
data
,
picture
->
linesize
,
c
->
width
,
c
->
height
,
c
->
pix_fmt
,
32
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
could not alloc
raw picture buffer
\n
"
);
fprintf
(
stderr
,
"
Could not allocate
raw picture buffer
\n
"
);
exit
(
1
);
}
...
...
@@ -419,12 +419,12 @@ static void video_encode_example(const char *filename, int codec_id)
/* encode the image */
ret
=
avcodec_encode_video2
(
c
,
&
pkt
,
picture
,
&
got_output
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
e
rror encoding frame
\n
"
);
fprintf
(
stderr
,
"
E
rror encoding frame
\n
"
);
exit
(
1
);
}
if
(
got_output
)
{
printf
(
"
encoding
frame %3d (size=%5d)
\n
"
,
i
,
pkt
.
size
);
printf
(
"
Write
frame %3d (size=%5d)
\n
"
,
i
,
pkt
.
size
);
fwrite
(
pkt
.
data
,
1
,
pkt
.
size
,
f
);
av_free_packet
(
&
pkt
);
}
...
...
@@ -436,12 +436,12 @@ static void video_encode_example(const char *filename, int codec_id)
ret
=
avcodec_encode_video2
(
c
,
&
pkt
,
NULL
,
&
got_output
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"
e
rror encoding frame
\n
"
);
fprintf
(
stderr
,
"
E
rror encoding frame
\n
"
);
exit
(
1
);
}
if
(
got_output
)
{
printf
(
"
w
rite frame %3d (size=%5d)
\n
"
,
i
,
pkt
.
size
);
printf
(
"
W
rite frame %3d (size=%5d)
\n
"
,
i
,
pkt
.
size
);
fwrite
(
pkt
.
data
,
1
,
pkt
.
size
,
f
);
av_free_packet
(
&
pkt
);
}
...
...
@@ -496,7 +496,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
/* find the mpeg1 video decoder */
codec
=
avcodec_find_decoder
(
AV_CODEC_ID_MPEG1VIDEO
);
if
(
!
codec
)
{
fprintf
(
stderr
,
"
c
odec not found
\n
"
);
fprintf
(
stderr
,
"
C
odec not found
\n
"
);
exit
(
1
);
}
...
...
@@ -510,7 +510,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
/* open it */
if
(
avcodec_open2
(
c
,
codec
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"
c
ould not open codec
\n
"
);
fprintf
(
stderr
,
"
C
ould not open codec
\n
"
);
exit
(
1
);
}
...
...
@@ -518,7 +518,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
f
=
fopen
(
filename
,
"rb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"
c
ould not open %s
\n
"
,
filename
);
fprintf
(
stderr
,
"
C
ould not open %s
\n
"
,
filename
);
exit
(
1
);
}
...
...
@@ -557,7 +557,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
exit
(
1
);
}
if
(
got_picture
)
{
printf
(
"
s
aving frame %3d
\n
"
,
frame
);
printf
(
"
S
aving frame %3d
\n
"
,
frame
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
...
...
@@ -579,7 +579,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
avpkt
.
size
=
0
;
len
=
avcodec_decode_video2
(
c
,
picture
,
&
got_picture
,
&
avpkt
);
if
(
got_picture
)
{
printf
(
"
s
aving last frame %3d
\n
"
,
frame
);
printf
(
"
S
aving last frame %3d
\n
"
,
frame
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
...
...
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