Create an AAC stream matching the Core Media Audio packet format / priming etc?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
45 messages Options
123
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
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

ffmpeg -i SyncTest24p.mov -c:v libx264 -pix_fmt yuv420p -movflags faststart -c:a aac -b:a 128k ffmpeg.mp4
ffmpeg version N-85343-gd0a3143-tessus Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzvbi --enable-version3 --disable-ffplay --disable-indev=qtkit
  libavutil      55. 60.100 / 55. 60.100
  libavcodec     57. 92.100 / 57. 92.100
  libavformat    57. 72.100 / 57. 72.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 84.100 /  6. 84.100
  libswscale      4.  7.100 /  4.  7.100
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SyncTest24p.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2017-04-14T13:37:46.000000Z
    timecode        : 01:00:00:00
  Duration: 00:00:02.00, start: 0.000000, bitrate: 118705 kb/s
    Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn / 0x6E645641), yuv422p(tv, bt709/unknown/unknown), 1920x1080, 116391 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2017-04-14T13:37:46.000000Z
      handler_name    : Apple Alias Data Handler
      encoder         : Avid DNxHD Codec
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      creation_time   : 2017-04-14T13:37:46.000000Z
      handler_name    : Apple Alias Data Handler
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2017-04-14T13:37:46.000000Z
      handler_name    : Apple Alias Data Handler
      timecode        : 01:00:00:00
Stream mapping:
  Stream #0:0 -> #0:0 (dnxhd (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s24le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7ff1ae809200] using SAR=1/1
[libx264 @ 0x7ff1ae809200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7ff1ae809200] profile High, level 4.0
[libx264 @ 0x7ff1ae809200] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'ffmpeg.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    timecode        : 01:00:00:00
    encoder         : Lavf57.72.100
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2017-04-14T13:37:46.000000Z
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc57.92.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp (24 bit), 128 kb/s (default)
    Metadata:
      creation_time   : 2017-04-14T13:37:46.000000Z
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc57.92.100 aac
[mp4 @ 0x7ff1ae81ec00] Starting second pass: moving the moov atom to the beginning of the file
frame=   48 fps=0.0 q=-1.0 Lsize=      24kB time=00:00:02.00 bitrate=  97.2kbits/s speed= 3.6x
video:17kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 15.142209%
[libx264 @ 0x7ff1ae809200] frame I:1     Avg QP:18.80  size:  4448
[libx264 @ 0x7ff1ae809200] frame P:14    Avg QP:16.87  size:   374
[libx264 @ 0x7ff1ae809200] frame B:33    Avg QP:23.31  size:   227
[libx264 @ 0x7ff1ae809200] consecutive B-frames:  2.1% 16.7%  6.2% 75.0%
[libx264 @ 0x7ff1ae809200] mb I  I16..4: 52.6% 46.2%  1.2%
[libx264 @ 0x7ff1ae809200] mb P  I16..4:  0.0%  0.0%  0.1%  P16..4:  0.2%  0.1%  0.0%  0.0%  0.0%    skip:99.6%
[libx264 @ 0x7ff1ae809200] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%  0.1%  0.0%  direct: 0.0%  skip:99.7%  L0:60.9% L1:38.1% BI: 1.0%
[libx264 @ 0x7ff1ae809200] 8x8 transform intra:45.8% inter:14.5%
[libx264 @ 0x7ff1ae809200] coded y,uvDC,uvAC intra: 1.4% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7ff1ae809200] i16 v,h,dc,p: 97%  0%  3%  0%
[libx264 @ 0x7ff1ae809200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 62%  2% 36%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x7ff1ae809200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 16% 33%  5%  2%  4%  2%  6%  2%
[libx264 @ 0x7ff1ae809200] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 0x7ff1ae809200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7ff1ae809200] ref P L0: 70.5%  1.8% 16.3% 11.3%
[libx264 @ 0x7ff1ae809200] ref B L0: 58.5% 32.1%  9.4%
[libx264 @ 0x7ff1ae809200] ref B L1: 90.6%  9.4%
[libx264 @ 0x7ff1ae809200] kb/s:68.72
[aac @ 0x7ff1ae80aa00] Qavg: 61514.836

Attached is an ffprobe log file showing the audio packets for this ffmpeg encode.
Also, I ran the same source file through Apple Compressor v4.3.1 to the same output file spec and through YouTube and have attached ffprobe logs of their audio packets.

Apologies if I’ve not gone about this the right way, I’m not trying to demonstrate a bug, simply want to highlight the differences between the initial packets of these files and see if there is a way to produce a file via ffmpeg which uses a packet ‘setup’ similar to the Compressor or even YouTube way as this plays very nice with Quicktime decoders.

Perhaps the key here is that ffmpeg has a negative pts for the first packet and this is what Quicktime struggles with I would think. It also has SIDE DATA which Quicktime may also be struggling with, but I’ve not found much info on this and from my understanding Quicktime always assumes 2112 samples of delay at the start.
https://developer.apple.com/library/content/technotes/tn2258/_index.html

Start of ffmpeg file:

[PACKET]
codec_type=audio
stream_index=1
pts=-1024
pts_time=-0.021333
dts=-1024
dts_time=-0.021333
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=300
pos=8722
flags=KD
[SIDE_DATA]
side_data_type=Skip Samples
skip_samples=1024
discard_padding=0
skip_reason=0
discard_reason=0
[/SIDE_DATA]
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=0
pts_time=0.000000
dts=0
dts_time=0.000000
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=410
pos=9351
flags=K_
[/PACKET]
...

Start of Compressor file:

[PACKET]
codec_type=audio
stream_index=0
pts=0
pts_time=0.000000
dts=0
dts_time=0.000000
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=6
pos=2320
flags=K_
[/PACKET]
...

Start of YouTube file:

[PACKET]
codec_type=audio
stream_index=1
pts=0
pts_time=0.000000
dts=0
dts_time=0.000000
duration=1024
duration_time=0.023220
convergence_duration=N/A
convergence_duration_time=N/A
size=557
pos=9043
flags=K_
[/PACKET]


Thank you if you have read this far, I really appreciate it. I’m slightly worried this is going to open a can of worms which will be above my pay grade!

Anyway, assuming I have provided enough info (and I can send anyone the source file if they want it), are there any options / flags etc I could add to the command to bring the encode in line with the Compressor or YouTube outputs in terms of the aac audio stream?

Many many thanks for any help,

Regards
Mark





_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

uncut console output loglevel 99.txt (108K) Download Attachment
ffprobe ffmpeg.txt (31K) Download Attachment
ffprobe Compressor.txt (30K) Download Attachment
ffprobe YouTube.txt (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
* 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

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.

--
  Was heißt hier Dogma, ich bin Underdogma!
[ What the hell do you mean dogma, I am underdogma. ]
free movies       --->>> https://blacktrash.org/underdogma
http://itunes.apple.com/podcast/underdogma-movies/id363423596
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
On 14 Apr 2017, 17:47 +0100, Christian Ebert <[hidden email]>, 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]

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

ffprobe =?utf-8?Q?ffmpeg=5Fv2.txt?= (31K) Download Attachment
ffprobe =?utf-8?Q?ffmpeg=5Fv3.txt?= (31K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
* Mark Burton on Friday, April 14, 2017 at 21:45:07 +0100

>> * Mark Burton on Friday, April 14, 2017 at 16:57:06 +0100
>>> 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.

Inserting

-t `ffprobe -v quiet -of default=nw=1:nk=1 -select_streams V -show_entries stream=duration SyncTest24p.mov`

into your commandline should do the trick.

imho this is a muxing bug in dealing with aac priming in many
situations, but making my case fell on deaf ears.

--
\black\trash movie         _SAME  TIME  SAME  PLACE_
 --->> https://blacktrash.org/underdogma/stsp.php
\black\trash audio   _ANOTHER  TIME  ANOTHER  PLACE_
--->> https://blacktrash.org/underdogma/atap.html
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton

> On 14 Apr 2017, at 22:22, Christian Ebert <[hidden email]> wrote:
>>> 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.
>
> Inserting
>
> -t `ffprobe -v quiet -of default=nw=1:nk=1 -select_streams V -show_entries stream=duration SyncTest24p.mov`
>
> into your commandline should do the trick.

Adding '-t 2.000000’ to the command does help a little, but ultimately the final audio packet is still too large - 6ms in this case - and the black frame still occurs.

[PACKET]
codec_type=audio
stream_index=1
pts=95232
pts_time=1.984000
dts=95232
dts_time=1.984000
duration=1056
duration_time=0.022000
convergence_duration=N/A
convergence_duration_time=N/A
size=406
pos=23401
flags=K_
[/PACKET]


> imho this is a muxing bug in dealing with aac priming in many
> situations, but making my case fell on deaf ears.

It feels a bit odd having to chase the output file in this way doesn’t it. I’ve read a number of the reports around this issue (perhaps some from you?) and there does appear to be a real difference of opinion on both sides.

How do you work round this in your products? I find it hard having to accept an encode will always play out of sync on certain players.

Thank so much for your help,

Regards
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Carl Eugen Hoyos-2
2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
> I find it hard having to accept an encode will always play out of
> sync on certain players.

Could you elaborate a little?
So far, for every ticket, it either turned out that out-of-sync was
not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
by-one-frame which I consider hard to reproduce...

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Marton Balint

On Sat, 15 Apr 2017, Carl Eugen Hoyos wrote:

> 2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
>> I find it hard having to accept an encode will always play out of
>> sync on certain players.
>
> Could you elaborate a little?
> So far, for every ticket, it either turned out that out-of-sync was
> not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
> by-one-frame which I consider hard to reproduce...

Last time I checked (a year ago or so), ffmpeg created a correct .mov edit
list to signal the audio priming.

https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html

Here is patch which writes Sample Group Description Atom and the
Sample-To-Group Atom as well, in addition to the already existing edit
list.

You can check if it makes a difference or not.

Regards,
Marton
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

0001-avformat-movenc-add-support-for-writing-AAC-Audio-Pr.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
On 15 Apr 2017, 06:55 +0100, Marton Balint <[hidden email]>, wrote:

> On Sat, 15 Apr 2017, Carl Eugen Hoyos wrote:
>
> > 2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
> > > I find it hard having to accept an encode will always play out of
> > > sync on certain players.
> >
> > Could you elaborate a little?
> > So far, for every ticket, it either turned out that out-of-sync was
> > not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
> > by-one-frame which I consider hard to reproduce...
>
> Last time I checked (a year ago or so), ffmpeg created a correct .mov edit
> list to signal the audio priming.
>
> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>
> Here is patch which writes Sample Group Description Atom and the
> Sample-To-Group Atom as well, in addition to the already existing edit
> list.
>
> You can check if it makes a difference or not.

Thanks Martin. I use a precompiled binary of the latest snapshot build from https://evermeet.cx/ffmpeg. Apologies, I’m not familiar with how to test an individual patch, but I’m sure it involves compiling the source and although I’ve used brew install a few times, I’m very much a novice in that area.

Has your patch not been committed to the project?

Thanks
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
In reply to this post by Carl Eugen Hoyos-2
On 14 Apr 2017, 23:45 +0100, Carl Eugen Hoyos <[hidden email]>, wrote:

> 2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
> > I find it hard having to accept an encode will always play out of
> > sync on certain players.
>
> Could you elaborate a little?
> So far, for every ticket, it either turned out that out-of-sync was
> not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
> by-one-frame which I consider hard to reproduce…

Hi Carl,

Thanks for taking the time to look at this again, it really is appreciated. My environment is post production based. We work in DNxHD with PCM audio which is in sync with the picture inside the Avid editing system. We export using same as source to make a 24fps (not 23.976) Avid DNx115 video, 48khz 24bit PCM audio Quicktime .mov file. This file plays back in any decoder in sync, exactly the same as it did inside the Avid software.

Take this file, encode with ffmpeg using native aac and playback in Quicktime Player 7 or X or Switch or any other player which uses a Quicktime decoder and it is now out of sync by 1 frame (audio is early). The same encode played back in VLC shows about 1/2 frame of sync slip.

I have yet to produce a .mov or .mp4 with any ffmpeg build with an AAC stream which plays back in sync (the same sync as the source file) in Quicktime based decoders.

A good test file is to have a visual and audible 1 frame pip on the first frame, then the same on the last frame. Create it with PCM audio and using a video codes such as DNx or MJPEG. Encode this with a standard command:

ffmpeg -i SyncTest24p.mov -c:v copy -c:a aac -b:a 128k ffmpeg_aac.mov

The first frame where there used to be an audible pip, is now mute. The end pip now plays approx. 1 frame early. I think in the past you’ve asked how can we know that AV-sync is off by 0.04 seconds. I can’t tell you the ‘exact' amount it is off by, but I do know that the first pip is gone completely and end pip is approx. 1 frame early, but overall the sync in the encoded file does not match the original and is therefore out of sync.

Perhaps there is somewhere I could upload and share my test file for you to test?

I’m really mindful that my explanation may not be technically the best and hopefully others who have been reporting this may chime in to offer data which is more quantifiable. However, I will do anything I can to help resolve this if at all possible.

Many thanks and kind regards,
Mark


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
In reply to this post by Mark Burton
* Mark Burton on Friday, April 14, 2017 at 22:44:52 +0100

>> On 14 Apr 2017, at 22:22, Christian Ebert <[hidden email]> wrote:
>>>> 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
>>>
>>> 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.
>>
>> Inserting
>>
>> -t `ffprobe -v quiet -of default=nw=1:nk=1 -select_streams V -show_entries stream=duration SyncTest24p.mov`
>>
>> into your commandline should do the trick.
>
> Adding '-t 2.000000’ to the command does help a little, but ultimately the final audio packet is still too large - 6ms in this case - and the black frame still occurs.

Works for me with all my sample results I checked.

Somewhat counterintuitive, but you never know:

-filter:a aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+1024

combined with the -t incantation.

--
theatre - books - texts - movies
Black Trash Productions at home: https://blacktrash.org
Black Trash Productions on Facebook:
https://www.facebook.com/blacktrashproductions
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
In reply to this post by Carl Eugen Hoyos-2
* Carl Eugen Hoyos on Saturday, April 15, 2017 at 00:44:43 +0200
> 2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
>> I find it hard having to accept an encode will always play out of
>> sync on certain players.
>
> Could you elaborate a little?
> So far, for every ticket, it either turned out that out-of-sync was
> not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
> by-one-frame which I consider hard to reproduce...

In theory it is probably correct that it's the task of the
decoding application to make the aac priming work. In many real
world scenarios this does not happen.

I do a lot of segmenting, and can always reproduce it with the
hls muxer:

https://trac.ffmpeg.org/ticket/3859
I closed it because, as per last comment I finally resorted to
the workaround(?) mentioned here.
https://trac.ffmpeg.org/ticket/3859#comment:13
https://sourceforge.net/p/opencore-amr/mailman/message/32912437/

If you see a HLS playlist where the TARGETDURATION is higher than
the duration of any segments than the first you can bet it has
been created by ffmpeg.

And if you don't clip at the end, you can easily get invalid
audio-only segments as last segment, and end of video may not be
detected in the majority of real world scenarios, arguably when
you play HLS in a browser.

So, apart from introducing minimal async, it also has other
repercussions.

Why not a warning, ideally with a hint as to how to best deal
with the situation, similar to the one about pix_fmpt yuv420p:

Use -pix_fmt yuv420p for compatibility with outdated media players.

Maybe there is no correct solution, and the delay hint in the
verbose output was certainly helpful, at least in my case; it
also points to some awareness of a potential problem area. It
just took me a long time to find it.

--
  Was heißt hier Dogma, ich bin Underdogma!
[ What the hell do you mean dogma, I am underdogma. ]
free movies       --->>> https://blacktrash.org/underdogma
http://itunes.apple.com/podcast/underdogma-movies/id363423596
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
In reply to this post by Marton Balint
* Marton Balint on Saturday, April 15, 2017 at 07:55:22 +0200

> Last time I checked (a year ago or so), ffmpeg created a correct .mov
> edit list to signal the audio priming.
>
> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>
> Here is patch which writes Sample Group Description Atom and the
> Sample-To-Group Atom as well, in addition to the already existing edit
> list.
>
> You can check if it makes a difference or not.

Unfortunately the patch doesn't apply.

> Regards,
> Marton

> From 64d9db76038b7b248bffe459b58b138c6b8fcc03 Mon Sep 17 00:00:00 2001
> From: Marton Balint <[hidden email]>
> Date: Sat, 20 Feb 2016 19:32:18 +0100
> Subject: [PATCH] avformat/movenc: add support for writing AAC Audio Priming
> metadata
>
> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>
> Signed-off-by: Marton Balint <[hidden email]>
> ---
> libavformat/movenc.c                | 21 ++++++++++++++-------
> tests/ref/fate/adtstoasc_ticket3715 |  4 ++--
> tests/ref/fate/copy-psp             |  4 ++--
> tests/ref/fate/movenc               | 12 ++++++------
> 4 files changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index e6a70bf..5779e3c 100644

I could not find commit e6a70bf either.

--
theatre - books - texts - movies
Black Trash Productions at home: https://blacktrash.org
Black Trash Productions on Facebook:
https://www.facebook.com/blacktrashproductions
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Marton Balint

On Sat, 15 Apr 2017, Christian Ebert wrote:

> * Marton Balint on Saturday, April 15, 2017 at 07:55:22 +0200
>> Last time I checked (a year ago or so), ffmpeg created a correct .mov
>> edit list to signal the audio priming.
>>
>> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>>
>> Here is patch which writes Sample Group Description Atom and the
>> Sample-To-Group Atom as well, in addition to the already existing edit
>> list.
>>
>> You can check if it makes a difference or not.
>
> Unfortunately the patch doesn't apply.
>
Hmm, a recent fix changed one of the hunk contexts... Could you try this
new attached patch?

Thanks,
Marton
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

0001-avformat-movenc-add-support-for-writing-AAC-Audio-Pr.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Christian Ebert
* Marton Balint on Saturday, April 15, 2017 at 12:25:58 +0200
> On Sat, 15 Apr 2017, Christian Ebert wrote:
>> * Marton Balint on Saturday, April 15, 2017 at 07:55:22 +0200
>>> Last time I checked (a year ago or so), ffmpeg created a correct .mov
>>> edit list to signal the audio priming.
>>>
>>> https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>
> Hmm, a recent fix changed one of the hunk contexts... Could you try
> this new attached patch?

I'm afraid for my purpose - segmenting - it does not make a
difference. I still get the same overlong first segments;
depending on codec - native aac has much shorter 'delays' than
fdk-aac, they are minute, but they still make the hls muxer set a
1 second higher TARGETDURATION, even when all segments are of the
exact duration up to the sixth decimal - this can be corrected
by hand because the spec tolerates such minimal divergences.

But again, for the purpose of segmenting it has not any effect.

It may well fix Mark's use case. I haven't checked that.

--
\black\trash movie    _MORALISK  ANSTALT_
                        "Nix verstanden."

--->> https://blacktrash.org/underdogma/moraliskanstalt.php
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
In reply to this post by Christian Ebert
On 15 Apr 2017, 09:22 +0100, Christian Ebert <[hidden email]>, wrote:

> * Mark Burton on Friday, April 14, 2017 at 22:44:52 +0100
> > > On 14 Apr 2017, at 22:22, Christian Ebert <[hidden email]> wrote:
> > > > > 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
> > > >
> > > > 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.
> > >
> > > Inserting
> > >
> > > -t `ffprobe -v quiet -of default=nw=1:nk=1 -select_streams V -show_entries stream=duration SyncTest24p.mov`
> > >
> > > into your commandline should do the trick.
> >
> > Adding '-t 2.000000’ to the command does help a little, but ultimately the final audio packet is still too large - 6ms in this case - and the black frame still occurs.
>
> Works for me with all my sample results I checked.
>
> Somewhat counterintuitive, but you never know:
>
> -filter:a aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+1024
>
> combined with the -t incantation.

Same result for me as before - the last packet is too large (1056) and is not being trimmed, so a black frame occurs at the end on playback.
When you say it works for you, was that with a Quicktime based decoder?

Thanks
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
In reply to this post by Mark Burton
On 15 Apr 2017, 09:18 +0100, Mark Burton <[hidden email]>, wrote:

> On 14 Apr 2017, 23:45 +0100, Carl Eugen Hoyos <[hidden email]>, wrote:
> > 2017-04-14 23:44 GMT+02:00 Mark Burton <[hidden email]>:
> > > I find it hard having to accept an encode will always play out of
> > > sync on certain players.
> >
> > Could you elaborate a little?
> > So far, for every ticket, it either turned out that out-of-sync was
> > not reproducible with MPlayer / vlc (and FFmpeg) or it was off-
> > by-one-frame which I consider hard to reproduce…
>
> Hi Carl,
>
> Thanks for taking the time to look at this again, it really is appreciated. My environment is post production based. We work in DNxHD with PCM audio which is in sync with the picture inside the Avid editing system. We export using same as source to make a 24fps (not 23.976) Avid DNx115 video, 48khz 24bit PCM audio Quicktime .mov file. This file plays back in any decoder in sync, exactly the same as it did inside the Avid software.
>
> Take this file, encode with ffmpeg using native aac and playback in Quicktime Player 7 or X or Switch or any other player which uses a Quicktime decoder and it is now out of sync by 1 frame (audio is early). The same encode played back in VLC shows about 1/2 frame of sync slip.
>
> I have yet to produce a .mov or .mp4 with any ffmpeg build with an AAC stream which plays back in sync (the same sync as the source file) in Quicktime based decoders.
>
> A good test file is to have a visual and audible 1 frame pip on the first frame, then the same on the last frame. Create it with PCM audio and using a video codes such as DNx or MJPEG. Encode this with a standard command:
>
> ffmpeg -i SyncTest24p.mov -c:v copy -c:a aac -b:a 128k ffmpeg_aac.mov
>
> The first frame where there used to be an audible pip, is now mute. The end pip now plays approx. 1 frame early. I think in the past you’ve asked how can we know that AV-sync is off by 0.04 seconds. I can’t tell you the ‘exact' amount it is off by, but I do know that the first pip is gone completely and end pip is approx. 1 frame early, but overall the sync in the encoded file does not match the original and is therefore out of sync.
>
> Perhaps there is somewhere I could upload and share my test file for you to test?
>
> I’m really mindful that my explanation may not be technically the best and hopefully others who have been reporting this may chime in to offer data which is more quantifiable. However, I will do anything I can to help resolve this if at all possible.


Hi Carl,

Did you have any thoughts on this?

Christians fix helps with the sync issue, although not 100%, but the downside is that it creates an even longer audio track, which causes Quicktime decoders to create a bogus black end frame.

Do you not see the same behaviour?

Kind regards
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

mjpegenc change to optimal huffman coding as default and Quicktime Player 7

Mark Burton
In reply to this post by Christian Ebert
This caught me out today, so just as an FYI to anyone else this might affect, the change to enable ‘optimal' huffman coding by default since Sunday 9th April, does cause playback to break in Quicktime Player 7 on macOS. Since Quicktime Player 7 is very old now this is understandable, but for anyone that needs to maintain compatibility, add '-huffman default' to your mjpeg command.

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/45eeb1f785d6c726181568db341bbf80b43e32c0
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Mark Burton
In reply to this post by Marton Balint
On 15 Apr 2017, 11:26 +0100, Marton Balint <[hidden email]>, wrote:

> Hmm, a recent fix changed one of the hunk contexts... Could you try this
> new attached patch?

Is this patch likely to be applied in the near future? Thanks.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Carl Eugen Hoyos-2
2017-05-09 15:58 GMT+02:00 Mark Burton <[hidden email]>:
> On 15 Apr 2017, 11:26 +0100, Marton Balint <[hidden email]>, wrote:
>
>> Hmm, a recent fix changed one of the hunk contexts... Could
>> you try this new attached patch?
>
> Is this patch likely to be applied in the near future? Thanks.

The only comment I see above is that the patch does not fix
any issue, so while I haven't looked at it, I consider this more
of an argument against applying it.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create an AAC stream matching the Core Media Audio packet format / priming etc?

Carl Eugen Hoyos-2
In reply to this post by Mark Burton
2017-04-18 14:21 GMT+02:00 Mark Burton <[hidden email]>:

> Do you not see the same behaviour?

No, unfortunately not.

I have dealt with (reproduced) several hundred issues related to
A/V sync over the last decade. Some of them were about mostly
missing audio, some about increasing desync, many (most) are
related to audio "missing" in the source media.
Some are desync in the range of seconds, many around 100ms
(which I still consider very bad), some significantly less: harder
to reproduce but still definitely bugs that should be fixed.

If you say audio is off by one frame, I am not the right person
to talk to because I have no idea how to reproduce.

If the effect can be multiplied by encoding several times with
FFmpeg, things would of course be different: Is that the case?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
123
Loading...