Commit 1782a840 authored by Stefan Westerfeld's avatar Stefan Westerfeld

testhls: re-add aac encoder cut_start and cut_end

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 161e4b9b
...@@ -122,6 +122,8 @@ struct OutputStream { ...@@ -122,6 +122,8 @@ struct OutputStream {
const WavData *wav_data = nullptr; const WavData *wav_data = nullptr;
int64_t t; int64_t t;
size_t cut_frames_start = 0;
size_t keep_frames = 0;
struct SwsContext *sws_ctx; struct SwsContext *sws_ctx;
struct SwrContext *swr_ctx; struct SwrContext *swr_ctx;
...@@ -424,14 +426,24 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost) ...@@ -424,14 +426,24 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
exit(1); exit(1);
} }
if (got_packet) { if (got_packet)
ret = write_frame(oc, &c->time_base, ost->st, &pkt); {
if (ret < 0) { if (ost->cut_frames_start)
fprintf(stderr, "Error while writing audio frame: %s\n", {
av_err2str(ret)); ost->cut_frames_start--;
exit(1); }
} else if (ost->keep_frames)
} {
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
if (ret < 0)
{
fprintf(stderr, "Error while writing audio frame: %s\n",
av_err2str(ret));
exit(1);
}
ost->keep_frames--;
}
}
return (frame || got_packet) ? 0 : 1; return (frame || got_packet) ? 0 : 1;
} }
...@@ -465,6 +477,8 @@ ff_encode (const WavData& wav_data, const string& out_filename, size_t start_pos ...@@ -465,6 +477,8 @@ ff_encode (const WavData& wav_data, const string& out_filename, size_t start_pos
OutputStream audio_st = { 0 }; OutputStream audio_st = { 0 };
audio_st.wav_data = &wav_data; audio_st.wav_data = &wav_data;
audio_st.cut_frames_start = cut_start / 1024;
audio_st.keep_frames = (wav_data.n_values() / wav_data.n_channels() - cut_start - cut_end) / 1024;
AVCodec *audio_codec; AVCodec *audio_codec;
AVOutputFormat *fmt; AVOutputFormat *fmt;
AVDictionary *opt = nullptr; AVDictionary *opt = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment