Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pixelFormat to GetCodecInfo() #303

Merged
merged 21 commits into from
Mar 9, 2022
Merged

Add pixelFormat to GetCodecInfo() #303

merged 21 commits into from
Mar 9, 2022

Conversation

AlexKordic
Copy link
Contributor

No description provided.

@@ -1739,7 +1741,8 @@ func TestTranscoder_GetCodecInfo(t *testing.T) {
t.Errorf("Unexpected error %v", err)
}
fname = path.Join(wd, "..", "data", "bunny.mp4")
res, acodec, vcodec, err = GetCodecInfo(fname)
res, acodec, vcodec, pixelFormat, err = GetCodecInfo(fname)
fmt.Printf("bunny.mp4 %t %s %s %d %v\n", res, acodec, vcodec, pixelFormat, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printf() shall be removed later

@AlexKordic AlexKordic force-pushed the ak/pixelformatinfo branch 2 times, most recently from f030ed7 to 72d8fd5 Compare February 15, 2022 17:13
@AlexKordic AlexKordic marked this pull request as ready for review February 15, 2022 17:58
@AlexKordic AlexKordic requested review from cyberj0g, yondonfu and darkdarkdragon and removed request for yondonfu February 15, 2022 17:58
Comment on lines +249 to +250
// gopFloat is allowed to be 0
if gopFloat < 0.0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests in go-livepeer repo are designed to test for 0 in profile.GOP. Fixing this condition to allow 0

ffmpeg/ffmpeg.go Outdated Show resolved Hide resolved
Copy link
Contributor

@oscar-davids oscar-davids left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Good work @AlexKordic
Please remove Printf() before merging.

ffmpeg/ffmpeg.go Show resolved Hide resolved
ffmpeg/ffmpeg.go Outdated Show resolved Hide resolved
P240p30fps4x3 = VideoProfile{Name: "P240p30fps4x3", Bitrate: "600k", Framerate: 30, AspectRatio: "4:3", Resolution: "320x240"}
P144p30fps16x9 = VideoProfile{Name: "P144p30fps16x9", Bitrate: "400k", Framerate: 30, AspectRatio: "16:9", Resolution: "256x144"}
P144p25fps16x9 = VideoProfile{Name: "P144p25fps16x9", Bitrate: "400k", Framerate: 25, AspectRatio: "16:9", Resolution: "256x144"}
P720p60fps16x9 = VideoProfile{Name: "P720p60fps16x9", Bitrate: "6000k", Framerate: 60, AspectRatio: "16:9", Resolution: "1280x720", ChromaFormat: ChromaSubsampling420, ColorDepth: ColorDepth8Bit}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not initialize these fields to default enum values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure to understand yet what is the consequence? What is wanted behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, ColorDepth is actually number of bits, not enum. To specify default value in this case, we'll need to add a NewVideoProfile function and replace all direct VideoProfile initialization throughout the code. With current implementation, it looks like it may later break some tests which are initializing VideoProfile, because ColorDepth will be 0 without explicit initialization. Alternative is to use usual int enum semantics, where 0 maps to default value (8 bits), and then map it to number of bits in lpms.

What I originally meant probably would still apply to ChromaFormat, we have default value of iota (0) there, which represents ChromaSubsampling420, maybe omit it completely in VideoProfile initializer for the sake of clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could change ColorDepthBits to be ColorDepthBitsMinus8 to make it default 0 being 8bit default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@AlexKordic AlexKordic requested review from cyberj0g and removed request for darkdarkdragon March 7, 2022 17:38
ffmpeg/ffmpeg.go Outdated
func (pixelFormat PixelFormat) Properties() (ChromaSubsampling, ColorDepthBits, error) {
switch pixelFormat.RawValue {
case C.AV_PIX_FMT_YUV420P:
return ChromaSubsampling420, 0, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since value doesn't have direct meaning anymore, can we use named constants for ColorDepthBits here?

type ColorDepthBits int

const (
ColorDepth8Bit ColorDepthBits = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment detailing how these values are related to actual number of bits?

Documented relation of ColorDepthBits value to bit value
@AlexKordic AlexKordic requested a review from cyberj0g March 8, 2022 10:04
@AlexKordic AlexKordic merged commit f4dcebd into master Mar 9, 2022
@hjpotter92 hjpotter92 deleted the ak/pixelformatinfo branch June 1, 2023 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants