av_dump_format needs the codecs opened in order to print them.
---
 libavformat/output-example.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/output-example.c b/libavformat/output-example.c
index a467109..195f9df 100644
--- a/libavformat/output-example.c
+++ b/libavformat/output-example.c
@@ -147,8 +147,10 @@ static void write_audio_frame(AVFormatContext *oc, 
AVStream *st)
 
     get_audio_frame(samples, audio_input_frame_size, c->channels);
     frame->nb_samples = audio_input_frame_size;
-    avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, (uint8_t 
*)samples,
-                             audio_input_frame_size * 
av_get_bytes_per_sample(c->sample_fmt)
+    avcodec_fill_audio_frame(frame, c->channels,
+                             c->sample_fmt, (uint8_t *)samples,
+                             audio_input_frame_size *
+                             av_get_bytes_per_sample(c->sample_fmt)
                              * c->channels, 1);
 
     avcodec_encode_audio2(c, &pkt, frame, &got_packet);
@@ -464,8 +466,6 @@ int main(int argc, char **argv)
         audio_st = add_audio_stream(oc, fmt->audio_codec);
     }
 
-    av_dump_format(oc, 0, filename, 1);
-
     /* now that all the parameters are set, we can open the audio and
        video codecs and allocate the necessary encode buffers */
     if (video_st)
@@ -473,6 +473,8 @@ int main(int argc, char **argv)
     if (audio_st)
         open_audio(oc, audio_st);
 
+    av_dump_format(oc, 0, filename, 1);
+
     /* open the output file, if needed */
     if (!(fmt->flags & AVFMT_NOFILE)) {
         if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
-- 
1.7.8.rc1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to