[FFmpeg-devel] Patch for output_example.c

Peeyush Mishra pmishra
Thu Dec 18 11:35:28 CET 2008


This patch is no working  at all 
-----Original Message-----
From: ffmpeg-devel-bounces at mplayerhq.hu
[mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of Steve Allen
Sent: Thursday, December 18, 2008 3:14 PM
To: ffmpeg-devel at mplayerhq.hu
Subject: [FFmpeg-devel] Patch for output_example.c

Hi,

The example output code works fine with the MPEG4 codec but fails with the
H264 codec.  The reason for H264's difficulties lie in the
"ff_avc_parse_nal_units" routine which reassigns the packet buffer following
the conversion from stream to file format NAL codes. The reassignment then
breaks the video_outbuf in the output_example.c code.

My suggested solution is to place an av_dup_packet() and av_free_packet()
call around the av_write_frame() routine so that only the temporary pkt gets
reassigned and no the video_outbuf.

The problem can be seen by generating a ".mp4" file and forcing the codec to
be H264 (rather than the defaut MPEG4)

    /* allocate the output media context */
    oc = av_alloc_format_context();
    if (!oc) {
        fprintf(stderr, "Memory error\n");
        exit(1);
    }

    // Force video codec
    fmt->video_codec = CODEC_ID_H264;


Kind regards,

Steve


--- ffmpeg.orig\output_example.c          2008-12-18 09:22:39.470000000
+0000
+++ ffmpeg\output_example.c 2008-12-18 09:33:55.296000000 +0000
@@ -388,9 +388,11 @@
             pkt.stream_index= st->index;
             pkt.data= video_outbuf;
             pkt.size= out_size;
+            av_dup_packet(&pkt);    // Added SRA

             /* write the compressed frame in the media file */
             ret = av_write_frame(oc, &pkt);
+            av_free_packet(&pkt);   // Added SRA
         } else {
             ret = 0;
         }

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008 12:00
AM
 
    

No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008 12:00
AM
 





More information about the ffmpeg-devel mailing list