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-12-10 00:07:38 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e64e92dae3a854b1ad59406112da5487b0be80dc
e64e92da
1 parent
3cc97f66
count max audio stream should be mixed
fix bug for finished transcoding without all files transcoded
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
76 行增加
和
7 行删除
pip/AVTranscoder.cpp
pip/AVTranscoder.h
pip/merge_pip.cpp
pip/AVTranscoder.cpp
查看文件 @
e64e92d
...
...
@@ -7,7 +7,8 @@ _all_processed(true),
_one2one
(
true
),
_nOutputWidth
(
320
),
_cur_out_v_ts
(
0
),
_cur_out_a_ts
(
0
)
_cur_out_a_ts
(
0
),
_max_audio
(
1
)
{
if
(
_one2one
)
{
_nOutputHeight
=
480
;
...
...
@@ -255,11 +256,12 @@ int CAVTranscoder::open_output_file(const char *filename)
int16_t
*
psrc
=
(
int16_t
*
)
pFrame
->
extended_data
[
0
];
int16_t
*
pdst
=
(
int16_t
*
)
pDstFrame
->
extended_data
[
0
];
for
(
int
i
=
0
;
i
<
1024
;
i
++
,
pdst
++
,
psrc
++
)
{
*
pdst
+=
*
psrc
;
*
pdst
+=
(
*
psrc
/
_max_audio
)
;
}
}
}
pDstFrame
->
pts
=
_cur_out_a_ts
;
pDstFrame
->
pkt_dts
=
_cur_out_a_ts
;
pDstFrame
->
pkt_pts
=
_cur_out_a_ts
;
...
...
@@ -268,7 +270,6 @@ int CAVTranscoder::open_output_file(const char *filename)
int
got_frame
=
0
;
encode_write_frame
(
pDstFrame
,
1
,
&
got_frame
);
// av_frame_free(&pDstFrame);
return
0
;
}
...
...
@@ -399,6 +400,7 @@ int CAVTranscoder::encode_write_frame(AVFrame *filt_frame, unsigned int stream_i
av_init_packet
(
&
enc_pkt
);
ret
=
enc_func
(
_ofmt_ctx
->
streams
[
stream_index
]
->
codec
,
&
enc_pkt
,
filt_frame
,
got_frame
);
av_frame_unref
(
filt_frame
);
av_frame_free
(
&
filt_frame
);
if
(
ret
<
0
)
return
ret
;
...
...
@@ -438,3 +440,8 @@ int CAVTranscoder::flush_encoder(unsigned int stream_index)
}
return
ret
;
}
void
CAVTranscoder
::
set_max_audio
(
int
max_audio
)
{
_max_audio
=
max_audio
;
}
...
...
pip/AVTranscoder.h
查看文件 @
e64e92d
...
...
@@ -39,5 +39,8 @@ private:
int
flush_encoder
(
unsigned
int
stream_index
);
void
*
_a_frame_pool
;
int
_max_audio
;
public
:
void
set_max_audio
(
int
max_audio
);
};
...
...
pip/merge_pip.cpp
查看文件 @
e64e92d
...
...
@@ -577,6 +577,28 @@ void add_media_info(media_info m)
sorted_media
.
insert
(
it
,
m
);
}
list
<
media_info
>
audio_files
;
int
count_audio_files
(
float
mid
)
{
int
files
=
0
;
list
<
media_info
>::
iterator
it
=
audio_files
.
begin
();
for
(;
it
!=
audio_files
.
end
();
it
++
){
if
(
it
->
start_time
<
mid
){
if
(
it
->
end_time
>
mid
)
{
files
++
;
}
}
else
{
break
;
}
}
return
files
;
}
int
max_audio
=
1
;
void
add_media_infos
()
{
sorted_media
.
clear
();
...
...
@@ -597,15 +619,51 @@ void add_media_infos()
m
.
start_time_ms
=
f
.
start_time
*
1000
;
m
.
end_time_ms
=
f
.
end_time
*
1000
;
add_media_info
(
m
);
/*
m
.
t_type
=
tt_end
;
m
.
type_time
=
m
.
end_time
;
add_media_info(m);
*/
add_media_info
(
m
);
}
list
<
media_info
>
audio_type_files
;
list
<
media_info
>::
iterator
it
=
sorted_media
.
begin
();
for
(;
it
!=
sorted_media
.
end
();
it
++
){
sorted_infos
.
push_back
(
*
it
);
if
(
it
->
m_type
==
mt_audio
)
{
if
(
it
->
t_type
==
tt_start
)
{
audio_files
.
push_back
(
*
it
);
}
audio_type_files
.
push_back
(
*
it
);
}
}
it
=
sorted_media
.
begin
();
for
(;
it
!=
sorted_media
.
end
();){
if
(
it
->
t_type
==
tt_end
)
{
it
=
sorted_media
.
erase
(
it
);
}
else
{
it
++
;
}
}
it
=
audio_type_files
.
begin
();
media_info
last
=
*
it
;
for
(
it
++
;
it
!=
audio_type_files
.
end
();
it
++
)
{
if
(
it
->
t_type
==
tt_end
)
{
if
(
last
.
t_type
==
tt_start
)
{
float
mid
=
(
it
->
type_time
+
last
.
type_time
)
/
2
;
int
files_with_mid
=
count_audio_files
(
mid
);
if
(
files_with_mid
>
max_audio
)
{
max_audio
=
files_with_mid
;
}
}
}
else
{
last
=
*
it
;
}
}
}
...
...
@@ -894,6 +952,7 @@ int process_av_files()
avfilter_register_all
();
CAVTranscoder
videoTranscoder
;
videoTranscoder
.
set_max_audio
(
max_audio
);
int64_t
cur_time
=
0
;
bool
has_file
=
sorted_media
.
size
();
...
...
@@ -924,7 +983,7 @@ int process_av_files()
cur_time
=
videoTranscoder
.
transcode
();
}
while
(
videoTranscoder
.
all_processed
()){
while
(
!
videoTranscoder
.
all_processed
()){
cur_time
=
videoTranscoder
.
transcode
();
}
...
...
请
注册
或
登录
后发表评论