[FFmpeg-devel] [PATCH] lavf/webm_chunk: Use dyn_buf to write chunks

Vignesh Venkatasubramanian vigneshv at google.com
Thu Apr 30 20:35:19 CEST 2015


On Thu, Apr 30, 2015 at 11:10 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Thu, Apr 30, 2015 at 09:55:59AM -0700, Vignesh Venkatasubramanian wrote:
>> Use dyn_duf to write chunks so that we create the actual chunk
>> file only after the entire chunk data is available. This will help
>> not confuse other software looking at the chunk file (e.g. a web
>> server) by seeing a zero length file when ffmpeg is writing into
>> it.
>>
>> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
>> ---
>>  libavformat/webm_chunk.c | 46 ++++++++++++++++++++++++++++------------------
>>  1 file changed, 28 insertions(+), 18 deletions(-)
>>
>> diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
>> index 6d3d5d6..892fd7f 100644
>> --- a/libavformat/webm_chunk.c
>> +++ b/libavformat/webm_chunk.c
>> @@ -46,7 +46,6 @@ typedef struct WebMChunkContext {
>>      int chunk_start_index;
>>      char *header_filename;
>>      int chunk_duration;
>> -    int chunk_count;
>>      int chunk_index;
>>      uint64_t duration_written;
>>      int prev_pts;
>> @@ -86,18 +85,21 @@ static int chunk_mux_init(AVFormatContext *s)
>>      return 0;
>>  }
>>
>> -static int set_chunk_filename(AVFormatContext *s, int is_header)
>> +static int get_chunk_filename(AVFormatContext *s, int is_header, char *filename)
>>  {
>>      WebMChunkContext *wc = s->priv_data;
>>      AVFormatContext *oc = wc->avf;
>> +    if (!filename) {
>> +        return AVERROR(EINVAL);
>> +    }
>>      if (is_header) {
>>          if (!wc->header_filename) {
>>              return AVERROR(EINVAL);
>>          }
>> -        av_strlcpy(oc->filename, wc->header_filename, strlen(wc->header_filename) + 1);
>> +        av_strlcpy(filename, wc->header_filename, strlen(wc->header_filename) + 1);
>>      } else {
>> -        if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
>> -                                  s->filename, wc->chunk_index) < 0) {
>
>> +        if (av_get_frame_filename(filename, 1024,
>                                                ^^^^
> please use a named identifer instead of the litteral number
> [...]
>> +    char filename[1024];
>

done.
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are too smart to engage in politics are punished by being
> governed by those who are dumber. -- Plato
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>



-- 
Vignesh


More information about the ffmpeg-devel mailing list