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-09 14:24:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3cc97f668b51e1c4152c65e5d6daeca8c4a11684
3cc97f66
1 parent
60b881aa
output aac,set the correct aac packet duration
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
44 行增加
和
5 行删除
pip/AVTranscoder.cpp
pip/AVTranscoder.h
pip/AudioDecoder.cpp
pip/media_info.h
pip/merge_pip.cpp
pip/pip.vcxproj.filters
pip/AVTranscoder.cpp
查看文件 @
3cc97f6
...
...
@@ -169,6 +169,8 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx
->
qmin
=
10
;
enc_ctx
->
qmax
=
30
;
enc_ctx
->
qcompress
=
0.6
;
enc_ctx
->
framerate
.
den
=
20
;
enc_ctx
->
framerate
.
num
=
1
;
AVDictionary
*
d
=
NULL
;
char
*
k
=
av_strdup
(
"preset"
);
// if your strings are already allocated,
...
...
@@ -194,6 +196,7 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx
->
sample_fmt
=
AV_SAMPLE_FMT_S16
;
//AV_SAMPLE_FMT_FLTP;
enc_ctx
->
time_base
.
num
=
1
;
enc_ctx
->
time_base
.
den
=
enc_ctx
->
sample_rate
;
enc_ctx
->
bit_rate
=
64000
;
/* Third parameter can be used to pass settings to encoder */
ret
=
avcodec_open2
(
enc_ctx
,
encoder
,
NULL
);
if
(
ret
<
0
)
{
...
...
@@ -236,10 +239,37 @@ int CAVTranscoder::open_output_file(const char *filename)
int
CAVTranscoder
::
mix_and_output_aframe
(
vector
<
CAVDecoder
*>
&
decoders_got_frame
)
{
AVFrame
*
pDstFrame
=
av_frame_alloc
();
pDstFrame
->
nb_samples
=
1024
;
pDstFrame
->
channel_layout
=
AV_CH_LAYOUT_MONO
;
pDstFrame
->
channels
=
av_get_channel_layout_nb_channels
(
AV_CH_LAYOUT_MONO
);
pDstFrame
->
format
=
AV_SAMPLE_FMT_S16
;
pDstFrame
->
sample_rate
=
48000
;
av_frame_get_buffer
(
pDstFrame
,
0
);
av_samples_set_silence
(
pDstFrame
->
data
,
0
,
1024
,
pDstFrame
->
channels
,
(
AVSampleFormat
)
pDstFrame
->
format
);
vector
<
CAVDecoder
*>::
iterator
it
=
decoders_got_frame
.
begin
();
for
(;
it
!=
decoders_got_frame
.
end
();
it
++
)
{
(
*
it
)
->
free_cur_a_frame
();
AVFrame
*
pFrame
=
(
*
it
)
->
_cur_a_frame
;
if
(
pFrame
)
{
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
;
}
}
}
pDstFrame
->
pts
=
_cur_out_a_ts
;
pDstFrame
->
pkt_dts
=
_cur_out_a_ts
;
pDstFrame
->
pkt_pts
=
_cur_out_a_ts
;
pDstFrame
->
pkt_duration
=
1024
;
_cur_out_a_ts
+=
1024
;
int
got_frame
=
0
;
encode_write_frame
(
pDstFrame
,
1
,
&
got_frame
);
// av_frame_free(&pDstFrame);
return
0
;
}
...
...
@@ -335,13 +365,14 @@ int CAVTranscoder::open_output_file(const char *filename)
}
//fill the timestamp of dest frame
_cur_out_v_ts
++
;
pDstFrame
->
pts
=
_cur_out_v_ts
;
pDstFrame
->
pkt_dts
=
_cur_out_v_ts
;
pDstFrame
->
pkt_pts
=
_cur_out_v_ts
;
pDstFrame
->
format
=
AV_PIX_FMT_YUV420P
;
pDstFrame
->
width
=
_nOutputWidth
;
pDstFrame
->
height
=
_nOutputHeight
;
_cur_out_v_ts
++
;
//send to encoder
int
got_frame
=
0
;
...
...
pip/AVTranscoder.h
查看文件 @
3cc97f6
...
...
@@ -37,5 +37,7 @@ private:
int
fillDestFrame
(
AVFrame
*
pDstFrame
,
AVFrame
*
pSrcFrame
,
int
x
,
int
y
);
int
encode_write_frame
(
AVFrame
*
filt_frame
,
unsigned
int
stream_index
,
int
*
got_frame
);
int
flush_encoder
(
unsigned
int
stream_index
);
void
*
_a_frame_pool
;
};
...
...
pip/AudioDecoder.cpp
查看文件 @
3cc97f6
...
...
@@ -141,7 +141,7 @@ int CAudioDecoder::init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
goto
end
;
}
int
sample_rate
=
4
6
000
;
int
sample_rate
=
4
8
000
;
ret
=
av_opt_set_bin
(
buffersink_ctx
,
"sample_rates"
,
(
uint8_t
*
)
&
sample_rate
,
sizeof
(
sample_rate
),
AV_OPT_SEARCH_CHILDREN
);
...
...
pip/media_info.h
查看文件 @
3cc97f6
...
...
@@ -77,5 +77,5 @@ typedef struct FilteringContext {
}
FilteringContext
;
#define AFRAME_DURATION_MS
0.021
33333
#define AFRAME_DURATION_MS
21.3
33333
#define VFRAME_DURATION_MS 50
\ No newline at end of file
...
...
pip/merge_pip.cpp
查看文件 @
3cc97f6
...
...
@@ -835,7 +835,7 @@ string get_outmedia_file_name(const char * input)
if
(
p
)
{
*
p
=
0
;
}
strcat
(
out_media_file
,
"_out.
ts
"
);
strcat
(
out_media_file
,
"_out.
mp4
"
);
return
out_media_file
;
}
...
...
pip/pip.vcxproj.filters
查看文件 @
3cc97f6
...
...
@@ -42,6 +42,9 @@
<ClCompile Include="merge_pip.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="framepool.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="VideoDecoder.h">
...
...
@@ -65,5 +68,8 @@
<ClInclude Include="AudioEncoder.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="framepool.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论