X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=video_encoder.cpp;h=0df3b4ffe66c2bf8019be319233faa010c3796f8;hb=1462715cd71d8f61b9e53b31c34d591d150f2df3;hp=8fd9723239f613345151fb11323371be19497728;hpb=90d0745245f83999e88bc50cad57be3e4a1c7439;p=nageru diff --git a/video_encoder.cpp b/video_encoder.cpp index 8fd9723..0df3b4f 100644 --- a/video_encoder.cpp +++ b/video_encoder.cpp @@ -38,8 +38,15 @@ VideoEncoder::VideoEncoder(QSurface *surface, const std::string &va_display, int { open_output_stream(); - quicksync_encoder.reset(new QuickSyncEncoder(surface, va_display, width, height, stream_mux.get())); - quicksync_encoder->open_output_file(generate_local_dump_filename(/*frame=*/0).c_str()); + if (global_flags.stream_audio_codec_name.empty()) { + stream_audio_encoder.reset(new AudioEncoder(AUDIO_OUTPUT_CODEC_NAME, DEFAULT_AUDIO_OUTPUT_BIT_RATE)); + } else { + stream_audio_encoder.reset(new AudioEncoder(global_flags.stream_audio_codec_name, global_flags.stream_audio_codec_bitrate)); + } + stream_audio_encoder->add_mux(stream_mux.get()); + + string filename = generate_local_dump_filename(/*frame=*/0); + quicksync_encoder.reset(new QuickSyncEncoder(filename, surface, va_display, width, height, stream_mux.get(), stream_audio_encoder.get())); } VideoEncoder::~VideoEncoder() @@ -52,10 +59,8 @@ void VideoEncoder::do_cut(int frame) { string filename = generate_local_dump_filename(frame); printf("Starting new recording: %s\n", filename.c_str()); - quicksync_encoder->close_output_file(); quicksync_encoder->shutdown(); - quicksync_encoder.reset(new QuickSyncEncoder(surface, va_display, width, height, stream_mux.get())); - quicksync_encoder->open_output_file(filename.c_str()); + quicksync_encoder.reset(new QuickSyncEncoder(filename, surface, va_display, width, height, stream_mux.get(), stream_audio_encoder.get())); } void VideoEncoder::add_audio(int64_t pts, std::vector audio)