mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
fftools/ffmpeg: refactor limiting output file size with -fs
Move the file size checking code to ffmpeg_mux. Use the recently introduced of_filesize(), making this code consistent with the size shown by print_report().
This commit is contained in:
parent
81af4dec27
commit
d8e944c238
4 changed files with 14 additions and 8 deletions
|
|
@ -33,6 +33,8 @@
|
|||
#include "libavformat/avio.h"
|
||||
|
||||
struct Muxer {
|
||||
/* filesize limit expressed in bytes */
|
||||
int64_t limit_filesize;
|
||||
int header_written;
|
||||
};
|
||||
|
||||
|
|
@ -322,7 +324,7 @@ void of_close(OutputFile **pof)
|
|||
av_freep(pof);
|
||||
}
|
||||
|
||||
int of_muxer_init(OutputFile *of)
|
||||
int of_muxer_init(OutputFile *of, int64_t limit_filesize)
|
||||
{
|
||||
Muxer *mux = av_mallocz(sizeof(*mux));
|
||||
|
||||
|
|
@ -331,9 +333,16 @@ int of_muxer_init(OutputFile *of)
|
|||
|
||||
of->mux = mux;
|
||||
|
||||
mux->limit_filesize = limit_filesize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_finished(OutputFile *of)
|
||||
{
|
||||
return of_filesize(of) >= of->mux->limit_filesize;
|
||||
}
|
||||
|
||||
int64_t of_filesize(OutputFile *of)
|
||||
{
|
||||
AVIOContext *pb = of->ctx->pb;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue