[Ffmpeg-devel] Patch to add header info to flv format

Michael Niedermayer michaelni
Thu Jul 13 10:58:48 CEST 2006


Hi

On Thu, Jul 13, 2006 at 09:31:52AM +0200, Philipp Klaus wrote:
> >>I implemented a patch against ffmpeg, that adds a minimal header (meta
> >>data) to the flv video format. This is needed if you want to have the
> >>progress slider display anything in a flash video player.
> >>
> >>I've searched the ffmpeg homepage for an email address to send the patch
> >>to but have not found one. What's the usual way to send patches to this
> >>project? Send the patch to this list? Or is there a central address for
> >>every module where I have to send my patch?
> >
> >Send patches here using the unified diff format ( diff -u ).
> 
> Here it is, hope it's possible to integrate with the current source code 
> but as I looked a the CVS there wasn't much change in the flvenc.c file 
> in the last months.
> 
> Philipp
> 

> diff -ruN ffmpeg-20060317/ffmpeg.c ffmpeg-20060317_pylon/ffmpeg.c
> --- ffmpeg-20060317/ffmpeg.c	2006-03-17 14:23:28.000000000 +0100
> +++ ffmpeg-20060317_pylon/ffmpeg.c	2006-07-12 13:58:27.000000000 +0200
> @@ -1485,6 +1485,7 @@
>      AVInputStream *ist, **ist_table = NULL;
>      AVInputFile *file_table;
>      AVFormatContext *stream_no_data;
> +	int64_t total_duration = 0;

tabs are not allowed


>      int key;
>  
>      file_table= (AVInputFile*) av_mallocz(nb_input_files * sizeof(AVInputFile));
> @@ -1514,6 +1515,7 @@
>      j = 0;
>      for(i=0;i<nb_input_files;i++) {
>          is = input_files[i];
> +		total_duration += is->duration;
>          for(k=0;k<is->nb_streams;k++) {
>              ist = ist_table[j++];
>              ist->st = is->streams[k];
> @@ -1533,6 +1535,7 @@
>      nb_ostreams = 0;
>      for(i=0;i<nb_output_files;i++) {
>          os = output_files[i];
> +		os->duration = total_duration;

this is not acceptable, if a container has a field for the duration it must
contain the correct duration, not the one from the input blindly copied, which
would be wrong if -ss or -t is used and even without will be wrong for many
files
this should be calculated from the pts of the AVPackets in the muxer or
libavformat/utils.c


[...]
> +void put_amf_double(ByteIOContext *pb, double d)
> +{
> +    unsigned char *llp = (uint64_t *)&d;
> +    unsigned char nllp[8];
> +    int i;
> +    for (i = 0; i < 8; i++) {
> +        nllp[i] = llp[7-i];
> +    }
> +    put_byte(pb, AMF_DOUBLE);
> +    put_buffer(pb, nllp, 8);

this is not portable, use av_dbl2int()
... and whoever came up with the idea of using floats in a fileformat should
be shot


[...]
>  
>      return 0;
>  }
>  
> +
>  static int flv_write_trailer(AVFormatContext *s)

cosmetical change


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list