Discussion:
[SlimDevices: SqueezeCenter] Odd AAC/M4A Issue
atrocity
2018-12-06 02:44:59 UTC
Permalink
I've been fooling around with downloading videos from YouTube and
demuxing the AAC streams into M4A files. (Note: Not for piracy of easily
paid-for items, but for things like
LMS will happily play the
resulting files via drag and drop or Music Folder, but will not
recognize the metadata and, I assume for that reason, doesn't add them
to the library after a scan. The files behave completely normally when
opened in Foobar2000, mp3tag and (shockingly!) even in iTunes.

I'm using ffmpeg to do the work and can immediately see via its helper
ffprobe that there are differences in the metadata. A "normal" AAC/M4A
file starts off with:


Code:
--------------------

major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom

--------------------


While the files LMS doesn't like start off with:


Code:
--------------------

major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1

--------------------


I plan to keep looking at the ffmpeg documentation to see if I can find
any obvious answer, but it makes my brain hurt, so I thought I'd ask
here first just in case someone else has encountered this.


------------------------------------------------------------------------
atrocity's Profile: http://forums.slimdevices.com/member.php?userid=16009
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
Michael Herger
2018-12-06 05:24:08 UTC
Permalink
Post by atrocity
I've been fooling around with downloading videos from YouTube and
You know about Philippe's Youtube plugin?
--
Michael
kidstypike
2018-12-06 09:10:04 UTC
Permalink
Post by Michael Herger
Post by atrocity
I've been fooling around with downloading videos from YouTube and
You know about Philippe's Youtube plugin?
--
Michael
Plays fine with the Youtube plugin. :)

26171


+-------------------------------------------------------------------+
|Filename: pink tones.jpg |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=26171|
+-------------------------------------------------------------------+


*Study/Server - LMS 7.9.2 -* Pi3B+/pCP 4.1.0/pi screen/HiFiBerry
DAC+/jivelite, 25K library and playlists on WDMyCloud, LMS cache on a
USB stick (formatted ntfs).
*Lounge* - Pi2/pCP 4.1.0 > HiFiBerry DIGI+ > AudioEngine DAC1 > AVI DM5
*Dining Room* - Pi3B/pCP 4.1.0 > HiFiBerry AMP+/retro radio
*Garage* - Pi3B/Pi screen/HiFiBerry DAC+/pCP 4.1.0 > Edifier R980T
*In car* - RPi3B/pCP in AP mode > HiFiBerry DAC+ > car's audio (files on
a 2TB USB drive)
*Spares* - 1xTouch, 1xSB3, 1xRadio, 1xBoom
------------------------------------------------------------------------
kidstypike's Profile: http://forums.slimdevices.com/member.php?userid=10436
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
JohnB
2018-12-06 12:07:39 UTC
Permalink
atrocity, It might not be relevant but there are quite a few occasions
when I find an m4a (aac) file doesn't play in LMS.

I extract the AAC to a separate file (i.e. your starting position) and
then use MP4Box to create a new m4a file. I have never had any problem
with m4a files generated by MP4Box.


Code:
--------------------
"C:\Program Files (x86)\GPAC\MP4Box" -add input.aac output.m4a
--------------------

or in my case:


Code:
--------------------
"C:\Program Files (x86)\GPAC\MP4Box" -add input.aac output.m4a
--------------------


(Remember to enclose the filenames in double quotes if the filenames
contain spaces.)



Touch, Meridian G92, Bryston B4 SST2, PMC OB1i speakers, HP Proliant
Microserver/Ubuntu, PC/Windows 7, iPad 4, iPeng, Squeezepad.
------------------------------------------------------------------------
JohnB's Profile: http://forums.slimdevices.com/member.php?userid=31553
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
atrocity
2018-12-06 14:33:37 UTC
Permalink
Post by Michael Herger
Post by atrocity
I've been fooling around with downloading videos from YouTube and
You know about Philippe's Youtube plugin?
Yes, but YouTube can be a bit ephemeral at times and there are things
I'd like to be certain I can archive.

Having said that, there's no reason why I shouldn't add that plugin to
the toolbox and thank you for reminding me of it!


------------------------------------------------------------------------
atrocity's Profile: http://forums.slimdevices.com/member.php?userid=16009
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
bpa
2018-12-06 08:48:24 UTC
Permalink
Post by atrocity
I'm using ffmpeg to do the work and can immediately see via its helper
ffprobe that there are differences in the metadata. A "normal" AAC/M4A
This is not metadata (i.e. additiopnal info) but file structure - how
the file is encoded into MPEG4.

The usual issue is that media files often have the info about the audio
data (i.e where frames starts) and other data placed at the end of the
file after the audio data - this is no use when streaming when such
data is needed to start playing the audio (i.e. all frame start position
data) is needed before audio is received. Streamed files can only be
played as they are received - there is no jumping up and down the data
stream which is possible with a file This issue happens with some m4a
podcasts as well where file is expected to be downloaded anbd played
rather than streamed.

If it is this issue - it has been discussed many times in other
threads.

Possible solution is to convert the file with ffmpeg using the
"-movflags faststart" which moves all the data ("mdat") from start of
file to end of file making it suitable for streaming.

Try somehting like the following - you may need to tweak for your file.

Code:
--------------------

ffmpeg -i input.mp4 -codec copy -map 0 -movflags faststart output.mp4

--------------------


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
bpa
2018-12-06 09:05:50 UTC
Permalink
Ignore the body of my previous post - I just re-read your post and you
sai d files play OK.

The detail are still file structure and not just metadata (m4V and
isoisomiso2avc1 usually means video component present) - MPEG4 has very
many option and the m4a decoding in "Faad" and in the players are
getting stuck on some MPEG4 "atoms" for example checking if a value is
expect. Since metadata is missing the scanner module has the problem. I
would start with "movflag faststart" option to see if it clears it.
Otherwise post an an example file to be examined.

I did an MPeg4 parser for BBC DASH streams and Philippe has adapted it
for Youtube.


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
atrocity
2018-12-06 14:58:38 UTC
Permalink
Post by bpa
Ignore the body of my previous post - I just re-read your post and you
sai d files play OK.
Yes...they behave normally everywhere except LMS...and even there they
play, they just won't go into the library. I'm used to the opposite,
where LMS is the most reliable option while everything else is iffy!
Post by bpa
Then try converting the file only copy single audio into an audio only
output not an m4v.
I may be doing it wrong (in fact, obviously I AM doing it wrong!), but
that's what I'm attempting. I just want a standard audio-only .m4a
file.
Post by bpa
What ffmpeg command line are you using to convert ?
I went with a very simple:


Code:
--------------------
ffmpeg -i 'infile.mp4' -c copy outfile.m4a
--------------------
Post by bpa
Otherwise post an an example file to be examined.
Good idea! https://www.dropbox.com/s/ww59fqf7retp191/DIY.m4a?dl=0 is the
audio from
(And yes, I'm
going to just buy the record now that I see I can get it for a
reasonable price via Discogs.)

It seems likely that all I need to do is find the right set of options
on the ffmpeg command line, but looking at the extensive documentation
last night made my tiny little brain hurt. I'm pretty sure that a big
part of the problem is that what ffmpeg calls "metadata" and you refer
to more correctly as the file structure is being carried over from the
video file. I theoretically know how to override that, I just don't know
what values I need to use, if that makes any sense.

Thank you for your suggestions!

Worst case, given that everything else is happy with the file, I can
just convert to FLAC and waste a relatively microscopic amount of
storage space.


------------------------------------------------------------------------
atrocity's Profile: http://forums.slimdevices.com/member.php?userid=16009
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
bpa
2018-12-06 15:12:06 UTC
Permalink
This post might be inappropriate. Click to display it.
bpa
2018-12-06 15:52:21 UTC
Permalink
It looks the voideo content is causing the problem. Try the ffmpeg
following command - it strips the video track out.

Code:
--------------------

ffmpeg -i DIY.m4a -vn -c:a copy DIY-novideo.m4a

--------------------


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
atrocity
2018-12-06 16:19:00 UTC
Permalink
It looks like the video content is causing the problem. Try the ffmpeg
following command - it strips the video track out.
Code:
--------------------
ffmpeg -i DIY.m4a -vn -c:a copy DIY-novideo.m4a
--------------------
The "-vn" means no video
The "-c:a copy" means straight copy of audio codec.
Thank you, thank you, THANK YOU! This works perfectly! Thank you also
for your comments about the ffmpeg documentation. I made a good living
as a mainframe programmer for decades, so it's always more than a little
embarrassing when I try to read documentation and find that I just don't
get it.

Thank you also to JohnB: MP4Box also worked as long as I did a two-step
process by first going to an .aac file, then converting that .aac to
.m4a. Given how fast it worked, I'm confident there was no re-encoding.

That in turn gave me the idea to try a two-step approach with ffmpeg,
and that also worked. Telling ffmpeg to go MP4->.aac->.m4a made LMS
happy, but obviously any true one-line solution is going to be
preferable. I've encapsulated it in a bash script file with lots of
comments.

Now I'm off to score a copy of that record and play with the YouTube
plugin.

Thank you everyone again very, very much!


------------------------------------------------------------------------
atrocity's Profile: http://forums.slimdevices.com/member.php?userid=16009
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
bpa
2018-12-06 16:49:45 UTC
Permalink
Post by atrocity
That in turn gave me the idea to try a two-step approach with ffmpeg,
and that also worked. Telling ffmpeg to go MP4->.aac->.m4a made LMS
happy, but obviously any true one-line solution is going to be
preferable. I've encapsulated it in a bash script file with lots of
comments.
You should be able to use "-vn -c:a copy" in your command and so have a
single step ffmpeg conversion.


------------------------------------------------------------------------
bpa's Profile: http://forums.slimdevices.com/member.php?userid=1806
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
atrocity
2018-12-06 18:18:00 UTC
Permalink
Post by bpa
You should be able to use "-vn -c:a copy" in your command and so have a
single step ffmpeg conversion.
Yes...bad wording on my part. I meant that I had discovered the two-step
process before reading your post and am happy that you were able to give
me a very useful all-in-one method.

A curious thing with some (but not all) YouTube videos: You can download
lower-resolution video with better audio, higher-resolution video with
lesser audio or -silent- video at even higher resolutions. So if you
want to make the best version of that "Atom Heart Mother" performance
for yourself, you need to download the silent video, then download one
with reasonable audio, demux the audio and mux it with the better video.
Fortunately, it almost takes longer to explain than to do.


------------------------------------------------------------------------
atrocity's Profile: http://forums.slimdevices.com/member.php?userid=16009
View this thread: http://forums.slimdevices.com/showthread.php?t=109839
Loading...