X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fexport.cpp;h=7833f91f1d17030433e214304b34f00caf501d57;hb=refs%2Fheads%2Fmaster;hp=1b7c59c90ae75f853b1d9eaf6b7f27a190d06996;hpb=e0cb348ca42ae7057f8f5acee92a23e7eb26075f;p=nageru diff --git a/futatabi/export.cpp b/futatabi/export.cpp index 1b7c59c..b02361e 100644 --- a/futatabi/export.cpp +++ b/futatabi/export.cpp @@ -17,6 +17,7 @@ extern "C" { #include +#include } using namespace std; @@ -33,16 +34,15 @@ struct BufferedFrame { bool write_buffered_frames(AVFormatContext *avctx, const vector &buffered_frames) { for (const BufferedFrame &frame : buffered_frames) { - AVPacket pkt; - av_init_packet(&pkt); - pkt.stream_index = frame.video_stream_idx; - pkt.data = (uint8_t *)frame.data.data(); - pkt.size = frame.data.size(); - pkt.pts = frame.pts; - pkt.dts = frame.pts; - pkt.flags = AV_PKT_FLAG_KEY; + AVPacketWithDeleter pkt = av_packet_alloc_unique(); + pkt->stream_index = frame.video_stream_idx; + pkt->data = (uint8_t *)frame.data.data(); + pkt->size = frame.data.size(); + pkt->pts = frame.pts; + pkt->dts = frame.pts; + pkt->flags = AV_PKT_FLAG_KEY; - if (av_write_frame(avctx, &pkt) < 0) { + if (av_write_frame(avctx, pkt.get()) < 0) { return false; } } @@ -135,8 +135,9 @@ void export_multitrack_clip(const string &filename, const Clip &clip) avstream_audio->time_base = AVRational{ 1, TIMEBASE }; avstream_audio->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; avstream_audio->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; - avstream_audio->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; - avstream_audio->codecpar->channels = 2; + avstream_audio->codecpar->ch_layout.order = AV_CHANNEL_ORDER_NATIVE; + avstream_audio->codecpar->ch_layout.nb_channels = 2; + avstream_audio->codecpar->ch_layout.u.mask = AV_CH_LAYOUT_STEREO; avstream_audio->codecpar->sample_rate = OUTPUT_FREQUENCY; audio_streams.push_back(avstream_audio); } @@ -182,7 +183,7 @@ void export_multitrack_clip(const string &filename, const Clip &clip) } } - FrameReader::Frame frame = readers[first_frame_stream_idx].read_frame(first_frame, /*read_audio=*/true); + FrameReader::Frame frame = readers[first_frame_stream_idx].read_frame(first_frame, /*read_video=*/true, /*read_audio=*/true); // Write audio. (Before video, since that's what we expect on input.) if (!frame.audio.empty()) {