[Libav-user] How to specify output format

jim morgenstern jmorgie at yahoo.com
Mon Jan 21 22:37:03 CET 2013


Thanks again.

What I am not clear on is this -- after 

>     m_pFormatContext->oformat = m_pOutputFormat;

Sets up the whole structure, what individual fields can be tweaked and what
tweaks require further tweaking other fields ... it is not clear to me what
is connected to what.  Yr comment re avctx was helpful

jm

> -----Original Message-----
> From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org]
> On Behalf Of Paul B Mahol
> Sent: Monday, January 21, 2013 3:54 PM
> To: This list is about using libavcodec, libavformat, libavutil,
libavdevice and
> libavfilter.
> Subject: Re: [Libav-user] How to specify output format
> 
> On 1/21/13, jim morgenstern <jmorgie at yahoo.com> wrote:
> > So this is the piece to the puzzle I am missing:
> >
> > * where does one set the output pixel format / video codec to
> > CODEC_ID_RAWVIDEO ?
> > I have
> >> >     m_pOutputFormat = av_guess_format(NULL, filename, NULL);
> >> >     m_pFormatContext = avformat_alloc_context();
> >> >     m_pFormatContext->oformat = m_pOutputFormat;
> >
> > So after I get a format context then I can go in and tweak the various
> > fields?
> 
> m_pFormatContext->oformat->video_codec = CODEC_ID_RAWVIDEO.
> 
> When initialzing encoder you specify pix_fmt: example:
> avctx->pix_fmt = PIX_FMT_YUV420P;
> 
> There is example code:
> 
> http://git.videolan.org/?p=ffmpeg.git;a=blob;f=doc/examples/muxing.c
> 
> > Sure wish someone would write a book
> >
> > Thanks
> >
> >
> >
> >> -----Original Message-----
> >> From: libav-user-bounces at ffmpeg.org
> >> [mailto:libav-user-bounces at ffmpeg.org]
> >> On Behalf Of Paul B Mahol
> >> Sent: Monday, January 21, 2013 1:06 PM
> >> To: This list is about using libavcodec, libavformat, libavutil,
> > libavdevice and
> >> libavfilter.
> >> Subject: Re: [Libav-user] How to specify output format
> >>
> >> On 1/21/13, jim morgenstern <jmorgie at yahoo.com> wrote:
> >> > Paul -- couple of problems
> >> >
> >> > I did as you suggested and specified the output file as:  *.nut
> >> > **  ffmpeg associates the MPEG4 codec with this output and I want
> >> > uncompressed
> >> > **  the audio stream bombs
> >> >
> >> > Thanks for any help you can provide
> >>
> >> I said you must set video codec to rawvideo aka CODEC_ID_RAWVIDEO.
> >>
> >> >
> >> > Here is a code snippet, then screen output from ffmpeg:
> >> > =========
> >> >
> >> >     m_pOutputFormat = av_guess_format(NULL, filename, NULL);
> >> >     m_pFormatContext = avformat_alloc_context();
> >> >     m_pFormatContext->oformat = m_pOutputFormat;
> >> >     _snprintf_s(m_pFormatContext->filename,
> >> > sizeof(m_pFormatContext->filename), "%s", filename);
> >> >
> >> > // add the audio and video streams using the default format codecs
> >> > and initialize the codecs.
> >> >     m_pAudioStream = NULL;
> >> >     if (m_pOutputFormat->audio_codec != CODEC_ID_NONE)
> >> >    {
> >> >         m_pAudioStream = add_audio_stream(m_pFormatContext,
> >> > m_pOutputFormat->audio_codec, channels);
> >> >     }
> >> > // and the abort comes from add_audio_stream
> ==================
> >> >
> >> > Starting MediaFileIO for D:\Data\Solavei.mov
> >> >
> >> > [mov,mp4,m4a,3gp,3g2,mj2 @ 00ad3320] Stream #1: not enough frames
> >> > to estimate ra te; consider increasing probesize
> >> > [mov,mp4,m4a,3gp,3g2,mj2 @ 00ad3320] Stream #2: not enough frames
> >> > to estimate ra te; consider increasing probesize
> >> >
> >> > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Data\Solavei.mov':
> >> >   Metadata:
> >> >     major_brand     : qt
> >> >     minor_version   : 537199360
> >> >     compatible_brands: qt
> >> >     creation_time   : 2012-07-12 23:41:43
> >> >   Duration: 00:00:11.81, start: 0.000000, bitrate: 598161 kb/s
> >> >     Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le,
> >> > 1280x720, 59
> >> > 6600 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc
> >> >     Metadata:
> >> >       creation_time   : 2012-07-12 23:41:43
> >> >       handler_name    : Apple Alias Data Handler
> >> >     Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000
> >> > Hz, stereo, s1 6, 1536 kb/s
> >> >     Metadata:
> >> >       creation_time   : 2012-07-12 23:41:43
> >> >       handler_name    : Apple Alias Data Handler
> >> >     Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
> >> >     Metadata:
> >> >       creation_time   : 2012-07-12 23:42:01
> >> >       handler_name    : Apple Alias Data Handler
> >> >       timecode        : 00:00:28;11
> >> >
> >> >
> >> > Starting MediaFileIO for => D:\Data\TestSol.nut Output #0, nut, to
> >> > 'D:\Data\TestSol.nut':
> >> >     Stream #0:0: Video: mpeg4, yuv420p, 1280x720, q=2-31, 5942
> >> > kb/s, 90k tbn, 29  tbc
> >> >     Stream #0:1: Audio: vorbis, 44100 Hz, 1 channels, s16, 64 kb/s
> >> > [libvorbis @ 054e20c0] Specified sample_fmt is not supported.
> >> >
> >> > File Initialization Exception: output !!
> >> >  MediaFileWriter::open_audio: Could not open audio codec   //this is
my
> > app
> >> > error message
> >>
> >> You want to store audio? If yes. What codec?
> >>
> >>
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: libav-user-bounces at ffmpeg.org
> >> >> [mailto:libav-user-bounces at ffmpeg.org]
> >> >> On Behalf Of Paul B Mahol
> >> >> Sent: Monday, January 21, 2013 11:26 AM
> >> >> To: This list is about using libavcodec, libavformat, libavutil,
> >> > libavdevice and
> >> >> libavfilter.
> >> >> Subject: Re: [Libav-user] How to specify output format
> >> >>
> >> >> On 1/21/13, jim morgenstern <jmorgie at yahoo.com> wrote:
> >> >> > Paul
> >> >> > Thanks for the specifics.  I don't like headerless so .raw and
> >> >> > .yuv are out.
> >> >> >
> >> >> > Hadn't heard of .nut;  I don't understand your comment about
> >> >> > -vcodec
> >> > etc.
> >> >> > I am writing a C++ app not using the command line utilities.
> >> >>
> >> >> I mean video codec should be set to rawvideo. And pixel format for
> >> >> that
> >> > codec
> >> >> should be same as one detected in input.
> >> >>
> >> >> >
> >> >> > So what all do I need to know about .nut?  Googled but cannot
> >> >> > find any definitions or spec for the file.  Can you send a url?
> >> >>
> >> >> You really should not need know anything, you just set output
> >> >> format to
> >> > nut and
> >> >> it is all what is needed. I doubt you want nut spec if you gonna
> >> >> use
> >> > libavformat to
> >> >> read nut files.
> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> >> -----Original Message-----
> >> >> >> From: libav-user-bounces at ffmpeg.org
> >> >> >> [mailto:libav-user-bounces at ffmpeg.org]
> >> >> >> On Behalf Of Paul B Mahol
> >> >> >> Sent: Monday, January 21, 2013 10:41 AM
> >> >> >> To: This list is about using libavcodec, libavformat,
> >> >> >> libavutil,
> >> >> > libavdevice and
> >> >> >> libavfilter.
> >> >> >> Subject: Re: [Libav-user] How to specify output format
> >> >> >>
> >> >> >> On 1/21/13, jim morgenstern <jmorgie at yahoo.com> wrote:
> >> >> >> > So what Specifically is the specific format extension that I
> >> >> >> > give to ffmpeg that gives me the "raw video format" you cited?
> >> >> >>
> >> >> >> Headerless : .raw, .yuv (You need to remember pixel format and
> >> >> >> dimensions stored in it)
> >> >> >>
> >> >> >> With headers : .nut (You must use -vcodec rawvideo and -pix_fmt
> >> >> >> same as
> >> >> > your
> >> >> >> input video
> >> >> >>                      to keep video uncompressed)
> >> >> >>     There are others like .avi, .. but they may not support
> >> >> >> pixel format
> >> >> > of your
> >> >> >> input video.
> >> >> >>
> >> >> >> >
> >> >> >> >> -----Original Message-----
> >> >> >> >> From: libav-user-bounces at ffmpeg.org
> >> >> >> >> [mailto:libav-user-bounces at ffmpeg.org]
> >> >> >> >> On Behalf Of Paul B Mahol
> >> >> >> >> Sent: Monday, January 21, 2013 9:50 AM
> >> >> >> >> To: This list is about using libavcodec, libavformat,
> >> >> >> >> libavutil,
> >> >> >> > libavdevice and
> >> >> >> >> libavfilter.
> >> >> >> >> Subject: Re: [Libav-user] How to specify output format
> >> >> >> >>
> >> >> >> >> On 1/21/13, jim morgenstern <jmorgie at yahoo.com> wrote:
> >> >> >> >> >>> where can I find the list of formats and their extensions?
> >> >> >> >> >> In the source code
> >> >> >> >> >
> >> >> >> >> > Yes but the source code is hundreds of files;  can you
> >> >> >> >> > tell me which one has the list and the mapping?
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >> > .       What is your recommended format for uncompressed
> HD
> >> >> video
> >> >> > ?
> >> >> >> >> >>
> >> >> >> >> >> libx264 is the state of the art encode
> >> >> >> >> >
> >> >> >> >> > But I do not want any encoding or compression:  I want
> >> >> >> >> > flat file that can be read later on for more processing.
> >> >> >> >> > So is there a recommendation for a particular file format
> >> >> >> >> > that does
> > this?
> >> >> >> >>
> >> >> >> >> Depends on what you gonna use for more processing later.
> >> >> >> >> Depending on available storage and CPU speed you could use
> >> >> >> >> raw video formats...
> >> >> >> >>
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >> -----Original Message-----
> >> >> >> >> >> From: libav-user-bounces at ffmpeg.org
> >> >> >> >> >> [mailto:libav-user-bounces at ffmpeg.org]
> >> >> >> >> >> On Behalf Of Stefano Sabatini
> >> >> >> >> >> Sent: Monday, January 21, 2013 7:50 AM
> >> >> >> >> >> To: This list is about using libavcodec, libavformat,
> >> >> >> >> >> libavutil,
> >> >> >> >> > libavdevice and
> >> >> >> >> >> libavfilter.
> >> >> >> >> >> Subject: Re: [Libav-user] How to specify output format
> >> >> >> >> >>
> >> >> >> >> >> In data Saturday 2013-01-19 01:55:22 -0500, Jim
> >> >> >> >> >> Morgenstern ha
> >> >> >> >> >> scritto:
> >> >> >> >> >> > I have C++ app [win 7]  that is reading and writing
> >> >> >> >> >> > video/audio
> >> >> >> > stream.
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> > When I specify the output file as xxxx.MOV I am getting
> >> >> >> >> >> > H264 compressed video at 24 fps.
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> > I want to have output as uncompressed at 30 or 60 fps
> >> >> >> >> >> > according to the input.
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> >
> >> >> >> >> >> > Some simple [I hope] questions:
> >> >> >> >> >> >
> >> >> >> >> >> > .       What is [where can I find] the mapping between
file
> >> > name
> >> >> >> >> > extension
> >> >> >> >> >> > and format used?
> >> >> >> >> >>
> >> >> >> >> >> In the source code, or you can show the ".extensions"
> >> >> >> >> >> field for all the
> >> >> >> >> > registered
> >> >> >> >> >> AVInput/OutputFormats.
> >> >> >> >> >>
> >> >> >> >> >> >
> >> >> >> >> >> > .       Can I specify the output format I want rather
than
> >> > using
> >> >> >> >> >> > av_guess_format ?  all the tutorials use guess
> >> >> >> >> >>
> >> >> >> >> >> Yes, you need to specify avformat_alloc_output_context2()
> >> >> >> >> >> and rely on oformat/format_name parameters, or use
> >> >> >> >> >> av_guess_format().
> >> >> >> >> >>
> >> >> >> >> >> >
> >> >> >> >> >> > .       What is your recommended format for uncompressed
> HD
> >> >> video
> >> >> > ?
> >> >> >> >> >>
> >> >> >> >> >> libx264 is the state of the art encoder (but it has
> >> >> >> >> >> licensing
> >> >> >> >> > constraints).
> >> >> >> >> >> _______________________________________________
> >> >> >> >> >> Libav-user mailing list
> >> >> >> >> >> Libav-user at ffmpeg.org
> >> >> >> >> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >> >> >
> >> >> >> >> > _______________________________________________
> >> >> >> >> > Libav-user mailing list
> >> >> >> >> > Libav-user at ffmpeg.org
> >> >> >> >> > http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >> >> >
> >> >> >> >> _______________________________________________
> >> >> >> >> Libav-user mailing list
> >> >> >> >> Libav-user at ffmpeg.org
> >> >> >> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >> >
> >> >> >> > _______________________________________________
> >> >> >> > Libav-user mailing list
> >> >> >> > Libav-user at ffmpeg.org
> >> >> >> > http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >> >
> >> >> >> _______________________________________________
> >> >> >> Libav-user mailing list
> >> >> >> Libav-user at ffmpeg.org
> >> >> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >
> >> >> > _______________________________________________
> >> >> > Libav-user mailing list
> >> >> > Libav-user at ffmpeg.org
> >> >> > http://ffmpeg.org/mailman/listinfo/libav-user
> >> >> >
> >> >> _______________________________________________
> >> >> Libav-user mailing list
> >> >> Libav-user at ffmpeg.org
> >> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >> >
> >> > _______________________________________________
> >> > Libav-user mailing list
> >> > Libav-user at ffmpeg.org
> >> > http://ffmpeg.org/mailman/listinfo/libav-user
> >> >
> >> _______________________________________________
> >> Libav-user mailing list
> >> Libav-user at ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/libav-user
> >
> > _______________________________________________
> > Libav-user mailing list
> > Libav-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/libav-user
> >
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list