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-04-18 20:13:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3bd71f14a09d86ad302fbd6e0b2b57ab9799fbc3
3bd71f14
1 parent
14199160
add command parameter "-c",to support only convert mp4 to ts
set the version to 1.1.0
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
55 行增加
和
5 行删除
merge_av/merge_av.cpp
merge_av/merge_av.cpp
查看文件 @
3bd71f1
...
...
@@ -11,6 +11,7 @@
bool
only_print
=
false
;
bool
keep_tmp_files
=
false
;
bool
only_convert_mp4
=
false
;
using
namespace
std
;
enum
media_type
{
...
...
@@ -184,6 +185,13 @@ void merge_audio_video(const char * audio, const char * video, const char * dest
run_shell_cmd
(
buf
);
}
void
convert_video_to_ts
(
const
char
*
video
,
const
char
*
destfile
)
{
char
buf
[
2048
];
sprintf
(
buf
,
"ffmpeg -y -i %s %s %s %s"
,
video
,
acodec_param
,
vcodec_param
,
destfile
);
run_shell_cmd
(
buf
);
}
void
merge_video_silence
(
fileinfo
video
,
const
char
*
aacfile
,
const
char
*
destfile
)
{
char
buf
[
2048
];
...
...
@@ -504,8 +512,10 @@ void init()
strcpy
(
silence_aac_file
,
cfg_path
);
strcat
(
silence_aac_file
,
"silence.aac"
);
check_audio_duration
();
get_duration_from_video_file
();
if
(
only_convert_mp4
==
false
)
{
check_audio_duration
();
get_duration_from_video_file
();
}
add_media_infos
();
nv
=
0
;
...
...
@@ -973,7 +983,7 @@ int process_files()
for
(
int
i
=
0
;
i
<
media_files
.
size
();
i
++
){
fileinfo
video
=
media_files
[
i
];
get_output_file_name
(
i
,
video
.
name
.
c_str
(),
outputfile
);
merge_video_silence
(
video
,
silence_aac_file
,
des
tfile
);
merge_video_silence
(
video
,
silence_aac_file
,
outpu
tfile
);
save_out_info
(
video
.
start_time
,
outputfile
);
}
}
...
...
@@ -989,6 +999,37 @@ int process_files()
return
0
;
}
int
process_only_mp4_files
()
{
//only convert mp4 to ts,don't merge
printf
(
"\only convert mp4 files!
\n
"
);
char
outputfile
[
1024
];
init
();
if
(
!
media_files
.
size
()){
return
0
;
}
fp_out_info
=
fopen
(
out_info_file
,
"wt"
);
for
(
int
i
=
0
;
i
<
media_files
.
size
();
i
++
){
fileinfo
video
=
media_files
[
i
];
if
(
video
.
m_type
==
mt_audio
)
{
continue
;
}
get_output_file_name
(
i
,
video
.
name
.
c_str
(),
outputfile
);
convert_video_to_ts
(
video
.
name
.
c_str
(),
outputfile
);
save_out_info
(
video
.
start_time
,
outputfile
);
}
if
(
fp_out_info
)
{
fclose
(
fp_out_info
);
}
return
0
;
}
int
readfile
(
char
*
filename
)
{
ifstream
fin
(
filename
);
...
...
@@ -1058,11 +1099,12 @@ void get_outinfo_file_name(char * input)
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
printf
(
" merge_av 1.
0.9
\n
"
);
printf
(
" merge_av 1.
1.0
\n
"
);
printf
(
" run ffmpeg to merge audio and video files according to the record info file,
\n
usage:"
);
printf
(
"
\n
%s record_info_filename [-p] [-k]"
,
argv
[
0
]);
printf
(
"
\n
-p :only print the command,don't run ffmpeg"
);
printf
(
"
\n
-k :keep the temp files
\n
"
);
printf
(
"
\n
-c :only convert mp4 files
\n
"
);
return
-
1
;
}
...
...
@@ -1078,6 +1120,9 @@ int main(int argc, char * argv[])
else
if
(
!
strcmp
(
argv
[
i
],
"-k"
)){
keep_tmp_files
=
true
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-c"
)){
only_convert_mp4
=
true
;
}
}
get_outinfo_file_name
(
argv
[
1
]);
...
...
@@ -1086,7 +1131,12 @@ int main(int argc, char * argv[])
load_codec_param
();
process_files
();
if
(
only_convert_mp4
==
true
)
{
process_only_mp4_files
();
}
else
{
process_files
();
}
return
0
;
}
...
...
请
注册
或
登录
后发表评论