[FFmpeg-user] Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton mwjburton at gmail.com
Fri Apr 14 23:45:07 EEST 2017


On 14 Apr 2017, 17:47 +0100, Christian Ebert <blacktrash at gmx.net>, wrote:

> * Mark Burton on Friday, April 14, 2017 at 16:57:06 +0100
> > I appreciate this is a tricky area and there appear to be different ways that some encoders create AAC streams with regards to the padding and remaining samples etc. I won’t pretend to fully understand all the factors, but I would like to ask a genuine question which purely comes from the point of view of wanting to create a file for my working environment - an environment dominated by Quicktime 7 and X playback / decoding tools. I’m no great fan of Quicktime and appreciate its not well loved here also. In my industry it is still very much the defecto playback engine though, so if I’m able to tailor a file for this decoder, it would be an enormous help.
> >
> > Let me also say, I am not accusing ffmpeg of having an issue, I have read a number of ‘bug’ reports surrounding ffmpeg and AAC priming and there being a sync discrepancy in the resultant encode when played back in certain decoders. I happen to see the exact same issue, but from some of the developers replies, I accept their position is that they feel ffmpeg is doing it the right way and its the decoders that are at fault.
> >
> > With that said, I’d like to approach this question purely from the point of view of finding out whether there is a way to tweak a command in order to change this way the aac stream is created to produce an mp4 or mov file using the native aac encoder which decodes in Quicktime 7 or X, in sync. Currently an encoded file plays back 1 frame out of sync (audio is early by approx. 1 frame). In VLC its about 1/2 a frame out of sync.
> >
> > The source file is a .mov, DNx115 24p (true 24p, not 23.976), PCM 24bit 48khz audio, which is in sync. This is film material where sync is crucial and always expected.
> >
> > Here is the basic command to reproduce. I have attached the uncut loglevel 99 console output for this command:
> > ffmpeg -i SyncTest24p.mov -c:v libx264 -pix_fmt yuv420p -movflags faststart -c:a aac -b:a 128k ffmpeg.mp4
>
> Can you try:
>
> -filter:a aresample=first_pts=0

Thanks for your reply and these options to test. This first one does not appear to change the outcome. ffprobe for ffmpeg_v2 attached.

> Also, when you run with -v verbose, you'll see a delay (depends
> on audio codec), for you case it's probably 1024. Maybe try:
>
> -filter:a aresample=first_pts=0,asetpts=PTS-STARTPTS+1024
>
> Especially the latter could be exactly the wrong thing for your
> purpose, but it doesn't hurt trying.

1024 looks correct. This method successfully changes the start, and the encoded audio plays, almost, 100% in sync. Its slightly cut off at the head, but only very slightly. However the downside of this method is that the audio now overruns the end of the picture further and is not trimmed from remaining samples I’m guessing. This results in a blank video frame being added to the tail of clip. ffprobe for ffmpeg_v3 attached
.

I tried using -shortest, but that didn’t help address the above issue.

Last audio packet of original encode is:

[PACKET]
codec_type=audio
stream_index=1
pts=95232
pts_time=1.984000
dts=95232
dts_time=1.984000
duration=768
duration_time=0.016000
convergence_duration=N/A
convergence_duration_time=N/A
size=313
pos=24058
flags=K_
[/PACKET]

Last packet of encode using '-filter:a aresample=first_pts=0,asetpts=PTS-STARTPTS+1024’ is:

[PACKET]
codec_type=audio
stream_index=1
pts=96256
pts_time=2.005333
dts=96256
dts_time=2.005333
duration=800
duration_time=0.016667
convergence_duration=N/A
convergence_duration_time=N/A
size=313
pos=24038
flags=K_
[/PACKET]
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffprobe ffmpeg_v2.txt
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20170414/9c5787fb/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffprobe ffmpeg_v3.txt
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20170414/9c5787fb/attachment-0001.txt>


More information about the ffmpeg-user mailing list