PyNvVideoCodec 2.0.4__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. PyNvVideoCodec/PyNvVideoCodec_121.cp314-win_amd64.pyd +0 -0
  2. PyNvVideoCodec/PyNvVideoCodec_130.cp314-win_amd64.pyd +0 -0
  3. PyNvVideoCodec/VersionCheck.cp314-win_amd64.pyd +0 -0
  4. PyNvVideoCodec/__init__.py +246 -0
  5. PyNvVideoCodec/avcodec-62.dll +0 -0
  6. PyNvVideoCodec/avdevice-62.dll +0 -0
  7. PyNvVideoCodec/avfilter-11.dll +0 -0
  8. PyNvVideoCodec/avformat-62.dll +0 -0
  9. PyNvVideoCodec/avutil-60.dll +0 -0
  10. PyNvVideoCodec/decoders/SimpleDecoder.py +230 -0
  11. PyNvVideoCodec/decoders/ThreadedDecoder.py +129 -0
  12. PyNvVideoCodec/decoders/__init__.py +22 -0
  13. PyNvVideoCodec/swresample-6.dll +0 -0
  14. PyNvVideoCodec/swscale-9.dll +0 -0
  15. PyNvVideoCodec/transcoder/Transcoder.py +55 -0
  16. PyNvVideoCodec/transcoder/__init__.py +22 -0
  17. benchmarks/cached_decoder_benchmark.py +813 -0
  18. benchmarks/frame_sampling_benchmark.py +765 -0
  19. benchmarks/requirements.txt +47 -0
  20. benchmarks/segmented_transcode_benchmark.py +1546 -0
  21. pynvvideocodec-2.0.4.data/data/external/ffmpeg/readme.txt +15 -0
  22. pynvvideocodec-2.0.4.data/data/external/ffmpeg/src/ffmpeg-8.1.1.tar.xz +0 -0
  23. pynvvideocodec-2.0.4.dist-info/METADATA +84 -0
  24. pynvvideocodec-2.0.4.dist-info/RECORD +65 -0
  25. pynvvideocodec-2.0.4.dist-info/WHEEL +5 -0
  26. pynvvideocodec-2.0.4.dist-info/licenses/LICENSE.txt +22 -0
  27. pynvvideocodec-2.0.4.dist-info/licenses/NOTICES.txt +167 -0
  28. pynvvideocodec-2.0.4.dist-info/top_level.txt +3 -0
  29. samples/advanced/decode.py +173 -0
  30. samples/advanced/decode_from_memory_buffer.py +204 -0
  31. samples/advanced/decode_perf.py +299 -0
  32. samples/advanced/decode_reconfigure.py +184 -0
  33. samples/advanced/decode_sei_msg.py +193 -0
  34. samples/advanced/decode_with_cuda_control.py +214 -0
  35. samples/advanced/decode_with_low_latency.py +183 -0
  36. samples/advanced/encode_config.json +9 -0
  37. samples/advanced/encode_config_lowlatency.json +11 -0
  38. samples/advanced/encode_perf.py +338 -0
  39. samples/advanced/encode_reconfigure.py +211 -0
  40. samples/advanced/encode_sei_msg.py +188 -0
  41. samples/advanced/simple_decode_stats.py +179 -0
  42. samples/advanced/transcode.py +288 -0
  43. samples/basic/create_video_segments.py +187 -0
  44. samples/basic/encode.py +347 -0
  45. samples/basic/encode_config.json +9 -0
  46. samples/basic/segments.txt +3 -0
  47. samples/basic/simple_decode_sampling.py +182 -0
  48. samples/basic/transcode_config.json +6 -0
  49. samples/jupyter/ReconfigureDecoder.png +0 -0
  50. samples/jupyter/SimpleDecoderAPIs.png +0 -0
  51. samples/jupyter/ThreadedDecoder.png +0 -0
  52. samples/jupyter/coco_classes.pickle +0 -0
  53. samples/jupyter/object_detection_tutorial.ipynb +762 -0
  54. samples/jupyter/simple_decode_tutorial.ipynb +651 -0
  55. samples/requirements.txt +78 -0
  56. samples/utils/Utils.py +405 -0
  57. samples/utils/__init__.py +36 -0
  58. samples/utils/decode_parser.py +642 -0
  59. samples/utils/decode_stats_writer.py +177 -0
  60. samples/utils/encode_parallel_utils.py +174 -0
  61. samples/utils/encode_parser.py +357 -0
  62. samples/utils/frame_utils.py +89 -0
  63. samples/utils/sei_message_parser.py +223 -0
  64. samples/utils/sei_parser.py +223 -0
  65. samples/utils/transcode_parser.py +218 -0
@@ -0,0 +1,182 @@
1
+ # This copyright notice applies to this file only
2
+ #
3
+ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4
+ # SPDX-License-Identifier: MIT
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a
7
+ # copy of this software and associated documentation files (the "Software"),
8
+ # to deal in the Software without restriction, including without limitation
9
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
+ # and/or sell copies of the Software, and to permit persons to whom the
11
+ # Software is furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
+ # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
+ # DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ '''
26
+ This sample demonstrates multi-file video decoding with frame sampling and tensor conversion.
27
+ It shows how to:
28
+ 1. Process multiple video files efficiently
29
+ 2. Sample frames evenly across videos
30
+ 3. Convert video frames to PyTorch tensors
31
+ 4. Handle decoder reconfiguration
32
+
33
+ Key Learning Outcomes:
34
+ - Reconfigure decoder instance to process multiple video files
35
+ - RGB color format output
36
+ - PyTorch tensor conversion
37
+ - CUDA device memory usage
38
+
39
+
40
+ Usage:
41
+ python simple_decode_sampling.py video1.mp4 video2.mp4 [options]
42
+ python simple_decode_sampling.py /path/to/videos/*.mp4 [options]
43
+
44
+ Example:
45
+ python simple_decode_sampling.py video1.mp4 video2.mp4 -g 0 -f 16
46
+
47
+ Arguments:
48
+ video_files: One or more video files to process
49
+ -g/--gpu-id: GPU device ID (default: 0)
50
+ -f/--frames: Frames to sample per video (default: 8)
51
+
52
+ Note: Frames are sampled evenly across each video's duration.
53
+ '''
54
+
55
+ import sys
56
+ import torch
57
+ import PyNvVideoCodec as nvc
58
+ import numpy as np
59
+ from typing import List
60
+ from os.path import dirname, abspath
61
+
62
+ # Add the parent directory to Python path in a way that works from any working directory
63
+ current_dir = dirname(abspath(__file__))
64
+ parent_dir = dirname(current_dir)
65
+ if parent_dir not in sys.path:
66
+ sys.path.append(parent_dir)
67
+
68
+ # Import utilities for decoding
69
+ from utils.Utils import convert_frames_to_torch
70
+ from utils.decode_parser import parse_sampling_args
71
+
72
+ def process_multiple_files(video_files: List[str], gpu_id: int = 0, num_frames: int = 8,
73
+ need_scanned_stream_metadata: bool = False) -> None:
74
+ """
75
+ Process multiple video files using decoder reconfiguration.
76
+
77
+ Args:
78
+ video_files: List of video file paths
79
+ gpu_id: GPU device ID to use
80
+ num_frames: Number of frames to decode per video
81
+ need_scanned_stream_metadata: Whether to scan stream for detailed metadata
82
+ """
83
+ if not video_files:
84
+ print("No video files provided")
85
+ return
86
+
87
+ decoder = None
88
+
89
+ try:
90
+ for i, video_file in enumerate(video_files):
91
+ # Convert Path to string if needed
92
+ video_path = str(video_file)
93
+
94
+ print(f"\n{'='*60}")
95
+ print(f"Processing file {i+1}/{len(video_files)}: {video_path}")
96
+ print(f"{'='*60}")
97
+
98
+ if i == 0:
99
+ # Create decoder from first file
100
+ print(f"Creating decoder for: {video_path}")
101
+ decoder = nvc.SimpleDecoder(
102
+ video_path,
103
+ gpu_id=gpu_id,
104
+ use_device_memory=True,
105
+ need_scanned_stream_metadata=need_scanned_stream_metadata,
106
+ output_color_type=nvc.OutputColorType.RGB, # RGB format
107
+ max_width=2048,
108
+ max_height=2048
109
+ )
110
+ print(f"Decoder created successfully. Total frames: {len(decoder)}")
111
+ else:
112
+ # Reconfigure decoder for subsequent files
113
+ print(f"Reconfiguring decoder for: {video_path}")
114
+ torch.cuda.current_stream().synchronize()
115
+ decoder.reconfigure_decoder(video_path)
116
+ print(f"Decoder reconfigured successfully. Total frames: {len(decoder)}")
117
+
118
+ # Get total frames and calculate indices
119
+ total_frames = len(decoder)
120
+
121
+ if total_frames == 0:
122
+ print(f"Warning: No frames found in video: {video_file}")
123
+ continue
124
+
125
+ # Sample frames evenly across the video
126
+ frame_indices = np.linspace(0, total_frames-1, num_frames, dtype=int).tolist()
127
+
128
+ print(f"Decoding {num_frames} frames from indices: {frame_indices}")
129
+
130
+ # Get batch of frames by indices
131
+ decoded_frames = decoder.get_batch_frames_by_index(frame_indices)
132
+
133
+ # Convert to torch tensor
134
+ frames_tensor = convert_frames_to_torch(decoded_frames)
135
+
136
+ print(f"Decoded frames shape: {frames_tensor.shape}")
137
+
138
+ # Clean up frames to free memory
139
+ del frames_tensor
140
+ del decoded_frames
141
+
142
+ print(f"\n{'='*60}")
143
+ print("All files processed successfully!")
144
+ print(f"{'='*60}")
145
+
146
+ except Exception as e:
147
+ print(f"Error processing files: {e}")
148
+ raise
149
+ finally:
150
+ # Clean up decoder
151
+ if decoder is not None:
152
+ del decoder
153
+ def main():
154
+ """Main application entry point"""
155
+ try:
156
+ args, valid_files = parse_sampling_args()
157
+
158
+ # Display configuration
159
+ print("=" * 60)
160
+ print("VIDEO SAMPLING CONFIGURATION")
161
+ print("=" * 60)
162
+ print(f"GPU: {args.gpu_id} ({torch.cuda.get_device_name(args.gpu_id)})")
163
+ print(f"Input Files: {len(valid_files)} files found")
164
+ print(f"Frames per Video: {args.frames}")
165
+ print(f"Need Scanned Stream Metadata: {args.need_scanned_stream_metadata}")
166
+ print("=" * 60)
167
+
168
+ # Process all files
169
+ process_multiple_files(valid_files, args.gpu_id, args.frames, args.need_scanned_stream_metadata)
170
+
171
+ print("=" * 60)
172
+ print("SAMPLING COMPLETE")
173
+ print("=" * 60)
174
+
175
+ except KeyboardInterrupt:
176
+ print("\nApplication interrupted by user")
177
+ sys.exit(0)
178
+ except Exception as e:
179
+ print(f"Application error: {e}")
180
+ sys.exit(1)
181
+ if __name__ == "__main__":
182
+ main()
@@ -0,0 +1,6 @@
1
+ {
2
+ "codec" : "h264",
3
+ "preset" : "P3",
4
+ "tuning_info" : "high_quality",
5
+ "bf" : "3"
6
+ }
Binary file
Binary file
Binary file
Binary file