You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavf/img2enc: avoid a useless copy of the url
img2enc keeps a private (and possibly truncated) copy of the url that is never modified. Just use AVFormatContext.url instead.
This commit is contained in:
@@ -36,7 +36,6 @@ typedef struct VideoMuxData {
|
|||||||
const AVClass *class; /**< Class for private options. */
|
const AVClass *class; /**< Class for private options. */
|
||||||
int img_number;
|
int img_number;
|
||||||
int split_planes; /**< use independent file for each Y, U, V plane */
|
int split_planes; /**< use independent file for each Y, U, V plane */
|
||||||
char path[1024];
|
|
||||||
char tmp[4][1024];
|
char tmp[4][1024];
|
||||||
char target[4][1024];
|
char target[4][1024];
|
||||||
int update;
|
int update;
|
||||||
@@ -53,14 +52,12 @@ static int write_header(AVFormatContext *s)
|
|||||||
AVStream *st = s->streams[0];
|
AVStream *st = s->streams[0];
|
||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format);
|
||||||
|
|
||||||
av_strlcpy(img->path, s->url, sizeof(img->path));
|
|
||||||
|
|
||||||
if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
|
if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
|
||||||
img->muxer = "gif";
|
img->muxer = "gif";
|
||||||
} else if (st->codecpar->codec_id == AV_CODEC_ID_FITS) {
|
} else if (st->codecpar->codec_id == AV_CODEC_ID_FITS) {
|
||||||
img->muxer = "fits";
|
img->muxer = "fits";
|
||||||
} else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
|
} else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
|
||||||
const char *str = strrchr(img->path, '.');
|
const char *str = strrchr(s->url, '.');
|
||||||
img->split_planes = str
|
img->split_planes = str
|
||||||
&& !av_strcasecmp(str + 1, "y")
|
&& !av_strcasecmp(str + 1, "y")
|
||||||
&& s->nb_streams == 1
|
&& s->nb_streams == 1
|
||||||
@@ -136,29 +133,29 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
AVDictionary *options = NULL;
|
AVDictionary *options = NULL;
|
||||||
|
|
||||||
if (img->update) {
|
if (img->update) {
|
||||||
av_strlcpy(filename, img->path, sizeof(filename));
|
av_strlcpy(filename, s->url, sizeof(filename));
|
||||||
} else if (img->use_strftime) {
|
} else if (img->use_strftime) {
|
||||||
time_t now0;
|
time_t now0;
|
||||||
struct tm *tm, tmpbuf;
|
struct tm *tm, tmpbuf;
|
||||||
time(&now0);
|
time(&now0);
|
||||||
tm = localtime_r(&now0, &tmpbuf);
|
tm = localtime_r(&now0, &tmpbuf);
|
||||||
if (!strftime(filename, sizeof(filename), img->path, tm)) {
|
if (!strftime(filename, sizeof(filename), s->url, tm)) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not get frame filename with strftime\n");
|
av_log(s, AV_LOG_ERROR, "Could not get frame filename with strftime\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
} else if (img->frame_pts) {
|
} else if (img->frame_pts) {
|
||||||
if (av_get_frame_filename2(filename, sizeof(filename), img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
|
if (av_get_frame_filename2(filename, sizeof(filename), s->url, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames.");
|
av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the frames.");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
} else if (av_get_frame_filename2(filename, sizeof(filename), img->path,
|
} else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
|
||||||
img->img_number,
|
img->img_number,
|
||||||
AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
|
AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
|
||||||
img->img_number > 1) {
|
img->img_number > 1) {
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"Could not get frame filename number %d from pattern '%s'. "
|
"Could not get frame filename number %d from pattern '%s'. "
|
||||||
"Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
|
"Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
|
||||||
img->img_number, img->path);
|
img->img_number, s->url);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
Reference in New Issue
Block a user