Log in

View Full Version : Why does some players think there is silence at the end of a demuxed audio file?


egr
6th October 2019, 11:40
I demux media files down to just their pure audio side so I can transfer the smaller and less intense file to be played back on a portable device but I notice sometimes FFMPEG adds random silence to the end of the file. For example, a 5 minute demuxed file, will show having only 3 minutes of actual audio with the other two minutes being silence when played back under windows media player. With MPC-HC, it thinks it's only got 2 minutes of playback length but the file plays over the two minute mark and thus isn't the true representation of the playback length which is in fact 5 minutes and not 2 minutes as touted by MPC-HC or 3 minutes played back by windows media player but having 2 minutes of silence at the end of the file. Pot Player seems to have red it more correctly and shows the full length file and plays it back as well fine as well as being able to navigate to different time stamps fine too. This is just for the one file....

Any ideas what this is caused by and how to fix this through FFMPEG? Perhaps my demux lines are incorrect? Check below for line:


::Demux AAC from M4A:
for %%f in (*.m4a) do ffmpeg -i "%%f" -vn -acodec copy "%%~nf.aac"

::Demuxes audio from mp4 files
for %%f in (*.mp4) do ffmpeg -i "%%f" -vn -acodec copy "%%~nf.aac"

::Demuxes audio from mkv files
for %%f in (*.mkv) do ffmpeg -i "%%f" -vn -acodec copy "%%~nf.opus"


I use dBpoweramp to convert the OPUS to AAC which I then use FFMPEG to demux that from the m4a container so I get a consistent file format across my files and thus better playback compatibility.

sneaker_ger
6th October 2019, 15:33
The audio is using variable bitrate. If you extract to "raw" (ADTS) aac format then there is no index or duration information available for the player. Different players deploy different strategies to read/seek such files anyways but the results can be mixed. That's why usually we put AAC audio into mp4/m4a container so that players have metadata available for proper seeking and duration display. So I would recommend to NOT demux to "raw" .aac files.

tebasuna51
6th October 2019, 20:53
I demux media files down to just their pure audio side so I can transfer the smaller and less intense file ...

Please see the size of .m4a (3.952.721 bytes in my sample) and the size of extracted .aac (3.976.247 bytes in my sample).

The .aac is big because must have a header (ADTS) in each frame (9123 in my sample), in a container .m4a only need a unique header and a index to really raw audio data.

Like sneaker_ger say is better, and smaller, preserve the .m4a.

egr
7th October 2019, 00:35
The audio is using variable bitrate.

Oh... What if the bitrate is constant or average? Does that matter or still happens to that too?

If you extract to "raw" (ADTS) aac format then there is no index or duration information available for the player. Different players deploy different strategies to read/seek such files anyways but the results can be mixed. That's why usually we put AAC audio into mp4/m4a container so that players have metadata available for proper seeking and duration display. So I would recommend to NOT demux to "raw" .aac files.I see...

Please see the size of .m4a (3.952.721 bytes in my sample) and the size of extracted .aac (3.976.247 bytes in my sample).

The .aac is big because must have a header (ADTS) in each frame (9123 in my sample), in a container .m4a only need a unique header and a index to really raw audio data.

Like sneaker_ger say is better, and smaller, preserve the .m4a.Where's this sample...?

tebasuna51
7th October 2019, 10:55
Oh... What if the bitrate is constant or average? Does that matter or still happens to that too?

Whit constant bitrate, like AC3 or others compressed at CBR, any soft only need read the filesize and the first frame to know the exact duration.

To know the duration of a VBR stream we need read the full stream, and nobody want a pause before begin to play.

In a container (mp4, mkv) the full duration is stored in the initial header.
Some mp3's have also a initial special header with that data.

Where's this sample...?

Use your samples:
rem Demux AAC from M4A:
for %%f in (*.m4a) do ffmpeg -i "%%f" -vn -acodec copy "%%~nf.aac"

What is big, the .m4a or the extracted .aac?