[FFmpeg-devel] [PATCH] FLV meta injection (similar toFLVTOOLS2but an addon patch for FFMPEG)

andrew andrew
Sun Aug 12 13:45:08 CEST 2007


Please find the modified patch conforming to the 8.6 and 8.7 rules. If there are still problem could I have a hint of which rule I have broken? =) I think I got it all now but perhaps I make mistake, its the first opensource project i have submitted to.

8.6
point 19: Did you provide an example so we can verify the new feature added by the patch easily?

an example of the meta injection can be found here: http://www.butkus.co.uk/static/projects/ffmpeg/example.php

Thanks

> Hi
> 
> On Sun, Aug 12, 2007 at 12:14:57AM +0000, andrew wrote:
> > I added FLV meta injection, I was working on a project similar to youtube a while ago and found ffmpeg didn't support meta tags for framing. This would mean flash actionscript couldnt get information on video points for scrolling. There is a tool which does the seperately called FLVTOOLS2 but is written in ruby and my webserver didnt have ruby installed so I added my own patch to FFMPEG and wanted to offer it.
> > 
> > Ive added a new argument called -flvmeta_inject , so people can toggle my patch or ignore it and use the old method without meta injection. example usage: 
> > 
> > ./ffmpeg -y -i einstein_redspot.avi -acodec mp3 -ar 22050 -flvmeta_inject -f flv einstein.flv
> 
> [...]
> 
> please read 8.5 and 8.6 from http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
> 
> 
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c	(revision 10065)
> > +++ ffmpeg.c	(working copy)
> > @@ -33,6 +33,7 @@
> >  #include "opt.h"
> >  #include "fifo.h"
> >  #include "avstring.h"
> > +#include "flvenc.c"
> 
> are you serious?
> 
> 
> >  
> >  #if !defined(HAVE_GETRUSAGE) && defined(HAVE_GETPROCESSTIMES)
> >  #include <windows.h>
> > @@ -2404,6 +2405,11 @@
> >          video_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
> >  }
> >  
> > +static void opt_flvmeta_inject()
> > +{
> > +    flvmeta_inject = 1;        	
> > +}
> 
> trailing whitespace and what is this option good for?
> 
> 
> > +
> >  #ifdef CONFIG_VHOOK
> >  static void add_frame_hooker(const char *arg)
> >  {
> > @@ -2755,7 +2761,7 @@
> >  
> >          video_enc->codec_id = codec_id;
> >          codec = avcodec_find_encoder(codec_id);
> > -
> > +        
> 
> cosmetic
> 
> >          for(i=0; i<opt_name_count; i++){
> >               const AVOption *opt;
> >               double d= av_get_double(avctx_opts[CODEC_TYPE_VIDEO], opt_names[i], &opt);
> > @@ -3675,7 +3681,8 @@
> >      { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
> >      { "newvideo", OPT_VIDEO, {(void*)opt_new_video_stream}, "add a new video stream to the current output stream" },
> >      { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
> > -
> > +    { "flvmeta_inject", 0, {(void*)opt_flvmeta_inject}, "add flv meta keyframe data" },
> 
> > +    
> 
> cosmetic
> 
> 
> >      /* audio options */
> >      { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[CODEC_TYPE_AUDIO]}, "set the number of audio frames to record", "number" },
> >      { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
> > Index: cmdutils.c
> > ===================================================================
> > --- cmdutils.c	(revision 10065)
> > +++ cmdutils.c	(working copy)
> > @@ -66,7 +66,7 @@
> >      const char *opt, *arg;
> >      int optindex, handleoptions=1;
> >      const OptionDef *po;
> > -
> > + 
> >      /* parse options */
> 
> cosmetic
> 
> 
> >      optindex = 1;
> >      while (optindex < argc) {
> > Index: libavformat/flvenc.c
> > ===================================================================
> > --- libavformat/flvenc.c	(revision 10065)
> > +++ libavformat/flvenc.c	(working copy)
> > @@ -25,6 +25,8 @@
> >  #undef NDEBUG
> >  #include <assert.h>
> >  
> > +static int flvmeta_inject = 0;   
> > +
> 
> non constant static
> 
> 
> >  static const AVCodecTag flv_video_codec_ids[] = {
> >      {CODEC_ID_FLV1,    FLV_CODECID_H263  },
> >      {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
> > @@ -45,7 +47,13 @@
> >  typedef struct FLVContext {
> >      int hasAudio;
> >      int hasVideo;
> > +    int hasMetaData;
> >      int reserved;
> 
> > +    
> 
> cosmetic
> 
> [...]
> > @@ -163,6 +171,7 @@
> >          }
> >          av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */
> >      }
> > +    
> 
> cosmtic
> 
> >      put_tag(pb,"FLV");
> >      put_byte(pb,1);
> >      put_byte(pb,   FLV_HEADER_FLAG_HASAUDIO * flv->hasAudio
> > @@ -183,7 +192,7 @@
> >  
> >      /* write meta_tag */
> >      put_byte(pb, 18);         // tag type META
> > -    metadata_size_pos= url_ftell(pb);
> > +    metadata_size_pos = url_ftell(pb);
> 
> cosmetic
> 
> 
> >      put_be24(pb, 0);          // size of data part (sum of all parts below)
> >      put_be24(pb, 0);          // time stamp
> >      put_be32(pb, 0);          // reserved
> > @@ -201,7 +210,52 @@
> >      put_amf_string(pb, "duration");
> >      flv->duration_offset= url_ftell(pb);
> >      put_amf_double(pb, 0); // delayed write
> > +    
> > +    flv->hasMetaData = flvmeta_inject;
> 
> cosmetic
> 
> 
> [...]
> > @@ -258,12 +312,41 @@
> >      FLVContext *flv = s->priv_data;
> >  
> >      file_size = url_ftell(pb);
> > +    
> > +    int duration = flv->duration / (double)1000;
> >  
> >      /* update informations */
> >      url_fseek(pb, flv->duration_offset, SEEK_SET);
> > -    put_amf_double(pb, flv->duration / (double)1000);
> > +    put_amf_double(pb, duration);
> 
> cosmetic
> 
> 
> 
> >      url_fseek(pb, flv->filesize_offset, SEEK_SET);
> >      put_amf_double(pb, file_size);
> > +    
> 
> cosmetic
> 
> 
> [...]
> 
> > +        if (duration < flvduration)
> > +            flvduration = (duration);
> > +            
> > +        int steptime = duration / flvduration;  
> 
> mixes declaration and statement, trailing whitespace
> 
> 
> [...]
> 
> > -
> > +    
> 
> cosmetic
> 
> 
> [...]
> > @@ -42,6 +42,13 @@
> >  
> >  #define AMF_END_OF_OBJECT         0x09
> >  
> > +#define NUM_OF_ENTRIES 20
> > +
> > +#define AMF_CHILDNODE       3
> > +#define AMF_CHILDNODEVALUE  10
> > +#define AMF_PARENTNODE      9
> > +
> 
> these belong in the enum where the other AMF types are
> 
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> The educated differ from the uneducated as much as the living from the
> dead. -- Aristotle 
> 
> 

Andrew Butkus
butkus.co.uk

My public key for contacting me securely:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.6 (GNU/Linux)

mQGiBEa4PeMRBADajg5zW8sM2AkcVfXf/xwKM0mc39MpSLCUwGib5riy4RVpzy4g
tSvq5s1xpgyaovKiSbRG36PiArrymnHq9O1qCp6+qWqdhaqxuk37LoABQbQ9sXxu
0jPYASRN1kTR2tJLklCpmYGvkXPsXe9tx2hBUur6aRbhbkdJyaNCf8JwhwCgkzOC
ayExrr0DFOiUzXY3XDorFe8EAJgEgIETrS28RHnKh5fOQNp6MYQjmoo7JINXwZTd
M7WehjbLnytlkBieRAT0Ex8FOesxBS1KkS32xFcN91noiXpOYo/7UcUB1kBXLrdW
3FhtGRnBLVMfQljFePhR5BclY/LSKIjwtVBimVd4qQMrYYo3AtGtSz8/VDSSgRlm
qnADA/44AGz2/qkSormq2aAh7WFGszoAtywc+RTNwskUPboDSfn3cBdmwTcqG2dJ
K2oiL7HaXuj+Nga8omk4wQdUnig02btc+lLlxkHCW00mfdlblQswpbwEwlZa4Mtl
hlAreQP1oNTvRcLWPzrC7CqBkOUPxvilipP3c4HWXYrSXsqPGLQ7QW5kcmV3IEJ1
dGt1cyAoQW5kcmV3J3MgR1BHIGtleSBwYWlyKSA8YW5kcmV3QGJ1dGt1cy5jby51
az6IYAQTEQIAIAUCRrg94wIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJENJ5
Bj3tTq6WEu0AnAsYEPElmoDEzIdbTZJgIWTMeSqdAJ9GrLmAY0fwCyt2l6DC9+IQ
fGen6rkCDQRGuD3oEAgA714L70CoVgdTphWoza4AW7n4WA7NhgWOsTf/uyV8XV5N
6FIvrAWSbueIGnpSYeyEiaQeEsCx5VltWZ5BxxSpWl1vmPwWd5OplUFx2dOpXP+N
BEghG+StFRVPl350IB3WAvWJHOcbxpWwefnc8kG5GUWZSCY0rrOq4/AZaEdmMwrh
hMmXUUEJnkO4nLjQgkNIQO9dVzVX+Cm8AuhYqyz2htp7nW6kIq5AFEmk7WZ4PaKZ
6fs0KwSF0n978hf8/IprDSNgUOirXtfTxUvB21/lBVY07FrgN5mncKEt1SN3mIny
++GYlYFWkPVrT3YAymAxXHFl7kjzki3SE0ugAOrgWwADBgf9E1gK3d9EGmmwAevG
ZR77toj1kUnkta0ZnnZ0bd+cs9L/VWUBrA4Hk4fsXiLw94yAZyUyMA6topEi7vcD
JV/hTxtgb+xfnXygdzXtaG3sJlKYOv72aVnvfiELn5lKwOpGPmIyNKry51Pg2UFd
nzrgjrI5gHczEFjd4kC5l/Midi3XtY5EsfjMuDdN9+Ccs/P+JTSBv+bRSLMdNVrv
4F/Rvlz0d8eek2MgO5OnvSaXFr+1s+/+tb5bTAwA1MVUOGt3GjgFWk8rLim/9ESF
OMfTljs1GJp0sVsZ4wwNN+gqEg7vdXQsslqdkbbHNWbbbDa54OKG0y9T/nc1UbCM
wpul0IhJBBgRAgAJBQJGuD3oAhsMAAoJENJ5Bj3tTq6WUzcAoJIVpSZAYflDWhlh
mamFWG+xnRwtAKCLvw9B8LpfAYcvSTWhWvFldz0AAw==
=PDDZ
-----END PGP PUBLIC KEY BLOCK-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 6930 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070812/f613996d/attachment.obj>



More information about the ffmpeg-devel mailing list