WyattBlue / auto-editor

Auto-Editor: Efficient media analysis and rendering
https://auto-editor.com
The Unlicense
2.86k stars 418 forks source link

Severe Audio Degradation Issues #416

Closed Drive4Code closed 9 months ago

Drive4Code commented 9 months ago

Bug description

I am having severe audio degradation issues in my videos, and occasionally also delay in audio. I am running all this in docker under WSL 2, here is part of neofetch:

 OS: Ubuntu 22.04.3 LTS on Windows 10 x86_64
 Kernel: 5.15.133.1-microsoft-standard-WSL2

I've noticed the sample rate gets dropped from 160k to ~130k (sometimes 129, other 132...) and when i try to fix it with the audio_bitrate this works but causes even more artifacts. I've tried both the included and --my-ffmpeg, and my-ffmpeg usually causes even more issues. I've tried previous ffmpeg versions, and I've found v 4.2.3 causes the least amount of issues when using --my-ffmpeg, as the audio seems to be degraded for only part of the clip and the rest is kept intact.

Full Dockerfile: FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

WORKDIR /app

COPY requirements.txt ./ RUN apt-get update && apt-get install git python3 python3-pip -y

COPY --from=mwader/static-ffmpeg:4.2 /ffmpeg /usr/local/bin/ COPY --from=mwader/static-ffmpeg:4.2 /ffprobe /usr/local/bin/ RUN pip3 install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8080

CMD [ "python3","-u", "app.py"]

FFmpeg: https://hub.docker.com/layers/mwader/static-ffmpeg/4.2/images/sha256-7e5c2d9f202dc2438ac52a9700ee72c623a64c654611dfeb81539a2efc93e916?context=explore

What's your platform?

Python Version: 3.10.12 64-bit\nPlatform: Linux 5.15.133.1-microsoft-standard-WSL2 x86_64\nFFmpeg Version: 4.2.3\nFFmpeg Path: /usr/local/bin/ffmpeg\nAuto-Editor Version: 23w51a\n

What command did you use

auto-editor input.mp4 -o output_edited.mp4 --margin 0.6sec --keep_tracks_seperate

What properties does your input video have?

/app/static/files/yr3gpjr9o5vt2rn/yr3gpjr9o5vt2rn.mp4:
 - video:
   - track 0:
     - codec: h264
     - fps: 2768625/46144
     - resolution: 1920x1080
     - aspect ratio: 16:9
     - pixel aspect ratio: 1
     - duration: 123.05066666666667
     - pix fmt: yuv420p
     - color range: tv
     - color space: bt709
     - color primaries: bt709
     - color transfer: bt709
     - timebase: 1/90000
     - bitrate: 6001574
     - lang: und
 - audio:
   - track 0:
     - codec: aac
     - samplerate: 48000
     - channels: 2
     - duration: 122.98666666666666
     - bitrate: 159621
     - lang: und
 - container:
   - duration: 123.050667
   - bitrate: 6175309

ffmpeg: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/app/static/files/yr3gpjr9o5vt2rn/yr3gpjr9o5vt2rn.mp4':\n Metadata:\n major_brand : isom\n minor_version : 512\n compatible_brands: isomiso2avc1mp41\n encoder : Lavf58.29.100\n Duration: 00:02:03.05, start: 0.015000, bitrate: 6175 kb/s\n Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 6001 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)\n Metadata:\n handler_name : VideoHandler\n Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)\n Metadata:\n handler_name : SoundHandler\nAt least one output file must be specified\n

Comments

I have multiple examples of the artifacts. They're all in this drive folder, where the edited ones are marked with _EDITED. They represent examples I've tried with:

auto-editor input.mp4 -o output_edited.mp4 --margin 0.6sec auto-editor input.mp4 -o output_edited.mp4 --margin 0.6sec --my-ffmpeg auto-editor input.mp4 -o output_edited.mp4 --margin 0.6sec --keep_tracks_seperate --my-ffmpeg

In all these cases artifacts are present, sometimes worse sometimes better. This also somewhat seemed to change based on the ffmpeg version, although never where these problems gone completely.

I've also tried running the program on barebones windows and the issues persist (Included in the folder). Looking forward to help you out if you need more information

WyattBlue commented 9 months ago

I can't repro audio bitrate issues or audio desync with your samples. Audio quality seems fine. auto-editor only supports ffmpeg 6.0 and beyond. The fact that you can still use ffmpeg 4.x and auto-editor doesn't crash is a miracle in itself.

On Linux, the --my-ffmpeg flag is being applied already. You should compile and use ffmpeg master with fdc_aac enabled if you want to remove audio artifacts to the lowest possible.

Drive4Code commented 9 months ago

Thanks for pointing me in this direction, I finally figured out the issue was with an unstable clock in my cpu. With that being said, auto-editor still does indeed degrade the quality of the video a little bit when running, compared to the original sample. I noticed a sort of "reverb" effect