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
630902a1
Commit
630902a1
authored
Jul 06, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: factor out initializing input streams.
parent
ddf5ef02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
46 deletions
+47
-46
avconv.c
avconv.c
+47
-46
No files found.
avconv.c
View file @
630902a1
...
...
@@ -1816,6 +1816,48 @@ static void print_sdp(OutputFile *output_files, int n)
av_freep
(
&
avc
);
}
static
int
init_input_stream
(
int
ist_index
,
OutputStream
*
output_streams
,
int
nb_output_streams
,
char
*
error
,
int
error_len
)
{
int
i
;
InputStream
*
ist
=
&
input_streams
[
ist_index
];
if
(
ist
->
decoding_needed
)
{
AVCodec
*
codec
=
ist
->
dec
;
if
(
!
codec
)
codec
=
avcodec_find_decoder
(
ist
->
st
->
codec
->
codec_id
);
if
(
!
codec
)
{
snprintf
(
error
,
sizeof
(
error
),
"Decoder (codec id %d) not found for input stream #%d.%d"
,
ist
->
st
->
codec
->
codec_id
,
ist
->
file_index
,
ist
->
st
->
index
);
return
AVERROR
(
EINVAL
);
}
/* update requested sample format for the decoder based on the
corresponding encoder sample format */
for
(
i
=
0
;
i
<
nb_output_streams
;
i
++
)
{
OutputStream
*
ost
=
&
output_streams
[
i
];
if
(
ost
->
source_index
==
ist_index
)
{
update_sample_fmt
(
ist
->
st
->
codec
,
codec
,
ost
->
st
->
codec
);
break
;
}
}
if
(
avcodec_open2
(
ist
->
st
->
codec
,
codec
,
&
ist
->
opts
)
<
0
)
{
snprintf
(
error
,
sizeof
(
error
),
"Error while opening decoder for input stream #%d.%d"
,
ist
->
file_index
,
ist
->
st
->
index
);
return
AVERROR
(
EINVAL
);
}
assert_codec_experimental
(
ist
->
st
->
codec
,
0
);
assert_avoptions
(
ist
->
opts
);
}
ist
->
pts
=
ist
->
st
->
avg_frame_rate
.
num
?
-
ist
->
st
->
codec
->
has_b_frames
*
AV_TIME_BASE
/
av_q2d
(
ist
->
st
->
avg_frame_rate
)
:
0
;
ist
->
next_pts
=
AV_NOPTS_VALUE
;
init_pts_correction
(
&
ist
->
pts_ctx
);
ist
->
is_start
=
1
;
return
0
;
}
/*
* The following code is the main loop of the file converter
*/
...
...
@@ -1824,7 +1866,7 @@ static int transcode(OutputFile *output_files,
InputFile
*
input_files
,
int
nb_input_files
)
{
int
ret
=
0
,
i
,
j
;
int
ret
=
0
,
i
;
AVFormatContext
*
is
,
*
os
;
AVCodecContext
*
codec
,
*
icodec
;
OutputStream
*
ost
;
...
...
@@ -2118,51 +2160,10 @@ static int transcode(OutputFile *output_files,
}
}
/* open each decoder */
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
{
ist
=
&
input_streams
[
i
];
if
(
ist
->
decoding_needed
)
{
AVCodec
*
codec
=
ist
->
dec
;
if
(
!
codec
)
codec
=
avcodec_find_decoder
(
ist
->
st
->
codec
->
codec_id
);
if
(
!
codec
)
{
snprintf
(
error
,
sizeof
(
error
),
"Decoder (codec id %d) not found for input stream #%d.%d"
,
ist
->
st
->
codec
->
codec_id
,
ist
->
file_index
,
ist
->
st
->
index
);
ret
=
AVERROR
(
EINVAL
);
goto
dump_format
;
}
/* update requested sample format for the decoder based on the
corresponding encoder sample format */
for
(
j
=
0
;
j
<
nb_output_streams
;
j
++
)
{
ost
=
&
output_streams
[
j
];
if
(
ost
->
source_index
==
i
)
{
update_sample_fmt
(
ist
->
st
->
codec
,
codec
,
ost
->
st
->
codec
);
break
;
}
}
if
(
avcodec_open2
(
ist
->
st
->
codec
,
codec
,
&
ist
->
opts
)
<
0
)
{
snprintf
(
error
,
sizeof
(
error
),
"Error while opening decoder for input stream #%d.%d"
,
ist
->
file_index
,
ist
->
st
->
index
);
ret
=
AVERROR
(
EINVAL
);
goto
dump_format
;
}
assert_codec_experimental
(
ist
->
st
->
codec
,
0
);
assert_avoptions
(
ost
->
opts
);
}
}
/* init pts */
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
{
AVStream
*
st
;
ist
=
&
input_streams
[
i
];
st
=
ist
->
st
;
ist
->
pts
=
st
->
avg_frame_rate
.
num
?
-
st
->
codec
->
has_b_frames
*
AV_TIME_BASE
/
av_q2d
(
st
->
avg_frame_rate
)
:
0
;
ist
->
next_pts
=
AV_NOPTS_VALUE
;
init_pts_correction
(
&
ist
->
pts_ctx
);
ist
->
is_start
=
1
;
}
/* init input streams */
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
if
((
ret
=
init_input_stream
(
i
,
output_streams
,
nb_output_streams
,
error
,
sizeof
(
error
))
<
0
))
goto
dump_format
;
/* open files and write file headers */
for
(
i
=
0
;
i
<
nb_output_files
;
i
++
)
{
...
...
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