Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: Blues on April 25, 2017, 12:19:12 AM

Title: Crash when muxing AAC
Post by: Blues on April 25, 2017, 12:19:12 AM
I have a little script to convert WAV to AAC.
for i in *.wav ; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 128k "${i%wav}aac" ; done
When 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.

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]
Title: Re: Crash when muxing AAC
Post by: Jan Gruuthuse 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.



Title: Re: Crash when muxing AAC
Post by: Blues 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.
Title: Re: Crash when muxing AAC
Post by: p3trus on April 25, 2017, 01:56:59 PM
Quote from: Blues 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.

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 :)
Title: Re: Crash when muxing AAC
Post by: Blues 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?
Title: Re: Crash when muxing AAC
Post by: eumagga0x2a 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?
Title: Re: Crash when muxing AAC
Post by: mm0359 on April 25, 2017, 07:32:31 PM
Blues, please provide sample files, so people can try and reproduce.
Title: Re: Crash when muxing AAC
Post by: Blues on April 26, 2017, 11:53:12 AM
Audio file. (http://asclinux.com/tmp/Background1.aac)

Avidemux loads it, but crashes when I try to mux it.
Title: Re: Crash when muxing AAC
Post by: eumagga0x2a 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".

Title: Re: Crash when muxing AAC
Post by: eumagga0x2a on April 26, 2017, 04:14:00 PM
I don't have libfdk installed, but encoding with

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:

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:

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


Title: Re: Crash when muxing AAC
Post by: Blues on April 26, 2017, 04:35:02 PM
Good catch, thanks for confirming the bug.
Title: Re: Crash when muxing AAC
Post by: eumagga0x2a 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.
Title: Re: Crash when muxing AAC
Post by: eumagga0x2a 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.
Title: Re: Crash when muxing AAC
Post by: Jan Gruuthuse 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.
Title: Re: Crash when muxing AAC
Post by: eumagga0x2a 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 (https://github.com/mean00/avidemux2/commit/20f99b972b1a0efc90fdb8cefaf5358be63d66fd). The fix will be in the 2.6.20 release as well.

Thank you for your report.
Title: Re: Crash when muxing AAC
Post by: AQUAR on April 27, 2017, 12:07:56 PM
IIRC, some time ago you could not import AAC at all.
People were saving (exporting) AAC from ADM and also found that they could not even import that file (raw data).
Then on request,  Mean added basic functionality that exported the AAC audio in ADTS and allowed its importation.

Probably the reason why there are issues with non ADM created external AAC audio.

Title: Re: Crash when muxing AAC
Post by: eumagga0x2a on April 28, 2017, 08:26:24 AM
The issue was an unforseen side effect of [audio] Add support for external eac3 track (https://github.com/mean00/avidemux2/commit/3880d7c598b1ee77d8eae55a26ae024ea39ba9ec). The added check for E-AC3 sometimes wrongly recognized AAC as E-AC3; the ADM_ad_lav code subsequently tried to parse AAC as E-AC3 (the crash in the parser is not fixed, just the misdetection).