Author Topic: Crash when muxing AAC  (Read 2574 times)

Blues

  • Jr. Member
  • **
  • Posts: 79
Crash when muxing AAC
« on: April 25, 2017, 12:19:12 AM »
I have a little script to convert WAV to AAC.
Code: [Select]
for i in *.wav ; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 128k "${i%wav}aac" ; doneWhen I load the resulting file into Avidemux and attempt to create an MP4 Avidemux first complains this file is not suitable for this container and then crashes.
I am using the git version of Avidemux, just compiled today, FFmpeg is version 3.3.

Code: [Select]
Segfault
 at line 0, file ??
ADM_backTrack
/lib64/libc.so.6() [0x3d0a6330d0]
av_log
avpriv_request_sample



av_write_frame
muxerFFmpeg::writePacket(AVPacket*)
muxerFFmpeg::saveLoop(char const*)
admSaver::save()
A_Save(char const*)
A_SaveWrapper(char const*)
ADM_QT4_fileSel::GUI_FileSelWriteExtension(char const*, char const*, void (*)(char const*))
HandleAction_Save(Action)
HandleAction(Action)
avidemux3_qt5() [0x4ab59e]
QMetaObject::activate(QObject*, int, int, void**)
MainWindow::actionSignal(Action)
MainWindow::searchToolBar(QAction*)
avidemux3_qt5() [0x4ab344]
QMetaObject::activate(QObject*, int, int, void**)
QToolBar::actionTriggered(QAction*)
/usr/lib64/libQt5Widgets.so.5() [0x324d8f529c]
QMetaObject::activate(QObject*, int, int, void**)
QToolButton::triggered(QAction*)
QMetaObject::activate(QObject*, int, int, void**)
QAction::triggered(bool)
QAction::activate(QAction::ActionEvent)
/usr/lib64/libQt5Widgets.so.5() [0x324d83ccbd]

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6060
Re: Crash when muxing AAC
« Reply #1 on: April 25, 2017, 07:27:16 AM »
Why not using the audio option of avidemux?
Load video, keep Video Output set to [Copy]
In Avidemux Menu: Audio drop down menu:
- Select Track
 Track 1 [v]  Enebaled,change [Track 0 form video (....)] to [... Add audio track]
 Browse to the wav file you want to use, select it, click [Open]
- change [Copy]  to the wanted encoding
 [AAC (FDK)]
 [AAC (Faac)]
 [AAC (lav)]
 [...]

[Configure] and select/change the presented options

apply [Filters] if wanted / needed.

When you have saved a video  which suits your needs.
Check the saved video with MediaInfo for the audio properties. Find out how to set these in your script with ffmpeg.



« Last Edit: April 25, 2017, 08:24:19 AM by Jan Gruuthuse »

Blues

  • Jr. Member
  • **
  • Posts: 79
Re: Crash when muxing AAC
« Reply #2 on: April 25, 2017, 12:13:34 PM »
So you recommend to convert back to WAV before muxing. Not an ideal solution considering AAC is lossy.

p3trus

  • Newbie
  • *
  • Posts: 36
Re: Crash when muxing AAC
« Reply #3 on: April 25, 2017, 01:56:59 PM »
So you recommend to convert back to WAV before muxing. Not an ideal solution considering AAC is lossy.

No - according to your first post, you have a video file, and your audio track as *.wav.
Jan suggested to skip your conversion script (<> NOT converting wav > aac with ffmpeg first), but load the wav audio track directly in ADM and let ADM do the conversion to aac.
Jan gave a perfect step-by-step instruction for this :)

Blues

  • Jr. Member
  • **
  • Posts: 79
Re: Crash when muxing AAC
« Reply #4 on: April 25, 2017, 03:13:50 PM »
I did not say nothing of the kind. The files are encoded to AAC, I merely described how they were encoded. Now I need to use them and Avidemux crashes. Can we stay on topic, please?

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #5 on: April 25, 2017, 03:37:15 PM »
If you load audio from an external file, does the duration of the audio at least equal the duration of the video?

mm0359

  • Full Member
  • ***
  • Posts: 171
Re: Crash when muxing AAC
« Reply #6 on: April 25, 2017, 07:32:31 PM »
Blues, please provide sample files, so people can try and reproduce.

Blues

  • Jr. Member
  • **
  • Posts: 79
Re: Crash when muxing AAC
« Reply #7 on: April 26, 2017, 11:53:12 AM »
Audio file.

Avidemux loads it, but crashes when I try to mux it.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #8 on: April 26, 2017, 03:48:25 PM »
Decoding the sample as an external audio track crashes Avidemux in ADM_AudiocoderLavcodec::decodeToFloatPlanar(float **outptr,uint32_t *nbOut) from avidemux_plugins/ADM_audioDecoders/ADM_ad_lav.

Valgrind says, "Invalid read of size 4".

« Last Edit: April 26, 2017, 03:57:04 PM by eumagga0x2a »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #9 on: April 26, 2017, 04:14:00 PM »
I don't have libfdk installed, but encoding with

Code: [Select]
ffmpeg -i some_audio_file -c:a aac -b:a 192k output.aac
and loading the file as external audio track not only crashes Avidemux in the very same way but also the values displayed in the properties dialog are completely off:

ffprobe:

Code: [Select]
Input #0, aac, from 'test.aac':
  Duration: 00:07:11.54, bitrate: 188 kb/s
    Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 188 kb/s

Avidemux:

Code: [Select]
Codec: E-AC3
Channels: 6
Bitrate: 5000 Bps / 40 kbps
Frequency: 32000 Hz
Total Duration: 00:00:00.000


Blues

  • Jr. Member
  • **
  • Posts: 79
Re: Crash when muxing AAC
« Reply #10 on: April 26, 2017, 04:35:02 PM »
Good catch, thanks for confirming the bug.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #11 on: April 26, 2017, 04:35:10 PM »
Likely something is wrong in ADM_EAC3GetInfo from avidemux_core/ADM_coreAudioParser/src/ADM_eac3info.cpp:23.

Apart from getting the bitrate wrong, Avidemux doesn't exhibit difficulties with the same audio when muxed in copy mode with ffmpeg.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #12 on: April 26, 2017, 08:00:44 PM »
Okay, idAAACADTS always reports 128k as bitrate for AAC, so nothing surprising here :)

Swapping the order of checks for E-AC3 and AAC in ADM_identifyAudioStream sort of fixes this bug which originates from AAC getting misidentified as E-AC3 (on the other hand even misidentified stream should not result in a crash). I have no idea what will break if this band-aid gets applied, however.

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6060
Re: Crash when muxing AAC
« Reply #13 on: April 27, 2017, 05:50:59 AM »
What I could think of (wild guessing)

- relation between actual channels (2,2.1, 5.0,5.1, ...) and used bitrate (compounded)
- limitation in maximum (allowed?) bitrate, bitrate/channel
- limitation in maximum (allowed?) kHz

above usage against different libraries: AAC (FDK),AAC (Faac), AAC (lav)

some more info: https://trac.ffmpeg.org/wiki/Encode/AAC
- As a rule of thumb, for audible transparency, use 64kb/s for each channel (so 128kb/s for stereo, 384 kb/s for 5.1 surround sound)
- Note: A bug exists in libfdk-aac 0.1.3 and earlier that will cause a crash when using high sample rates, such as 96kHz, with VBR mode 5.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
Re: Crash when muxing AAC
« Reply #14 on: April 27, 2017, 07:11:01 AM »
The E-AC3 detection has been fixed: [audio] Check deeper if it is eac3, the 2 frames must be right after one another. The fix will be in the 2.6.20 release as well.

Thank you for your report.