@@ -415,7 +415,6 @@ void _add_video_stream(
415415 }
416416
417417 validateDeviceInterface (std::string (device), std::string (device_variant));
418-
419418 videoStreamOptions.device = torch::Device (std::string (device));
420419 videoStreamOptions.deviceVariant = device_variant;
421420
@@ -648,11 +647,10 @@ void encode_video_to_file(
648647 std::optional<std::string_view> preset = std::nullopt ,
649648 std::optional<std::vector<std::string>> extra_options = std::nullopt ) {
650649 VideoStreamOptions videoStreamOptions;
650+ videoStreamOptions.device = torch::Device (std::string (device));
651651 videoStreamOptions.codec = std::move (codec);
652652 videoStreamOptions.pixelFormat = std::move (pixel_format);
653653 videoStreamOptions.crf = crf;
654-
655- videoStreamOptions.device = torch::Device (std::string (device));
656654 videoStreamOptions.preset = preset;
657655
658656 if (extra_options.has_value ()) {
@@ -680,11 +678,10 @@ at::Tensor encode_video_to_tensor(
680678 std::optional<std::vector<std::string>> extra_options = std::nullopt ) {
681679 auto avioContextHolder = std::make_unique<AVIOToTensorContext>();
682680 VideoStreamOptions videoStreamOptions;
681+ videoStreamOptions.device = torch::Device (std::string (device));
683682 videoStreamOptions.codec = std::move (codec);
684683 videoStreamOptions.pixelFormat = std::move (pixel_format);
685684 videoStreamOptions.crf = crf;
686-
687- videoStreamOptions.device = torch::Device (std::string (device));
688685 videoStreamOptions.preset = preset;
689686
690687 if (extra_options.has_value ()) {
@@ -719,10 +716,10 @@ void _encode_video_to_file_like(
719716 std::unique_ptr<AVIOFileLikeContext> avioContextHolder (fileLikeContext);
720717
721718 VideoStreamOptions videoStreamOptions;
719+ videoStreamOptions.device = torch::Device (std::string (device));
722720 videoStreamOptions.codec = std::move (codec);
723721 videoStreamOptions.pixelFormat = std::move (pixel_format);
724722 videoStreamOptions.crf = crf;
725- videoStreamOptions.device = torch::Device (std::string (device));
726723 videoStreamOptions.preset = preset;
727724
728725 if (extra_options.has_value ()) {
0 commit comments