Skip to content

Commit c4d0df8

Browse files
author
Daniel Flores
committed
use av_opt_set_array to avoid av_get_pix_fmt_name
1 parent fddf741 commit c4d0df8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,14 @@ AVFilterContext* createBuffersinkFilter(
397397
if (!sinkContext) {
398398
return nullptr;
399399
}
400-
// av_opt_set uses the string representation of a pixel format
401-
const char* fmt_name = av_get_pix_fmt_name(outputFormat);
402-
if (!fmt_name) {
403-
return nullptr;
404-
}
405-
status = av_opt_set(
406-
sinkContext, "pixel_formats", fmt_name, AV_OPT_SEARCH_CHILDREN);
400+
status = av_opt_set_array(
401+
sinkContext,
402+
"pixel_formats",
403+
AV_OPT_SEARCH_CHILDREN,
404+
0, // start_elem
405+
1, // nb_elems
406+
AV_OPT_TYPE_PIXEL_FMT,
407+
&outputFormat);
407408
if (status < 0) {
408409
return nullptr;
409410
}

src/torchcodec/_core/FFMPEGCommon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323
#include <libavutil/display.h>
2424
#include <libavutil/file.h>
2525
#include <libavutil/opt.h>
26-
#include <libavutil/pixdesc.h>
2726
#include <libavutil/pixfmt.h>
2827
#include <libavutil/version.h>
2928
#include <libswresample/swresample.h>

0 commit comments

Comments
 (0)