3

I have several video and audio files on my server that I wish to stream. I have converted all video files to mp4 and audio files to aac.

Now I am streaming both type of files but it seems audio files are taking longer, much longer, to begin playing than videos. Sometimes I can see it buffering the entire file before it starts playing it.

I am not sure if it has any effect but for video files I use the -movflags faststart option and it gets the job done.

I was wondering if there is something similar to be done for audio files to make them start playing faster.

EDIT:

here is how I run the command to convert the files:

ffmpeg -i OriginalPath.wma -strict experimental -c:a aac -b:a 128k -n SomePath.m4a

And I use the HTML5 web player to play them from my server.

Zaid Amir
  • 207
  • 3
  • 7
  • 17
  • What actual files do you export your aac tracks to ? .aac files ? If so, I'd recommend .m4a (the same as mp4 but with a different name often associated with audio-only). – Ely Oct 06 '15 at 14:44
  • What is your ffmpeg command and complete console output? How are you playing the files? – llogan Oct 06 '15 at 20:46
  • Try adding `-movflags +faststart` to the command in your question. – llogan Oct 07 '15 at 17:00
  • @LordNeckbeard that seems to work. I was under the impression that this was only for video files. One question though, why the + sign before faststart? – Zaid Amir Oct 08 '15 at 05:32
  • The `+` should add it to any default flags (assuming if there are any). Without it I believe it will clear everything but faststart, but I haven't actually looked into this or tested it. – llogan Oct 09 '15 at 16:45

2 Answers2

2

You can still use -movflags +faststart with MP4 & M4A outputs that just contain audio.

llogan
  • 57,139
  • 15
  • 118
  • 145
0

If you have files in m4a (m4a is ipod extension files, so old), then you have to put it into a container friendly for html5, like mp4.

ffmpeg -i SomePath.m4a -c copy -strict -2 audio_friendly.mp4

I think that your problem is your html5 code for playing this audio file, because the -movflags +faststart is only if in you mp4 has videos... this code here is ignored, so in your html file, you have to know the attr and his options

<audio src="audio_friendly.mp4" preload="" controls></audio>

The "preload" option have to be your problem, how do you configure it?

preload

Used for buffering large files; it can take one of three values:

 "none" does not buffer the file
 "auto" buffers the media file
 "metadata" buffers only the metadata for the file

The source for html5 audio

Hashim Aziz
  • 11,898
  • 35
  • 98
  • 166
xear
  • 32
  • 4