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

Check audio codec on uploaded videos #1414

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from
Open

Check audio codec on uploaded videos #1414

wants to merge 25 commits into from

Conversation

KemalKrKX
Copy link
Contributor

Motivation and Context

https://github.com/TUM-Dev/gocast/issues/1336

Description

Audio codec is now also checked during filavigate to a Livestreame upload and if it is not in aac format it will be transcoded.

Steps for Testing

  1. Log in as prof or admin
  2. Create a lecture by choosing upload video option
  3. Upload a video with an audio codec that is not aac
  4. After the video is available to watch, locate the file and ffprobe it to see the audio codec is changed

Screenshots

Copy link

Your Testserver will be ready at https://1414.test.live.mm.rbg.tum.de in a few minutes.

Logins
Kurs1 Kurs2 Kurs3 Kurs4
public public loggedin enrolled
prof1 prof1 prof2 prof1
prof2
student1
student2
student3
student1
student2
student2
student3
student1
student2

@joschahenningsen joschahenningsen changed the title 1336 video format Check audio codec on uploaded videos Nov 24, 2024
Copy link
Member

@joschahenningsen joschahenningsen left a comment

Choose a reason for hiding this comment

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

Very nice!! I added a couple ideas on your code :)

probe, err := probe(file)
if err != nil {
return "", err
}
return gjson.Get(probe, "streams.0.codec_name").String(), nil
codecNumber := gjson.Get(probe, "streams.#").Int()
Copy link
Member

Choose a reason for hiding this comment

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

I think a more descriptive name would be nice, something like

Suggested change
codecNumber := gjson.Get(probe, "streams.#").Int()
nStreams := gjson.Get(probe, "streams.#").Int()

Comment on lines +28 to +29
videoIndex = int(gjson.Get(probe, fmt.Sprintf("streams.%d.index", i)).Int())
break
Copy link
Member

Choose a reason for hiding this comment

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

Instead we could just return here

Suggested change
videoIndex = int(gjson.Get(probe, fmt.Sprintf("streams.%d.index", i)).Int())
break
return gjson.Get(probe, fmt.Sprintf("streams.%d.codec_name", i)).String(), nil

return "", errors.New("no video stream found")
}

func getAudioCodec(file string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could combine these methods into one, something like this:

Suggested change
func getAudioCodec(file string) (string, error) {
// getCodec returns the codec of the file, codecType=video returns the video codec, codecType=audio the audio codec.
func getCodec(file string, codecType string) (string, error) {

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.

2 participants