Code Monkey home page Code Monkey logo

Comments (4)

Smalls1652 avatar Smalls1652 commented on September 17, 2024

Noticed that too, but on iOS and macOS (If you use quick view from Finder or QuickTime) the audio stream is not playing. Ran ffprobe on one of the files and it came back with h264 on the video stream and mp3 on the audio stream.

  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x800 [SAR 1:1 DAR 8:5], 889 kb/s, 30.01 fps, 30 tbr, 16k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : "VA-API\ H264\ encoder"
  Stream #0:1[0x2](eng): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
[h264 @ 0x15a00dc60] time_scale/num_units_in_tick invalid or unsupported (0/1)

Not sure why they're not playing the audio stream though. IIRC mp3 codecs are supported in the MP4 container format.

I forked the repo and made a change to the ffmpeg process that runs after saving a rolling/replay recording video that copies the existing video stream and encodes the audio stream directly to aac at 128kbps. That'll prevent the video from being re-encoded and degrading the quality any further; however, the same can't be said for the audio and there might be some loss in quality.

Smalls1652/decky-recorder-fork/blob/61954ae3d013ab3f69e2f5484feb97ff8c2cc3e9/main.py#L362

I built it locally and deployed it to my Deck and it's working. If you want me to @safijari, I can open a PR for it. The other thing we could possibly do is change the audio encoder in the GStreamer pipeline to something that encodes to aac directly from the raw audio (faac maybe?). That would probably be the much better option than remuxing a mp3 to aac, since you're not encoding twice (raw -> mp3 -> aac) and degrading the quality of the audio. I've got a second branch on my fork with faac implemented. Just waiting for the build to finish so I can deploy it to my Deck and test it.

Edit:

Mmm I see why faac was replaced. If that audio delay is still there, the first option would probably be the only way to get the MP4 container to work properly.

from decky-recorder-fork.

safijari avatar safijari commented on September 17, 2024

from decky-recorder-fork.

Smalls1652 avatar Smalls1652 commented on September 17, 2024

I unfortunately tested a more interactive recording and it doesn't exactly solve the issue. It's pointing towards the timescale being off in the video stream (#18). If I re-encode the video on my laptop (The audio stream is already encoded with aac) with ffmpeg -i xyz.mp4 -c:v libx264 -c:a copy xyz_converted.mp4, the video and audio streams are in sync.

I'm digging around to see if I can figure out why the VAAPI H264 encoder is doing that.

from decky-recorder-fork.

Smalls1652 avatar Smalls1652 commented on September 17, 2024

So I've got a bit of a band-aid fix. I've got ffmpeg set to resample the audio stream (with -af aresample=async=1000) and that's resolving the audio stream being out of sync with the video stream. Here's a sample video. It might be distorting the audio a little bit? I also re-enabled faac in the GStreamer pipeline and bumped the bitrate to 320kbps. It's not an ideal solution because we're still re-encoding the audio later on with ffmpeg at 192kbps. Not a huge fan of lossy-to-lossy conversion. 😅 Could also be an issue for non-rolling recording videos?

I'm still trying to figure out what might be the best solution to fix the timescale, but this should get usable MP4 files. I'll create the PR for it tomorrow and I can make any changes if needed.

from decky-recorder-fork.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.