Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
multimedia:apps
DVDStyler
DVDStyler-ffmpeg7.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File DVDStyler-ffmpeg7.patch of Package DVDStyler
Index: DVDStyler-3.2.1/src/mediaenc_ffmpeg.cpp =================================================================== --- DVDStyler-3.2.1.orig/src/mediaenc_ffmpeg.cpp +++ DVDStyler-3.2.1/src/mediaenc_ffmpeg.cpp @@ -30,6 +30,7 @@ extern "C" { #include <libswscale/swscale.h> #include <libavutil/mathematics.h> #include <libavutil/avstring.h> +#include <libavutil/channel_layout.h> #include <libavcodec/avcodec.h> } @@ -297,8 +298,14 @@ bool wxFfmpegMediaEncoder::addAudioStrea c->bit_rate = 64000; c->sample_rate = 48000; c->sample_fmt = sampleFmt; - c->channels = 2; - c->channel_layout = AV_CH_LAYOUT_STEREO; + + AVChannelLayout chLayoutStereo; + av_channel_layout_default(&chLayoutStereo, 2); + if (av_channel_layout_copy(&c->ch_layout, &chLayoutStereo)) { + wxLogError("Failed to set 2 channels"); + return false; + } + if (m_audioStm && avcodec_parameters_from_context(m_audioStm->codecpar, c) < 0) { wxLogError("Failed to copy encoder parameters to output audio stream"); return false; @@ -306,7 +313,7 @@ bool wxFfmpegMediaEncoder::addAudioStrea if (avcodec_open2(c, encoder, NULL) < 0) { - wxLogError(wxT("Could not open audio codec")); + wxLogError("Could not open audio codec"); return false; } @@ -318,7 +325,10 @@ bool wxFfmpegMediaEncoder::addAudioStrea m_audioFrame->nb_samples = c->frame_size; m_audioFrame->format = c->sample_fmt; - m_audioFrame->channel_layout = c->channel_layout; + if (av_channel_layout_copy(&m_audioFrame->ch_layout, &c->ch_layout) < 0) { + wxLogError("Could not open copy channel layout"); + return false; + } int ret = av_frame_get_buffer(m_audioFrame, 0); // allocate the data buffers if (ret < 0) { @@ -328,7 +338,7 @@ bool wxFfmpegMediaEncoder::addAudioStrea ret = av_frame_make_writable(m_audioFrame); if (ret < 0) return false; - for (int i = 0; i < c->channels; i++) { + for (int i = 0; i < c->ch_layout.nb_channels; i++) { uint16_t *samples = (uint16_t*)m_audioFrame->data[i]; memset(samples, 0, c->frame_size * av_get_bytes_per_sample(c->sample_fmt)); } @@ -492,30 +502,29 @@ int encode(AVCodecContext *avctx, AVPack } bool wxFfmpegMediaEncoder::writeAudioFrame() { - AVPacket pkt = { 0 }; // data and size must be 0; - int got_packet; - - av_init_packet(&pkt); + AVPacket* pkt = av_packet_alloc(); AVCodecContext *c = m_audioCodec; m_audioFrame->pts = m_nextAudioPts; m_nextAudioPts += m_audioFrame->nb_samples; - encode(c, &pkt, m_audioFrame, &got_packet); + + int got_packet = 0; + encode(c, pkt, m_audioFrame, &got_packet); if (!got_packet) { - av_packet_unref(&pkt); + av_packet_unref(pkt); return true; } - pkt.stream_index = m_audioStm->index; + pkt->stream_index = m_audioStm->index; // write the compressed frame in the media file - int ret = av_interleaved_write_frame(m_outputCtx, &pkt); + int ret = av_interleaved_write_frame(m_outputCtx, pkt); if (ret < 0) { - av_packet_unref(&pkt); + av_packet_unref(pkt); print_error("Error while writing audio frame", ret); return false; } - av_packet_unref(&pkt); + av_packet_unref(pkt); return true; } @@ -524,34 +533,33 @@ bool wxFfmpegMediaEncoder::writeVideoFra // encode the image m_picture->pts = m_nextVideoPts++; - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = m_videoOutbuf; - pkt.size = VIDEO_BUF_SIZE; + AVPacket* pkt = av_packet_alloc(); + pkt->data = m_videoOutbuf; + pkt->size = VIDEO_BUF_SIZE; int got_packet = 0; - int ret = encode(c, &pkt, m_picture, &got_packet); + int ret = encode(c, pkt, m_picture, &got_packet); if (ret < 0) { - av_packet_unref(&pkt); + av_packet_unref(pkt); print_error("Error while writing video frame", ret); return false; } if (got_packet) { - if (pkt.pts != (int64_t) AV_NOPTS_VALUE) - pkt.pts = av_rescale_q(pkt.pts, c->time_base, m_videoStm->time_base); - if (pkt.dts != (int64_t) AV_NOPTS_VALUE) - pkt.dts = av_rescale_q(pkt.dts, c->time_base, m_videoStm->time_base); - pkt.stream_index = m_videoStm->index; + if (pkt->pts != (int64_t) AV_NOPTS_VALUE) + pkt->pts = av_rescale_q(pkt->pts, c->time_base, m_videoStm->time_base); + if (pkt->dts != (int64_t) AV_NOPTS_VALUE) + pkt->dts = av_rescale_q(pkt->dts, c->time_base, m_videoStm->time_base); + pkt->stream_index = m_videoStm->index; // write the compressed frame in the media file - ret = av_interleaved_write_frame(m_outputCtx, &pkt); + ret = av_interleaved_write_frame(m_outputCtx, pkt); if (ret < 0) { - av_packet_unref(&pkt); + av_packet_unref(pkt); print_error("Error while writing video frame", ret); return false; } } - av_packet_unref(&pkt); + av_packet_unref(pkt); return true; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor