[Libav-user] Problems with H.264 encoding for MP4 files on macOS
Gonzalo Garramuño
ggarra13 at gmail.com
Sun Jan 29 22:29:19 EET 2017
El 27/01/17 a las 11:14, films escribió:
> Hi Folks.
>
> I am trying to write .mp4 files with H.264 and AAC from generated
> images and audio. My app is linked to libAVFormat, libAVCodec etc plus
> some necessary OSX frameworks
>
> If I let libAVFormat select the codecs for a file named xxxxx.mp4
> using av_guess_format() it selects the MPEG4 and AAC encoders and
> everything is working **fine**
>
> However, I really need to use the H.264 codec instead of the MPEG4
> video codec, so I have tried overriding the guessed codec by simply
> adding this after the av_guess_format stage.
>
> fmt->video_codec = AV_CODEC_ID_H264;
>
I don't have any MacOSX experience, but if you specify the codec, you
don't need to call av_guess_format. Here's a sample of my code:
static AVFormatContext *oc = NULL;
...
int err = avformat_alloc_output_context2(&oc, NULL, NULL, filename);
if (!oc || err < 0) {
LOG_WARNING( _("Could not deduce output format from file
extension: using MPEG.") );
err = avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
if ( err < 0 )
{
LOG_ERROR( _("Could not open mpeg movie") );
return false;
}
}
oc->flags |= AVFMT_FLAG_NOBUFFER|AVFMT_FLAG_FLUSH_PACKETS;
oc->max_interleave_delta = 1;
fmt = oc->oformat;
assert( fmt != NULL );
fmt->video_codec = AV_CODEC_ID_H264;
--
Gonzalo Garramuño
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20170129/a8e18262/attachment.html>
More information about the Libav-user
mailing list