Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
8e37038a
Commit
8e37038a
authored
Feb 01, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: switch to avcodec_encode_video2().
parent
06484d0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
35 deletions
+16
-35
avconv.c
avconv.c
+16
-35
No files found.
avconv.c
View file @
8e37038a
...
...
@@ -1292,9 +1292,6 @@ static void do_subtitle_out(AVFormatContext *s,
}
}
static
int
bit_buffer_size
=
1024
*
256
;
static
uint8_t
*
bit_buffer
=
NULL
;
#if !CONFIG_AVFILTER
static
void
do_video_resample
(
OutputStream
*
ost
,
InputStream
*
ist
,
...
...
@@ -1412,6 +1409,8 @@ static void do_video_out(AVFormatContext *s,
for
(
i
=
0
;
i
<
nb_frames
;
i
++
)
{
AVPacket
pkt
;
av_init_packet
(
&
pkt
);
pkt
.
data
=
NULL
;
pkt
.
size
=
0
;
if
(
!
check_recording_time
(
ost
))
return
;
...
...
@@ -1430,6 +1429,7 @@ static void do_video_out(AVFormatContext *s,
write_frame
(
s
,
&
pkt
,
ost
);
}
else
{
int
got_packet
;
AVFrame
big_picture
;
big_picture
=
*
final_picture
;
...
...
@@ -1454,22 +1454,18 @@ static void do_video_out(AVFormatContext *s,
big_picture
.
pict_type
=
AV_PICTURE_TYPE_I
;
ost
->
forced_kf_index
++
;
}
ret
=
avcodec_encode_video
(
enc
,
bit_buffer
,
bit_buffer_size
,
&
big_picture
);
ret
=
avcodec_encode_video2
(
enc
,
&
pkt
,
&
big_picture
,
&
got_packet
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Video encoding failed
\n
"
);
exit_program
(
1
);
}
if
(
ret
>
0
)
{
pkt
.
data
=
bit_buffer
;
pkt
.
size
=
ret
;
if
(
enc
->
coded_frame
->
p
ts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
enc
->
coded_frame
->
p
ts
,
enc
->
time_base
,
ost
->
st
->
time_base
);
if
(
got_packet
)
{
if
(
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
pkt
.
pts
,
enc
->
time_base
,
ost
->
st
->
time_base
)
;
if
(
pkt
.
d
ts
!=
AV_NOPTS_VALUE
)
pkt
.
dts
=
av_rescale_q
(
pkt
.
d
ts
,
enc
->
time_base
,
ost
->
st
->
time_base
);
if
(
enc
->
coded_frame
->
key_frame
)
pkt
.
flags
|=
AV_PKT_FLAG_KEY
;
write_frame
(
s
,
&
pkt
,
ost
);
*
frame_size
=
ret
;
video_size
+=
ret
;
...
...
@@ -1675,7 +1671,7 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
for
(;;)
{
AVPacket
pkt
;
int
fifo_bytes
;
int
fifo_bytes
,
got_packet
;
av_init_packet
(
&
pkt
);
pkt
.
data
=
NULL
;
pkt
.
size
=
0
;
...
...
@@ -1708,25 +1704,23 @@ static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
}
break
;
case
AVMEDIA_TYPE_VIDEO
:
ret
=
avcodec_encode_video
(
enc
,
bit_buffer
,
bit_buffer_size
,
NULL
);
ret
=
avcodec_encode_video
2
(
enc
,
&
pkt
,
NULL
,
&
got_packet
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_FATAL
,
"Video encoding failed
\n
"
);
exit_program
(
1
);
}
video_size
+=
ret
;
if
(
enc
->
coded_frame
&&
enc
->
coded_frame
->
key_frame
)
pkt
.
flags
|=
AV_PKT_FLAG_KEY
;
if
(
ost
->
logfile
&&
enc
->
stats_out
)
{
fprintf
(
ost
->
logfile
,
"%s"
,
enc
->
stats_out
);
}
if
(
ret
<=
0
)
{
if
(
!
got_packet
)
{
stop_encoding
=
1
;
break
;
}
pkt
.
data
=
bit_buffer
;
pkt
.
size
=
ret
;
if
(
enc
->
coded_frame
&&
enc
->
coded_frame
->
p
ts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
enc
->
coded_frame
->
p
ts
,
enc
->
time_base
,
ost
->
st
->
time_base
);
if
(
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
=
av_rescale_q
(
pkt
.
pts
,
enc
->
time_base
,
ost
->
st
->
time_base
)
;
if
(
pkt
.
d
ts
!=
AV_NOPTS_VALUE
)
pkt
.
dts
=
av_rescale_q
(
pkt
.
d
ts
,
enc
->
time_base
,
ost
->
st
->
time_base
);
write_frame
(
os
,
&
pkt
,
ost
);
break
;
default:
...
...
@@ -2497,18 +2491,6 @@ static int transcode_init(OutputFile *output_files,
}
}
}
if
(
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
int
size
=
codec
->
width
*
codec
->
height
;
bit_buffer_size
=
FFMAX
(
bit_buffer_size
,
6
*
size
+
200
);
}
}
if
(
!
bit_buffer
)
bit_buffer
=
av_malloc
(
bit_buffer_size
);
if
(
!
bit_buffer
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Cannot allocate %d bytes output buffer
\n
"
,
bit_buffer_size
);
return
AVERROR
(
ENOMEM
);
}
/* open each encoder */
...
...
@@ -2841,7 +2823,6 @@ static int transcode(OutputFile *output_files,
ret
=
0
;
fail:
av_freep
(
&
bit_buffer
);
av_freep
(
&
no_packet
);
if
(
output_streams
)
{
...
...
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