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-02-09 19:08:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ff7eb97f1cb888af7e7032d85e117685a9be6190
ff7eb97f
1 parent
04bc3145
rewrite merge logic,don't use pip when there is only one video
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
72 行增加
和
71 行删除
pip/pip.cpp
pip/pip.cpp
查看文件 @
ff7eb97
...
...
@@ -569,60 +569,46 @@ int merge_audio_video(vector<media_info> & files)
int
merge_video_pip
(
vector
<
media_info
>
&
files
)
{
char
video
_file
[
1024
];
char
ch0_file
[
1024
],
ch1
_file
[
1024
];
vector
<
string
>
merge_video_files
;
int
nsilence
=
0
;
media_info
video
=
files
[
0
];
float
start_time
=
video
.
start_time
;
for
(
int
i
=
1
;
i
<
files
.
size
()
-
1
;
i
+=
2
){
media_info
video
=
files
[
i
];
media_info
video_end
=
files
[
i
+
1
];
if
(
video
.
type_time
-
start_time
>
0.1
){
sprintf
(
audio_file
,
"%d_%d_silence.aac"
,
nf
,
nsilence
++
);
//a duration of silence
split_audio
(
silence_aac_file
,
0
,
video
.
type_time
-
start_time
,
audio_file
);
sprintf
(
video_file
,
"%d_%d_blank.ts"
,
nf
,
nsilence
++
);
merge_audio_pic
(
audio_file
,
blank_pic_file
,
video_file
);
media_info
ch0_start
,
ch0_end
,
ch1_start
,
ch1_end
;
merge_video_files
.
push_back
(
video_file
);
tmp_files
.
push_back
(
audio_file
);
tmp_files
.
push_back
(
video_file
);
if
(
files
[
0
].
channel
==
0
)
{
ch0_start
=
files
[
0
];
ch0_end
=
files
[
2
];
ch1_start
=
files
[
1
];
ch1_end
=
files
[
3
];
}
else
{
ch0_start
=
files
[
1
];
ch0_end
=
files
[
3
];
ch1_start
=
files
[
0
];
ch1_end
=
files
[
2
];
}
if
(
video
.
type_time
-
video
.
start_time
>
0.10
||
video_end
.
end_time
-
video_end
.
type_time
>
0.10
)
{
sprintf
(
video_file
,
"%d_%s"
,
nf
,
video
.
name
.
c_str
());
split_av
(
video
.
name
.
c_str
(),
video
.
type_time
-
video
.
start_time
,
video_end
.
type_time
-
video
.
type_time
,
video_file
);
tmp_files
.
push_back
(
video_file
);
if
(
ch0_start
.
type_time
-
ch0_start
.
start_time
>
0.10
||
ch0_end
.
end_time
-
ch0_end
.
type_time
>
0.10
)
{
sprintf
(
ch0_file
,
"%d_%s"
,
nf
,
ch0_start
.
name
.
c_str
());
split_av
(
ch0_start
.
name
.
c_str
(),
ch0_start
.
type_time
-
ch0_start
.
start_time
,
ch0_end
.
type_time
-
ch0_start
.
type_time
,
ch0_file
);
tmp_files
.
push_back
(
ch0_file
);
}
else
{
strcpy
(
video_file
,
video
.
name
.
c_str
());
strcpy
(
ch0_file
,
ch0_start
.
name
.
c_str
());
}
start_time
=
video_end
.
type_time
;
merge_video_files
.
push_back
(
video_file
);
if
(
i
==
files
.
size
()
-
2
){
if
(
video
.
end_time
-
video_end
.
type_time
>
0.1
){
sprintf
(
audio_file
,
"%d_%d_silence.aac"
,
nf
,
nsilence
++
);
//a duration of silence
split_audio
(
silence_aac_file
,
0
,
video
.
end_time
-
video_end
.
type_time
,
audio_file
);
sprintf
(
video_file
,
"%d_%d_blank.ts"
,
nf
,
nsilence
++
);
merge_audio_pic
(
audio_file
,
blank_pic_file
,
video_file
);
merge_video_files
.
push_back
(
video_file
);
tmp_files
.
push_back
(
audio_file
);
tmp_files
.
push_back
(
video_file
);
}
if
(
ch1_start
.
type_time
-
ch1_start
.
start_time
>
0.10
||
ch1_end
.
end_time
-
ch1_end
.
type_time
>
0.10
)
{
sprintf
(
ch1_file
,
"%d_%s"
,
nf
,
ch1_start
.
name
.
c_str
());
split_av
(
ch1_start
.
name
.
c_str
(),
ch1_start
.
type_time
-
ch1_start
.
start_time
,
ch1_end
.
type_time
-
ch1_start
.
type_time
,
ch1_file
);
tmp_files
.
push_back
(
ch1_file
);
}
else
{
strcpy
(
ch1_file
,
ch1_start
.
name
.
c_str
());
}
sprintf
(
video_file
,
"%d_merged.ts"
,
nf
);
merge_av_file
(
merge_video_files
,
video_file
);
tmp_files
.
push_back
(
video_file
);
sprintf
(
destfile
,
"%d.ts"
,
nf
);
merge_video_pip
(
video_file
,
video
.
name
.
c_str
()
,
destfile
);
merge_video_pip
(
ch0_file
,
ch1_file
,
destfile
);
merged_files
.
push_back
(
destfile
);
nf
++
;
...
...
@@ -630,7 +616,7 @@ int merge_video_pip(vector<media_info> & files)
}
int
transcode_file
s
(
vector
<
media_info
>
files
)
int
transcode_file
(
vector
<
media_info
>
files
)
{
char
video_file
[
1024
];
media_info
video
=
files
[
0
];
...
...
@@ -727,39 +713,59 @@ int split_audio_for_video(int audio_start,vector<media_info> & result)
return
0
;
}
int
split_ch0_for_ch1
(
int
ch0_start
,
vector
<
media_info
>
&
result
)
int
split_ch0_for_ch1
(
vector
<
media_info
>
&
result
)
{
media_info
ch0
=
sorted_infos
[
ch0_start
];
media_info
ch1
=
sorted_infos
[
ch0_start
+
1
];
media_info
firstend
=
sorted_infos
[
2
];
media_info
next
=
sorted_infos
[
3
];
result
.
clear
();
for
(
int
i
=
0
;
i
<=
ch0_start
;
i
++
){
if
(
sorted_infos
[
0
].
index
==
firstend
.
index
)
{
for
(
int
i
=
0
;
i
<=
2
;
i
++
){
result
.
push_back
(
sorted_infos
[
i
]);
}
}
else
{
result
.
push_back
(
sorted_infos
[
1
]);
result
.
push_back
(
sorted_infos
[
0
]);
result
.
push_back
(
sorted_infos
[
2
]);
}
if
(
sorted_infos
[
ch0_start
+
2
].
index
==
sorted_infos
[
ch0_start
].
index
){
if
(
sorted_infos
[
ch0_start
+
2
].
type_time
-
sorted_infos
[
ch0_start
+
1
].
type_time
<
0.1
){
//no need to split
result
.
push_back
(
sorted_infos
[
ch0_start
+
2
]);
//put the audio end to the result
result
.
push_back
(
ch1
);
//push the video end to the result
for
(
int
i
=
0
;
i
<=
ch0_start
+
2
;
i
++
){
//remove the infos including the audio end
if
(
next
.
t_type
==
tt_end
){
if
(
next
.
type_time
-
firstend
.
type_time
<
0.1
){
//no need to split
result
.
push_back
(
next
);
//push the video end to the result
for
(
int
i
=
0
;
i
<
4
;
i
++
){
//remove the infos
sorted_infos
.
pop_front
();
}
return
1
;
}
next
.
type_time
=
firstend
.
type_time
;
result
.
push_back
(
next
);
for
(
int
i
=
0
;
i
<
3
;
i
++
){
//remove the infos including the video end
sorted_infos
.
pop_front
();
}
next
.
t_type
=
tt_start
;
sorted_infos
.
push_front
(
next
);
}
else
{
media_info
should_split
=
result
[
1
];
should_split
.
t_type
=
tt_end
;
should_split
.
type_time
=
firstend
.
type_time
;
result
.
push_back
(
should_split
);
ch0
.
t_type
=
tt_end
;
ch0
.
type_time
=
ch1
.
type_time
;
result
.
push_back
(
ch0
);
result
.
push_back
(
ch1
);
for
(
int
i
=
0
;
i
<=
ch0_start
+
1
;
i
++
){
//remove the infos including the video end
for
(
int
i
=
0
;
i
<
3
;
i
++
){
//remove the infos including the video end
sorted_infos
.
pop_front
();
}
ch0
.
t_type
=
tt_start
;
sorted_infos
.
push_front
(
ch0
);
should_split
.
t_type
=
tt_start
;
sorted_infos
.
push_front
(
should_split
);
}
return
0
;
}
...
...
@@ -926,24 +932,17 @@ int process_va_files()
while
(
sorted_infos
.
size
())
{
int
channel
=
sorted_infos
[
0
].
channel
;
if
(
0
==
channel
)
{
if
(
!
sorted_infos
[
1
].
index
==
sorted_infos
[
0
].
index
)
if
(
sorted_infos
[
1
].
index
==
sorted_infos
[
0
].
index
)
{
split_ch0_for_no_process
(
cur_processing
);
}
else
{
get_front_info
(
1
,
cur_processing
);
transcode_file
(
cur_processing
);
}
transcode_files
(
cur_processing
);
}
else
if
(
1
==
channel
)
{
int
index
=
find_video_end
();
if
(
is_ch0_start
(
index
-
1
))
{
split_ch0_for_ch1
(
index
-
1
,
cur_processing
);
else
if
(
sorted_infos
[
1
].
type_time
-
sorted_infos
[
0
].
type_time
>
0.2
)
{
split_ch0_for_no_process
(
cur_processing
);
transcode_file
(
cur_processing
);
}
else
{
get_front_info
(
index
,
cur_processing
);
}
split_ch0_for_ch1
(
cur_processing
);
merge_video_pip
(
cur_processing
);
}
//if the duration between the processed end and the start of not processed is large than 200 ms, reopen a new file
...
...
@@ -968,12 +967,14 @@ int process_files()
//don't split video, for a video, using merged audios to mix with it
//for audio, mix with video or jpg
char
outputfile
[
1024
];
init
();
if
(
!
media_files
.
size
()){
return
0
;
}
init
();
fp_out_info
=
fopen
(
out_info_file
,
"wt"
);
process_va_files
();
...
...
请
注册
或
登录
后发表评论