[libav-devel] [PATCH] movenc: check for the error in the AVIOContext and write

Luca Barbato lu_zero at gentoo.org
Thu Aug 27 13:20:33 CEST 2015


On 27/08/15 13:10, Martin Storsjö wrote:
> On Thu, 27 Aug 2015, Alexandra Hájková wrote:
> 
>> the error message if there is some error. MOV has its header
>> at the end of the file so the output will be corrupted if
>> writing to the output will fail before header is written.
> 
> This isn't true for all mov modes, only the non-fragmented ones.
> 
>> Bug-Id: 881
>> ---
>> libavformat/movenc.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index ee2f089..a6436e6 100644
>> --- a/libavformat/movenc.c
>> +++ b/libavformat/movenc.c
>> @@ -3559,6 +3559,11 @@ int ff_mov_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>     if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
>>         ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
>>                                  reformatted_data, size);
>> +    if (pb->error < 0) {
>> +        av_log(s, AV_LOG_ERROR, "Error while writing mov packet, "
>> +               "the output will be corrupted. \n");
> 
> Stray space before the newline
> 
>> +        ret = pb->error;
>> +    }
> 
> The message isn't completely true if mov->flags & FF_MOV_FLAG_FRAGMENT
> is set. I guess it still makes sense to return the error code though,
> but the file won't be corrupted, only truncated.
> 
> Even though this might be important for fixing this particular bug,
> wouldn't it make more sense to do this generically like in Sean's patch?
> Does this add anything else than just the message?
> 

I'd keep some error message mov-specific and have it also in the generic
path (in which it would be less problematic).

lu



More information about the libav-devel mailing list