[FFmpeg-devel] [PATCH] lavf/segment: add CVS escaping for CSV list file filename field
Clément Bœsch
ubitux at gmail.com
Sun Sep 2 11:12:53 CEST 2012
On Sat, Sep 01, 2012 at 04:15:50PM +0200, Stefano Sabatini wrote:
> ---
> doc/muxers.texi | 4 ++--
> libavformat/segment.c | 25 ++++++++++++++++++++++++-
> 2 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 834edf8..1375356 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -498,8 +498,8 @@ each line matching the format:
> @end example
>
> @var{segment_filename} is the name of the output file generated by the
> -muxer according to the provided pattern, and should not contain the
> -"," character for simplifying parsing operations.
> +muxer according to the provided pattern. CSV escaping (according to
> +RFC4180) is applied if required.
>
> @var{segment_start_time} and @var{segment_end_time} specify
> the segment start and end time expressed in seconds.
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index e148dc0..e7c3f2b 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -67,6 +67,28 @@ typedef struct {
> double start_time, end_time;
> } SegmentContext;
>
> +static void avio_print_csv_escaped_str(AVIOContext *ctx, const char *str)
> +{
> + const char *p;
> + int quote = 0;
> +
> + /* check if input needs quoting */
> + for (p = str; *p; p++)
> + if (*p == '"' || *p == ',' || *p == '\n' || *p == '\r')
> + quote = 1;
I guess you can break when you find one. BTW, you can use something like
"if (strchr("\",\n\r", *p)"
> +
> + if (quote)
> + avio_w8(ctx, '"');
> +
> + for (p = str; *p; p++) {
> + if (*p == '"')
> + avio_w8(ctx, '"');
avio_w8(ctx, '\\') no?
[...]
No factoring planed with ffprobe btw?
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120902/b249122c/attachment.asc>
More information about the ffmpeg-devel
mailing list