Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
merge_av
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
胡斌
2018-11-30 22:38:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3d8df99c0cf501a4ecdbc3c46959f14320591a14
3d8df99c
1 parent
86eb158a
more code about transcode
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
61 行增加
和
11 行删除
pip/AVDecoder.cpp
pip/AVDecoder.h
pip/AVTranscoder.cpp
pip/AVTranscoder.h
pip/AVDecoder.cpp
查看文件 @
3d8df99
...
...
@@ -8,7 +8,8 @@ _cur_a_ts_ms(INT64_MAX),
_cur_v_ts_ms
(
INT64_MAX
),
_end_time_ms
(
0
),
_cur_a_frame
(
NULL
),
_cur_v_frame
(
NULL
)
_cur_v_frame
(
NULL
),
_media_role
(
mr_student
)
{
}
...
...
@@ -19,6 +20,7 @@ CAVDecoder::~CAVDecoder()
int
CAVDecoder
::
add
(
media_info
&
info
)
{
_media_role
=
info
.
m_role
;
if
(
info
.
m_type
==
mt_audio
)
{
_a_start_time_ms
=
info
.
start_time_ms
;
_a_end_time_ms
=
info
.
end_time_ms
;
...
...
pip/AVDecoder.h
查看文件 @
3d8df99
...
...
@@ -15,7 +15,10 @@ public:
bool
get_one_v_frame
();
int64_t
_cur_a_ts_ms
;
int64_t
_cur_v_ts_ms
;
media_role
_media_role
;
AVFrame
*
_cur_a_frame
;
AVFrame
*
_cur_v_frame
;
protected
:
list
<
media_info
>
_video_info
;
list
<
media_info
>
_audio_info
;
...
...
@@ -26,8 +29,7 @@ protected:
int64_t
_v_start_time_ms
;
int64_t
_v_end_time_ms
;
int64_t
_end_time_ms
;
AVFrame
*
_cur_a_frame
;
AVFrame
*
_cur_v_frame
;
private
:
AVFrame
*
get_blank_frame
();
AVFrame
*
get_silence_frame
();
...
...
pip/AVTranscoder.cpp
查看文件 @
3d8df99
...
...
@@ -3,8 +3,16 @@
CAVTranscoder
::
CAVTranscoder
()
:
_start_time
(
INT64_MAX
),
_all_processed
(
true
)
_all_processed
(
true
),
_one2one
(
false
),
_nOutputWidth
(
320
)
{
if
(
_one2one
)
{
_nOutputHeight
=
480
;
}
else
{
_nOutputHeight
=
240
;
}
}
...
...
@@ -38,7 +46,7 @@ int CAVTranscoder::add(media_info & info)
int64_t
CAVTranscoder
::
transcode
()
{
vector
<
CAVDecoder
*>
decoders_got_frame
;
vector
<
CAVDecoder
*>::
iterator
it
=
_decoders
.
begin
();
vector
<
CAVDecoder
*>::
iterator
it
=
_decoders
.
begin
();
for
(;
it
!=
_decoders
.
end
();)
{
if
((
*
it
)
->
get_one_v_frame
()){
decoders_got_frame
.
push_back
(
*
it
);
...
...
@@ -201,6 +209,16 @@ int CAVTranscoder::open_output_file(const char *filename)
int
CAVTranscoder
::
mix_and_output_vframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
{
if
(
_one2one
){
return
mix_and_output_one2one_vframe
(
decoders_got_frame
);
}
else
{
return
mix_and_output_one2many_vframe
(
decoders_got_frame
);
}
}
int
CAVTranscoder
::
mix_and_output_aframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
{
vector
<
CAVDecoder
*>::
iterator
it
=
decoders_got_frame
.
begin
();
for
(;
it
!=
decoders_got_frame
.
end
();
it
++
)
{
(
*
it
)
->
free_cur_a_frame
();
...
...
@@ -208,17 +226,37 @@ int CAVTranscoder::open_output_file(const char *filename)
return
0
;
}
int
CAVTranscoder
::
mix_and_output_
a
frame
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
int
CAVTranscoder
::
mix_and_output_
one2many_v
frame
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
{
vector
<
CAVDecoder
*>::
iterator
it
=
decoders_got_frame
.
begin
();
for
(;
it
!=
decoders_got_frame
.
end
();
it
++
)
{
(
*
it
)
->
free_cur_v_frame
();
return
0
;
}
int
CAVTranscoder
::
fillDestFrame
(
AVFrame
*
pDstFrame
,
AVFrame
*
pSrcFrame
,
int
x
,
int
y
)
{
}
int
CAVTranscoder
::
mix_and_output_one2one_vframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
{
//prepare one2one base frame
AVFrame
*
pDstFrame
=
av_frame_alloc
();
int
nDstSize
=
avpicture_get_size
(
AV_PIX_FMT_YUV420P
,
_nOutputWidth
,
_nOutputHeight
);
uint8_t
*
dstbuf
=
new
uint8_t
[
nDstSize
];
avpicture_fill
((
AVPicture
*
)
pDstFrame
,
dstbuf
,
AV_PIX_FMT_YUV420P
,
_nOutputWidth
,
_nOutputHeight
);
if
(
decoders_got_frame
.
size
()
==
2
){
fillDestFrame
(
pDstFrame
,
decoders_got_frame
[
0
]
->
_cur_v_frame
,
0
,
decoders_got_frame
[
0
]
->
_media_role
==
mr_teacher
?
0
:
240
);
fillDestFrame
(
pDstFrame
,
decoders_got_frame
[
1
]
->
_cur_v_frame
,
0
,
decoders_got_frame
[
1
]
->
_media_role
==
mr_teacher
?
0
:
240
);
}
else
{
fillDestFrame
(
pDstFrame
,
decoders_got_frame
[
0
]
->
_cur_v_frame
,
0
,
0
);
}
return
0
;
}
int
encode_write_frame
(
AVFrame
*
filt_frame
,
unsigned
int
stream_index
,
int
*
got_frame
)
{
int
ret
;
int
encode_write_frame
(
AVFrame
*
filt_frame
,
unsigned
int
stream_index
,
int
*
got_frame
)
{
int
ret
;
int
got_frame_local
;
AVPacket
enc_pkt
;
#if 0
...
...
pip/AVTranscoder.h
查看文件 @
3d8df99
...
...
@@ -23,9 +23,17 @@ protected:
int64_t
_start_time
;
int64_t
_cur_a_time
;
int64_t
_cur_v_time
;
int
_nOutputWidth
;
int
_nOutputHeight
;
private
:
int
mix_and_output_vframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
);
int
mix_and_output_aframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
);
bool
_all_processed
;
bool
_one2one
;
int
mix_and_output_one2one_vframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
);
int
mix_and_output_one2many_vframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
);
int
fillDestFrame
(
AVFrame
*
pDstFrame
,
AVFrame
*
pSrcFrame
,
int
x
,
int
y
);
};
...
...
请
注册
或
登录
后发表评论