meta-pytorch / meta-pytorch/torchcodec
Enable color parameters in NVENC test on FFmpeg 4 and 6
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 125
- Avg merge
- 22h 47m
- Merged PRs (30d)
- 54
Description
Investigate why FFmpeg 4 and 6 fail with non-default color space and range.
The test_nvenc_against_ffmpeg_cli test is currently skipped on FFmpeg 4 and FFmpeg 6 when colorspace and color_range are set to values besides the default BT.601 and tv .
The code below demonstrates that the color parameters are set on the codec context, and the encoded video has the correct metadata. The error may be caused by other steps in the test.
import subprocess
import torch
import json
from torchcodec.encoders import VideoEncoder
# Create test frames and encode with specific color parameters
frames = torch.randint(0, 256, (5, 3, 256, 256), dtype=torch.uint8).to("cuda")
encoder = VideoEncoder(frames=frames, frame_rate=30)
encoder.to_file(
dest="/tmp/test_video.mp4",
codec="h264_nvenc",
extra_options={
"colorspace": "bt709",
"color_range": "pc",
}
)
result = subprocess.run(
[
"ffprobe",
"-v",
"error",
"-select_streams",
"v:0",
"-show_entries",
"stream=color_space,color_range,pix_fmt",
"-of",
"json",
"/tmp/test_video.mp4"
],
capture_output = True,
text = True,
check = True)
metadata = json.loads(result.stdout)["streams"][0]
print(json.dumps(metadata, indent=2))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test_nvenc_against_ffmpeg_cli test and reproduce its behavior on FFmpeg 4 and FFmpeg 6 using non-default colorspace and color_range values. Trace the test steps beyond codec-context setup, then confirm the test can run instead of being skipped and that the encoded video reports the expected color metadata through ffprobe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- audio-video-rtc, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100