[FFmpeg-user] drawtext filter box jittery issue

2019-02-02 Thread Mark Burton
When displaying a frame count number in the drawtext filter, the varying height 
of the characters can make the text jitter vertically as they count. Its 
possible to stop this by applying the ‘ascent' value to the y coordinate.

However when the drawtext filter contains a box, this element also jitters 
vertically and there doesn’t appear to be a way to apply the same method of 
using the ‘ascent’ value to stabilise it.

Here is an example command (font is relevant to macOS):

ffmpeg -f lavfi -i "color=red:size=1280x720:rate=24" -y -t 12 -c:v mjpeg 
-qscale:v 4 -huffman default -pix_fmt yuvj422p -vf 
"drawtext=fontfile=/System/Library/Fonts/Geneva.dfont: fontcolor=white: 
fontsize=150: box=1: boxcolor=black: boxborderw=5: x=640: y=500-ascent: 
text=%{n}: start_number=0" output.mov

In the above example, including ‘-ascent' in the y coordinate value stops the 
number characters from being jittery as they count. However you can see the box 
is still jittery and does not seem to support having the ‘-ascent’ value 
applied to it.

Is there any way to negate this jitter when using a box? Thanks.


Full uncut command:

ffmpeg version N-93020-g3224d6691c-tessus  https://evermeet.cx/ffmpeg/  
Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg 
--extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl 
--enable-libaom --enable-libass --enable-libbluray --enable-libdav1d 
--enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame 
--enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb 
--enable-libopenh264 --enable-libopenjpeg --enable-libopus 
--enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr 
--enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab 
--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack 
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs 
--enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi 
--enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil  56. 26.100 / 56. 26.100
  libavcodec 58. 44.100 / 58. 44.100
  libavformat58. 26.100 / 58. 26.100
  libavdevice58.  6.101 / 58.  6.101
  libavfilter 7. 48.100 /  7. 48.100
  libswscale  5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc55.  4.100 / 55.  4.100
Input #0, lavfi, from 'color=red:size=1280x720:rate=24':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 
1:1 DAR 16:9], 24 tbr, 24 tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7fce5b00d800] deprecated pixel format used, make sure you did set 
range correctly
Output #0, mov, to 'output.mov':
  Metadata:
encoder : Lavf58.26.100
Stream #0:0: Video: mjpeg (jpeg / 0x6765706A), yuvj422p(pc), 1280x720 [SAR 
1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 12288 tbn, 24 tbc
Metadata:
  encoder : Lavc58.44.100 mjpeg
Side data:
  cpb: bitrate max/min/avg: 0/0/20 buffer size: 0 vbv_delay: -1
frame=  288 fps=0.0 q=4.0 Lsize=7103kB time=00:00:11.95 
bitrate=4865.5kbits/s speed=19.7x
video:7101kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 0.027039%
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Invisible watermarking filter

2018-07-11 Thread Mark Burton
Is there or has there ever been any support for an invisible watermarking 
filter in ffmpeg? Or perhaps there is an external project that supports this?

This (now closed) job posting that someone listed a while ago, outlines what I 
would be looking for:
https://www.freelancer.co.uk/projects/c-programming-linux/ffmpeg-invisible-watermarking/
 

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-13 Thread Mark Burton


> On 8 Mar 2018, at 23:37, Mark Burton  wrote:
> 
> On 8 Mar 2018, at 22:29, Carl Eugen Hoyos  <mailto:ceffm...@gmail.com>> wrote:
>> One possibility is that you run "git diff libavformat/movenc.h" to verify you
>> have only changed this one value (this assumes you have originally done
>> "git clone" and not "curl..."), then run "git commit libavformat/movenc.h" to
>> start the commit line editor, type "i" (I believe this will be necessary to 
>> get
>> into insert mode) and "lavf/movenc: Change MOV_TIMESCALE
>> to 600" followed by two (!) carriage returns and an explanation why this is
>> a good idea (because seeking works better in some other software), then
>> exit the editor (it's "ESC" ":wq" here) and get back to the shell. There, run
>> "git format-patch HEAD^" to get a file 0001-lavf-movenc... that you send
>> as attachment to the ffmpeg-devel mailing list and "git reset HEAD^" to
>> clean your local checkout.
> 
> Fantastic. I’ve just submitted the patch to the developer list. Will do my 
> best to answer the questions that come my way!

Was the resubmit correct?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-08 Thread Mark Burton
On 8 Mar 2018, at 22:29, Carl Eugen Hoyos  wrote:
> One possibility is that you run "git diff libavformat/movenc.h" to verify you
> have only changed this one value (this assumes you have originally done
> "git clone" and not "curl..."), then run "git commit libavformat/movenc.h" to
> start the commit line editor, type "i" (I believe this will be necessary to 
> get
> into insert mode) and "lavf/movenc: Change MOV_TIMESCALE
> to 600" followed by two (!) carriage returns and an explanation why this is
> a good idea (because seeking works better in some other software), then
> exit the editor (it's "ESC" ":wq" here) and get back to the shell. There, run
> "git format-patch HEAD^" to get a file 0001-lavf-movenc... that you send
> as attachment to the ffmpeg-devel mailing list and "git reset HEAD^" to
> clean your local checkout.

Fantastic. I’ve just submitted the patch to the developer list. Will do my best 
to answer the questions that come my way!

Thanks again Carl.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-08 Thread Mark Burton
On 8 Mar 2018, at 17:21, Carl Eugen Hoyos  wrote:
> You need a compiler, make and git. Iirc, all three are installed if you
> type something like "gcc -v" on the command line (but I assume they
> are now installed by brew).

Thank you very much! That filled in a few blanks for me and I was able to get 
it all working. So I built from the current git and tested the ffmpeg build. 
The timescale issue was still the same, with inaccurate seeking.

Then in movenc.h I changed MOV_TIMESCALE from 1000 to 24000 and built ffmpeg 
again. This time the output .mov worked, with no seeking issues!

Finally in movenc.h I changed MOV_TIMESCALE to 600 and built ffmpeg again. 
Again, the output .mov worked, with no seeking issues!

I imagine some exhaustive testing is needed for other workflows, and I’m 
obviously not aware yet of why 1000 was chosen for ffmpeg (??), but based on 
the Quicktime specification documents and what the default timescale is set to 
there, it would seem that a switch from 1000 to 600 could be a very positive 
change.

Please could you advise what I would need to do from here to move things 
forward.

Many thanks again for your time and help getting ffmpeg built.

Regards
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-08 Thread Mark Burton
On 8 Mar 2018, at 16:38, Carl Eugen Hoyos  wrote:
> 2018-03-08 15:57 GMT+01:00, Mark Burton :
>> 
>> Understood. A better option would no doubt be the ability to specify this
>> value in the same way we can specify the video_track_timescale value.
> If it would not fix your issue why would it be a good option?

Fair enough. The current ffmpeg default is 1000. This is not divisible by 24, 
30 or 60fps. The default in the Quicktime specification is 600. This is cleanly 
divisible by 24, 25, 30, 50, 60, so is a very good value for the majority of 
professional fixed frame rates. I accept these do not represent all fixed frame 
rates, but it is evidently a better value than 1000.

https://developer.apple.com/library/content/documentation/QuickTime/RM/Fundamentals/QTOverview/QTOverview_Document/QuickTimeOverview.html
 
<https://developer.apple.com/library/content/documentation/QuickTime/RM/Fundamentals/QTOverview/QTOverview_Document/QuickTimeOverview.html>
"Media Time Scale
A QuickTime movie always has a time scale, expressed in units per second. You 
can specify a time scale when you create a movie, but the time scale cannot be 
changed once a movie exists. When you perform operations on a QuickTime movie, 
you frequently need to specify a point in the movie timeline at which to begin 
the operation; this is specified using a time value, expressed in movie time 
scale units. You may also need to specify a duration; this is also expressed in 
movie time scale units. The default movie time scale is 600…"

>> Since I don’t have the know how to make changes to the FFmpeg code
>> (changing MOV_TIMESCALE to a higher value in libavformat/movenc.h),
> Sorry, this is not an acceptable answer:
> movenc.h is a textfile that can be changed with any text editor.
I understand that, but I do not yet know how to bring the files locally, edit 
the values and then compile everything into a binary. I have absolutely tried 
this a number of ways, following the Compilation Guide 
https://trac.ffmpeg.org/wiki/CompilationGuide 
<https://trac.ffmpeg.org/wiki/CompilationGuide>, but I did not manage to do it 
successfully. I would love to get there though and so any help is hugely 
appreciated. I’m very determined and will do my utmost to be able to contribute 
a complete answer to this issue.

>> or even better, build a binary for me to test with.
> Could you elaborate why you cannot compile yourself?
> FFmpeg is supposed to build out-of-the-box on every common
> operating system and an a few very uncommon OS's.
> This is the right mailing list for compilation help.

Thanks. I have managed to compile a usable ffmpeg using brew (I work 
exclusively on macOS), but I have not figured out how I would be able to edit 
the libavformat/movenc.h file before compiling using this method. It seems I 
would need to go down the route, so any help to get that far would be so 
welcome.

Thanks
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-08 Thread Mark Burton
On 8 Mar 2018, at 11:03, Carl Eugen Hoyos  wrote:
> It is zero as long as nobody confirms that this would fix the issue you see.

Understood. A better option would no doubt be the ability to specify this value 
in the same way we can specify the video_track_timescale value.

For the record, I have used a 3rd party tool to alter the timescale to 24000 
and it completely fixed the issue with the ffmpeg output files.

Since I don’t have the know how to make changes to the FFmpeg code (changing 
MOV_TIMESCALE to a higher value in libavformat/movenc.h), I’ll need to find 
someone who is willing to either test, or even better, build a binary for me to 
test with.

Is there anyone out there willing to do this?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-07 Thread Mark Burton
On 7 Mar 2018, at 00:45, Mark Burton  wrote:
> Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?

What are the chances that this value could be changed to a much higher and more 
useful value?
Does anyone know why 1000 was chosen?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-06 Thread Mark Burton
On 7 Mar 2018, at 00:24, Carl Eugen Hoyos  wrote:
> Could you elaborate a little?
> What kind of issues?
> 
> Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?

The files are being used in software (Conformalizer) that seeks to specific 
points in the Quicktime file, but with the FFmpeg generated files, its landing 
on the wrong frame, usually 1 frame out. The original Quicktime files (with a 
timescale of 24000), seek just fine when used in the same software.

With regards to changing the MOV_TIMESCALE in libavformat/movenc.h, I’m afraid 
I’m not an experienced developer unfortunately and don’t have the know how to 
compile ffmpeg myself having made changes. I do think your right though, this 
could well be the answer to the problem. Some Quicktime software sets this 
value to 45000 as its then divisible by 24, 25 and 30fps. Is there is specific 
reason this value is currently being set to 1000? This is not divisible by 24.

Thanks
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Quicktime - Specify a Movie Header timescale of 24000

2018-03-06 Thread Mark Burton
When I run my 24fps Quicktime mov files through an FFmpeg transcode they are 
coming out with a Movie Header timescale of 1000, when the source file has a 
timescale of 24000. This low timescale value is causing issues in some 
professional software tools when seeking the file.

In my case the source file is a Quicktime with 1 x video track (DNx115) and 1 x 
data track (Timecode). I'm transcoding it to DNx36.

I can force the video timescale to 24000 by adding "-video_track_timescale 
24000", but this does not affect anything other than the video track.

The command is as follows:

ffmpeg -i input.mov -c:v dnxhd -b:v 36M -pix_fmt yuv422p -video_track_timescale 
24000 output.mov

Uncut console output:

ffmpeg version N-90214-gdd3f1e3a11-tessus Copyright (c) 2000-2018 the FFmpeg 
developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  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-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-libzimg --enable-libzmq --enable-libzvbi --enable-version3 
--pkg-config-flags=--static --disable-ffplay
  libavutil  56.  8.100 / 56.  8.100
  libavcodec 58. 13.102 / 58. 13.102
  libavformat58. 10.100 / 58. 10.100
  libavdevice58.  2.100 / 58.  2.100
  libavfilter 7. 12.100 /  7. 12.100
  libswscale  5.  0.102 /  5.  0.102
  libswresample   3.  0.101 /  3.  0.101
  libpostproc55.  0.100 / 55.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
creation_time   : 2018-03-06T10:45:16.00Z
timecode: 01:14:25:22
  Duration: 00:00:30.00, start: 0.00, bitrate: 116392 kb/s
Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn / 0x6E645641), yuv422p(tv, 
bt709), 1920x1080, 116391 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24k tbn, 24k 
tbc (default)
Metadata:
  creation_time   : 2018-03-06T10:45:16.00Z
  handler_name: Apple Alias Data Handler
  encoder : Avid DNxHD Codec
Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
Metadata:
  creation_time   : 2018-03-06T10:45:20.00Z
  handler_name: Apple Alias Data Handler
  timecode: 01:14:25:22
Stream mapping:
  Stream #0:0 -> #0:0 (dnxhd (native) -> dnxhd (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'output.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
timecode: 01:14:25:22
encoder : Lavf58.10.100
Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn / 0x6E645641), yuv422p, 
1920x1080 [SAR 1:1 DAR 16:9], q=2-1024, 36000 kb/s, 0.04 fps, 24k tbn, 24 tbc 
(default)
Metadata:
  creation_time   : 2018-03-06T10:45:16.00Z
  handler_name: Apple Alias Data Handler
  encoder : Lavc58.13.102 dnxhd
frame=  720 fps=151 q=4.0 Lsize=  132482kB time=00:00:29.95 
bitrate=36226.7kbits/s speed=6.28x

I have checked the timescale value in Atom Inspector and can clearly see that 
the mvhd (Movie Header) is changed to 1000 in the output.mov when the input.mov 
was set to 24000.

1000 is too low for accurate seeking.

Using Atom Inspector to manually change this header timescale to 24000 and 
alter the duration fields to what they should be based on this timescale, the 
file works as expected.

Is there anyway to set the Movie Header timescale value as an option in FFmpeg?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-07-18 Thread Mark Burton
The latest nightly of Handbrake includes an option to add the sample group atom 
as well as the edit list. This is much more successful than the current ffmpeg 
mux when playing in QT X. Its still ignored in older QT decoders, but certainly 
this would be an improvement if ffmpeg could follow the Handbrake atom 
structure for the sound track.

Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-07-02 Thread Mark Burton
On 1 Jul 2017, at 20:24, Sasi Inguva  wrote:
>> On Sat, Jul 1, 2017 at 6:56 AM, Mark Burton [via FFmpeg-users] 
>> How about this for a partial solution - ffmpeg supports the audiotoolbox
>> aac encoder on macOS. For the sake of being able to create .mov which are
>> compatible with the Quicktime format, there is a single change which I
>> think could work well, albeit the ‘fix' would be limited to macOS system
>> encoders.
>> 
>> Currently a .mov created by ffmpeg when using the aac_at audiotoolbox
>> encoder creates a sound track edit list with a media time of 2112. This
>> will not work with Quicktime decoders, the file with decode out of sync. If
>> this value was 0 however, then the file will decode properly in sync.
>> 
>> For now, would it be possible to change this value to 0 when using the
>> aac_at encoder in ffmpeg?
>> 
>> Doing the same for the ffmpeg native aac encoder does help quite a bit,
>> about 1/2 frame out of sync as opposed to a full frame.

> 
> There is already a flag called -use_editlist in ffmpeg MOV muxer
> http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/movenc.c;h=ca389e3a97f92e05b1abfda29aa7bde25e1089a0;hb=HEAD#l88
>  
> <http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/movenc.c;h=ca389e3a97f92e05b1abfda29aa7bde25e1089a0;hb=HEAD#l88>
> I think you can use that along with the audiotoolbox encoder to achieve what 
> you want.

I have tried this before, but by removing the editlist using this flag, the 
resulting file had major frame rate issues - for example a 24fps file, would 
come out at 23.99fps and would not play correctly - using my test file with 
burnt in timecode and a timecode track, it was easy to see that they were not 
keeping sync. This also results in a file which is longer than the true 
duration and Quicktime decoders can display a black frame at the end as a 
result.

Perhaps this is because the edit list is removed from all tracks, not just the 
audio, I don’t know, but it doesn’t currently achieve what I described above 
sadly.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-07-01 Thread Mark Burton
How about this for a partial solution - ffmpeg supports the audiotoolbox aac 
encoder on macOS. For the sake of being able to create .mov which are 
compatible with the Quicktime format, there is a single change which I think 
could work well, albeit the ‘fix' would be limited to macOS system encoders.

Currently a .mov created by ffmpeg when using the aac_at audiotoolbox encoder 
creates a sound track edit list with a media time of 2112. This will not work 
with Quicktime decoders, the file with decode out of sync. If this value was 0 
however, then the file will decode properly in sync.

For now, would it be possible to change this value to 0 when using the aac_at 
encoder in ffmpeg?

Doing the same for the ffmpeg native aac encoder does help quite a bit, about 
1/2 frame out of sync as opposed to a full frame.





> On 29 Jun 2017, at 18:52, Sasi Inguva  wrote:
> I am not knowledgeable enough about audio codec implementations, but I
> don't think we can control an audio codec implementation to follow a
> certain delay.  For AAC codec for example, I believe libfhg-aac sets 1600
> samples of dealy, while libfdk-aac would set 1024 etc. Some one with more
> knowledge can tag in here.
> 
> On Thu, Jun 29, 2017 at 10:46 AM, Mark Burton  wrote:
> 
>> 
>>> On 28 Jun 2017, at 01:12, Sasi Inguva 
>> wrote:
>>> I have been helping Mark test Marton's patch. I looked at the test file
>> Mark
>>> was using to test the sync. There are multiple reasons for audio being
>>> off-sync.
>>> 
>>> i) That file doesn't contain a non-zero edit list or 'sgpd' atom, as
>>> https://developer.apple.com/library/content/documentation/
>> QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>>> suggests to put. For this kind of file the spec says that, use the
>>> historical solution of assuming the delay as 2112 samples. And this is
>> what
>>> the QuickTime player and iMovie on my MAC seem to be doing. However in
>>> Ffmpeg we don't assume the delay as 2112 samples. If there is no edit
>> list,
>>> we assume it as zero.
>>> Hence, when we transcode the video using ffmpeg, we are adding 2112
>> samples
>>> of silence in the transcoded file ( as actual audio data).
>>> ii) On top of that ffmpeg AAC encoder itself introduces 1024 samples of
>>> silence, and ffmpeg then uses edit list to denote that as the encoder
>> delay.
>>> However the spec says that along with the edit list, we should also set
>> the
>>> "sgpd" atom, ( which is what Marton's patch does).
>>> 
>>> So to fix this, I hacked ffmpeg MOV demuxer to assume 2112 delay for AAC,
>>> and combined it with Marton's patch.  I hoped that the file transcoded
>> from
>>> ffmpeg built from these two patches, will correctly match the original
>> test
>>> file when decoded with Apple tools (iMovie) .
>>> 
>>> However it was not to be. It seems like even Apple tools don't respect
>> the
>>> new way of setting the encoder delay. When I decode the file using
>> iMovie, I
>>> observe that 2112 samples from the beginning are gone, indicating that
>> Apple
>>> is still assuming 2112 samples of delay for AAC.
>>> 
>>> I am attaching the original test file, and the file I generated.
>>> SyncTest_2sec_24p_Compressor_enc.mp4
>>> <http://www.ffmpeg-archive.org/file/n4680414/SyncTest_
>> 2sec_24p_Compressor_enc.mp4>
>>> SyncTestFfmpegAdEdit2112.mp4
>>> <http://www.ffmpeg-archive.org/file/n4680414/
>> SyncTestFfmpegAdEdit2112.mp4>
>> 
>> Thanks Sasi. So the short of this is that its unclear whether it is in
>> fact possible to create a mov file which Apple tools will decode using the
>> ‘new’ method.
>> 
>> If Apple tools will always reliably use the 2112 decode method, would it
>> not make more sense to include a new option in ffmpeg to encode in this way
>> (same as Quicktime encoders) and therefore ensure accurate decode of the
>> file in the actual formats decoder? If the current methods are either not
>> fully meeting the spec or are simply being ignored by Quicktime, it would
>> seem that in order to maintain compatibility with the format itself, having
>> a way to encode with 2112 delay would be the most reliable way to go.
>> 
>> Thanks
>> Mark
>> ___
>> ffmpeg-user mailing list
>> ffmpeg-user@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
>> 
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-29 Thread Mark Burton

> On 28 Jun 2017, at 01:12, Sasi Inguva  wrote:
> I have been helping Mark test Marton's patch. I looked at the test file Mark
> was using to test the sync. There are multiple reasons for audio being
> off-sync.
> 
> i) That file doesn't contain a non-zero edit list or 'sgpd' atom, as 
> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>  
> suggests to put. For this kind of file the spec says that, use the
> historical solution of assuming the delay as 2112 samples. And this is what
> the QuickTime player and iMovie on my MAC seem to be doing. However in
> Ffmpeg we don't assume the delay as 2112 samples. If there is no edit list,
> we assume it as zero.
> Hence, when we transcode the video using ffmpeg, we are adding 2112 samples
> of silence in the transcoded file ( as actual audio data). 
> ii) On top of that ffmpeg AAC encoder itself introduces 1024 samples of
> silence, and ffmpeg then uses edit list to denote that as the encoder delay. 
> However the spec says that along with the edit list, we should also set the
> "sgpd" atom, ( which is what Marton's patch does).
> 
> So to fix this, I hacked ffmpeg MOV demuxer to assume 2112 delay for AAC,
> and combined it with Marton's patch.  I hoped that the file transcoded from
> ffmpeg built from these two patches, will correctly match the original test
> file when decoded with Apple tools (iMovie) . 
> 
> However it was not to be. It seems like even Apple tools don't respect the
> new way of setting the encoder delay. When I decode the file using iMovie, I
> observe that 2112 samples from the beginning are gone, indicating that Apple
> is still assuming 2112 samples of delay for AAC.
> 
> I am attaching the original test file, and the file I generated.
> SyncTest_2sec_24p_Compressor_enc.mp4
> 
>   
> SyncTestFfmpegAdEdit2112.mp4
>   

Thanks Sasi. So the short of this is that its unclear whether it is in fact 
possible to create a mov file which Apple tools will decode using the ‘new’ 
method.

If Apple tools will always reliably use the 2112 decode method, would it not 
make more sense to include a new option in ffmpeg to encode in this way (same 
as Quicktime encoders) and therefore ensure accurate decode of the file in the 
actual formats decoder? If the current methods are either not fully meeting the 
spec or are simply being ignored by Quicktime, it would seem that in order to 
maintain compatibility with the format itself, having a way to encode with 2112 
delay would be the most reliable way to go.

Thanks
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-25 Thread Mark Burton
On 19 Jun 2017, at 22:38, Marton Balint  wrote:
> Can you measure how many samples are the delay before and after my patch? I'd 
> rather do some additional testing now, instead committing something that is 
> only half-correct.

I’ve reached out to the developer who was helping me. I believe he also wrote a 
second patch of his own. I don’t yet have a binary build I can test with 
myself, so I would like to test more files to check the results and give you a 
solid answer.

Essentially Quicktime is still assuming 2112 sample delay even with the 
patches, its just that it is ever so slightly better than normal, but it is 
still out of sync. In order to get Quicktime to adhere to a provided delay of 
1024, there would be other changes needed in ffmpeg.

It does appear that most (if not all) Quicktime based encoders are setup to 
output a file for the decoder to assume 2112 sample delay. We have not yet 
found one which uses the ‘modern’ method.

Thanks for your help on this Marton.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-19 Thread Mark Burton
On 16 Jun 2017, at 10:17, ffm...@me.com wrote:
> I agree with Mark here. 
> Followed the issue now for a while and opened a similar (not went into this 
> deep technical level) issue some time ago.
> 
> I guess it should be marked as a bug and - if possible - should be fixed. 
> Thanks, Andreas

Thanks Andreas. I feel with Marton’s patch (if it can be applied) and a few 
extra tweaks we could be getting very close to finally solving this bug.

What is your setup and how are you experiencing this?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-19 Thread Mark Burton
> On 15 Apr 2017, at 13:25, Christian Ebert  wrote:
> * 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.

Hi Marton,

I wasn’t able to test your patch myself, but another very helpful developer did 
apply it and ran a test for me. The result was much better sync with your 
patch, although still not a complete match for the input file’s sync when 
decoded in Quicktime.

Adding the 'roll' sgpd atom and sample-to-group atoms does appear to be a 
requirement for AAC priming to be better understood by Quicktime. Although 
there is still something else happening to scupper perfect sync, it would be 
useful to apply this patch if possible.

Many thanks
Mark


___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-09 Thread Mark Burton
I appreciate I don't fully grasp the complexities or know the full story here, 
but do you not think its fair to say this should be considered a major ffmpeg 
bug or issue? It seems clear to me, and others, that the current .mov muxer 
produces a file which is incompatible with Quicktime itself. AAC priming in 
this container does not follow as advised and that appears to be the main 
reason its breaks when decoded.

Going back to changing the file manually (after using aresample and asetpts 
filters), I can get a file which decodes perfectly in Quicktime and VLC by just 
changing the single value for duration in the sound edit list to match the 
video track duration:

trak - Track
edts - Edits
elst - Edit List
'segment duration’

This file also imports perfectly into Avid Media Composer, a first. The movie 
header still shows an overlong duration, but that does not appear to affect 
playback. Its really just a hack though.

Surely it would be preferable to have a permanent solution to this which did 
not require the use of multiple audio filters and manual hacks to produce a 
working file with AAC for Quicktime.

Many thanks for your patience with this, I know I’ve been banging on this door 
for a few months, so I apologise for clogging up your inboxes. Its not my 
intention to be accusatory, I’m genuinely trying to help improve the tool as 
best I can. A re-engagement from the experts here would be hugely appreciated 
and I will do all I can to help.

Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-06-04 Thread Mark Burton
On 26 May 2017, at 12:53, Christian Ebert mailto:blacktr...@gmx.net>> wrote:
> Yeah, filtering does not add an edit list (apparently the
> 'modern' solution):
> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-25592
>  
> 
> and therefore QuickTime fails over to a hardcoded 'historical'
> default. That explains it.

Further to what you’ve pointed out here, I looked at the encoded file with Atom 
Inspector after having used the below audio filter command:

-af aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+2112

Atom Inspector reveals there are just 3 values which need changing to achieve a 
file which decodes in Quicktime with perfect sync and perfect duration. Using 
the AudioToolbox AAC encoder is again more successful, but it can be done with 
the native AAC encoder also, with one extra step (removing the first entry in 
the sound media Edit List).

The locations of the values which need to be altered are:

IN THE MOVIE HEADER
moov - Movie  //  mvhd - Movie Header  //  ‘duration'

IN THE SOUND MEDIA TRACK
trak - Track  //  tkhd - Track Header  //  ‘duration’
trak - Track  //  edts - Edits  //  elst - Edit List  //  'segment duration’


When these values are changed to match the video track duration, the file is 
‘fixed’ so to speak - in Quicktime based decoders it plays in perfect sync, 
ends exactly where its supposed to end and has a duration which matches the 
source. Its the first file with AAC audio I’ve had from ffmpeg which works in a 
Quicktime decoder. Obviously this is not a viable solution unless there is a 
way to do this programatically, its cumbersome and, I’m sure, a bit of a hack.

However it does appear to prove your point that the current method of ffmpeg 
mov file muxing is producing a file which fails to use "a complete 
implementation using the sample group structures” for AAC tracks which 
therefore results in the decoder falling back to the historical technique to 
handle AAC timing and synchronisation and hence the sync issue.

If anyone is still monitoring this thread, please can you take another look at 
this? It appears there may be two ways to address this.

1 - Alter the mov muxer to create a file which correctly conforms to "a 
complete implementation using the sample group structures” as set out here:
https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html#//apple_ref/doc/uid/TP4939-CH2-SW11
 


2 - Alternatively, is there a way to programatically mux the mov file to record 
a duration which matches the source duration exactly?

Thanks
Mark


Command used in this example:
———
$ ffmpeg -v info -i input.mov -c:v libx264 -pix_fmt yuv420p -c:a aac_at -b:a 
128k -af aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+2112 output.mov
ffmpeg version N-86344-gb5a0971-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-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. 63.100 / 55. 63.100
  libavcodec 57. 96.101 / 57. 96.101
  libavformat57. 72.101 / 57. 72.101
  libavdevice57.  7.100 / 57.  7.100
  libavfilter 6. 91.100 /  6. 91.100
  libswscale  4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
creation_time   : 2016-10-15T16:52:53.00Z
timecode: 01:00:00:00
  Duration: 00:01:00.00, start: 0.00, bitrate: 118696 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   : 2016-10-15T16:52:53.00Z
  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 

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

2017-05-26 Thread Mark Burton
On 26 May 2017, at 12:53, Christian Ebert  wrote:
> Yeah, filtering does not add an edit list (apparently the
> 'modern' solution):
> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-25592
> and therefore QuickTime fails over to a hardcoded 'historical'
> default. That explains it.
> 
> There are some options referring to edit lists, but I haven't
> tried whether, nevermind how, they could be used for this
> purpose.


https://ffmpeg.org/pipermail/ffmpeg-cvslog/2012-October/055289.html 

http://ffmpeg.org/pipermail/ffmpeg-cvslog/2014-November/082944.html 


I’ve looked into these two notes before, when I experimented a little it in the 
past, I found it caused the tracks to not playback at a consistent rate and so 
sync was shifting by a frame throughout. Its a hard one to narrow down, as it 
seems to affect mostly the sync when I move to a new clip location and restart 
playback.

Since my test clip has visual running timecode and timecode in a data track, I 
can see that the sync between these two is not being maintained when pausing or 
jumping to a new play point. I’ve been using the video_track_timescale option 
for a while anyway, but I think this option is even more important when adding 
the command option "-use_editlist 0”.

Testing with the native aac encoder (with the option "-use_editlist 0” and 
without any of the -af options) produces a file which plays approx. 1/2 frame 
out sync in Quicktime decoders and the file ends when it should, but with the 
jump around sync issue mentioned above.

Doing the same test but with the AutoToolbox aac encoder (aac_at) produces a 
file which is plays in sync, but still has the jump around data sync issue and 
produces a 1 frame overlong duration.

Although playback audio / video sync is either very close or right on when 
started from head of the clip, neither show reliable sync to the timecode 
track, this doesn't seem viable as is. Its odd though as it seems to have been 
developed for this reason, so perhaps its the closest option to a solution and 
needs some final changes to make it fully reliable.

Apologies for my technical descriptions, I appreciate some of it is a little 
basic on my behalf.

Thanks
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-24 Thread Mark Burton
On 23 May 2017, at 11:20, Christian Ebert  wrote:
>> So I looked back at your above -af and realised that the 1024 should 
>> actually be 2112 which is Apple’s chosen fixed encoding delay.
>> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
>>  
>> 
>> 
>> -filter:a aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+2112
> Strange, probably all depends on the demuxing application.
My take on it is that Quicktime will always assume 2112 padding, so I believe a 
.mov should be setup with this priming duration.

> ffprobe -show_entries stream=codec_type,start_time,start_pts,duration result
> 
> for me gives 0 for all start values.
Which is then being pulled back -2112 samples on playback, which is why it goes 
out of sync I believe. Unless you have 2112 samples of empty audio before the 
source audio data starts, there will be a sync issue.

> Did you look at the atrim filter? It offers end, end_sample, and
> end_pts parameters. You may have to to some calculations.
> 
> Re-reading the article you referenced, it may even a better idea
> to use atrim instead of asetpts for the start as well.
> 
> Maybe:
> 
> -filter:a aresample=async=1:first_pts=0,atrim=start_pts=2112:end={-t value}
Thanks for the idea. I’m  not having much luck with this for the tail and 
unless I keep asetpts as before, the head is pulled out of sync.

I think the problem is that these trailing samples should just be trimmed on 
playback automatically. Thats works when we don’t add 2112 samples of padding, 
but with the required padding there are either too many trailing samples or it 
breaks the trailing detection process. I’ve tried to learn how this is 
signalled to the decoder, but I’m not really understanding it and its above my 
intellect grade.

It would be very useful to hear from the devs why (again with the greatest 
respect, I completely accept I’m not going to have a full picture here) ffmpeg 
does not follow the Quicktime file format spec for their .mov muxer in the way 
that Apple has advised, and ideally if there was a way to offer an extra option 
for this muxer to create aac files with Quicktime decoder compatibility.

Thanks
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-22 Thread Mark Burton
On 15 Apr 2017, at 09:22, Christian Ebert  wrote:
> Somewhat counterintuitive, but you never know:
> 
> -filter:a aresample=async=1:first_pts=0,asetpts=PTS-STARTPTS+1024
> 
> combined with the -t incantation.

Hi Christian,

It seems this issue is not going to garner much attention which is a little 
disheartening. I can show how to reproduce it and would love to be able to help.

So I looked back at your above -af and realised that the 1024 should actually 
be 2112 which is Apple’s chosen fixed encoding delay.
https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
 


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

...brings the native aac encoder almost perfectly into sync when played by a 
Quicktime based decoder. There is a tiny discrepancy, but its 99.9% better than 
without the -af line.

Further to this, using the AudioToolbox AAC encoder (aac_at) available in 
ffmpeg on macOS only, with the above -af line, this discrepancy is gone and the 
encoded file is a perfect sync match for the original source file.

The outstanding issue is the remaining samples for the file which are not being 
trimmed, so the clip runs past the end of the picture and we get a black frame. 
Perhaps the remaining samples are not being flagged in a way that the decoder 
would expect, I’m really not sure.

I can use the '-t' command with the value for ('total duration of source' - 
‘0.041') to trim the end, but its has issues too.
In my case of 24fps source, 0.041 is the duration of 1 frame. Doing this 
shortens the overlong audio stream, but it removes the last frame of audio and 
in some cases does strange things with the last two frames of audio. So its not 
really usable in a production environment. Without subtracting 0.041, the audio 
is still overlong.

So in short, this is super close to a solution for Quicktime environments, but 
still with one big issue. Hmm.

Best
Mark


___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-16 Thread Mark Burton
On 9 May 2017, 15:42 +0100, Mark Burton , wrote:

> > > Do you not see the same behaviour?
> > No, unfortunately not.
> Can I ask - are you playing back your encoded file on macOS in either 
> Quicktime Player 7.x or Quicktime Player 10.x?
> I don’t believe you will see this unless you are using a Quicktime based 
> decoder.

> > 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.
> Sorry if this is not correct way to share a file, I’ll remove and re-share if 
> asked of course:
> https://www.dropbox.com/s/qz5c64rk6l8415o/SyncTest24p.mov?dl=0
> This is a simple 2 second sync test Quicktime file (DNx115, 24fps with PCM 
> audio) with a sync pop on the head and tail frame.
> If you have time, please could you try to encode this as follows and playback 
> in a Quicktime based player.
> ffmpeg -i SyncTest24p.mov -c:v libx264 -pix_fmt yuv420p -movflags faststart 
> -c:a aac -b:a 128k ffmpeg.mov
>
> - Do you hear a sync pop on the first frame of the encode when played back in 
> Quicktime based player?
> - Does the tail sync pop sound on frame :23 or frame :22?

> > If the effect can be multiplied by encoding several times with
> > FFmpeg, things would of course be different: Is that the case?
> No, it does not get any worse by encoding it many times in a row.

Carl is there a chance you’ve had time to further review this with the sample 
file provided?

I know there are literally thousands of areas of focus you must have to be 
looking into, but I really wouldn’t keep banging on this door if I didn’t 
genuinely feel this was a worthwhile cause. I’m aware also that the list COD 
asks us not to assume our issue is the most important, so I say that with the 
greatest respect.

I honestly don’t think it would be a stretch to say that, at preset, the ffmpeg 
MOV muxer appears to be incompatible with regards to way it handles aac priming 
with the Quicktime format. If there is anything else I can provide or test, 
please do ask, I’ll do whatever I can to help nail this down.

Thank you and regards,
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-09 Thread Mark Burton
On 9 May 2017, at 15:21, Carl Eugen Hoyos  wrote:
>> Do you not see the same behaviour?
> No, unfortunately not.

Can I ask - are you playing back your encoded file on macOS in either Quicktime 
Player 7.x or Quicktime Player 10.x?
I don’t believe you will see this unless you are using a Quicktime based 
decoder.

> 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.

Sorry if this is not correct way to share a file, I’ll remove and re-share if 
asked of course:
https://www.dropbox.com/s/qz5c64rk6l8415o/SyncTest24p.mov?dl=0 


This is a simple 2 second sync test Quicktime file (DNx115, 24fps with PCM 
audio) with a sync pop on the head and tail frame.

If you have time, please could you try to encode this as follows and playback 
in a Quicktime based player.

ffmpeg -i SyncTest24p.mov -c:v libx264 -pix_fmt yuv420p -movflags faststart 
-c:a aac -b:a 128k ffmpeg.mov

- Do you hear a sync pop on the first frame of the encode when played back in 
Quicktime based player?
- Does the tail sync pop sound on frame :23 or frame :22?

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

No, it does not get any worse by encoding it many times in a row.

Many thanks for your continued help, its hugely appreciated.
Mark
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-09 Thread Mark Burton

> On 9 May 2017, at 15:16, Carl Eugen Hoyos  wrote:
>> 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.


Understood and makes perfect sense, thanks.
It was wishful thinking on my part and not properly taking in what Christian 
had reported back.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-05-09 Thread Mark Burton
On 15 Apr 2017, 11:26 +0100, Marton Balint , 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] sendcmd and drawtext - using more than one in the same filtergraph?

2017-04-28 Thread Mark Burton

> On 28 Apr 2017, at 16:28, Paul B Mahol  wrote:
> 
> You need to use Parsed_drawtext_X instead of drawtext, replace X with
> number of filter in filtergraph.
> 
> So if its 3rd filter in filtergraph its number will be 2. Because
> lavfi counts from 0.

Ah perfect. Many thanks Paul, working perfectly now!!
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] sendcmd and drawtext - using more than one in the same filtergraph?

2017-04-28 Thread Mark Burton
Using a single sendcmd to read text from an external file and command a single 
drawtext, is working fine:

ffmpeg -i input.mov -c:v dnxhd -b:v 115M -pix_fmt yuv422p -vf 
"sendcmd=filename=commandFile1,drawtext=fontfile=/System/Library/Fonts/Helvetica.dfont:fontsize=20:fontcolor=white:x=10:y=30:text="
 -an output.mov

However I need to have two or more drawtext filters being commanded from 
separate sendcmd files in the same filtergraph.

I believe I need to assign filter instance names to each drawtext command and 
then reference that name for [TARGET] in the sendcmd text file, but after 
reading through the docs and trying a few ideas, I’m no closer.

The basic command (currently not working):

ffmpeg -i input.mov -c:v dnxhd -b:v 115M -pix_fmt yuv422p -vf 
"sendcmd=filename=commandFile1,drawtext=fontfile=/System/Library/Fonts/Helvetica.dfont:fontsize=20:fontcolor=white:x=10:y=30:text=,sendcmd=filename=commandFile2,drawtext=fontfile=/System/Library/Fonts/Helvetica.dfont:fontsize=20:fontcolor=red:x=10:y=60:text="
 -an output.mov

Result:
drawtext 1 - after 1 frame at each new text entry, text from commandFile2 is 
overriding text from commandFile1.
drawtext 2 - nothing is being drawn by this filter.

...contents of the sendcmd files:

commandFile1
00:00:00.000-00:00:01.000 [enter] drawtext reinit 'text=Note A';
00:00:01.000-00:00:01.958 [enter] drawtext reinit 'text=Note B';

commandFile2
00:00:00.000-00:00:01.000 [enter] drawtext reinit 'text=Tag 1';
00:00:01.000-00:00:01.958 [enter] drawtext reinit 'text=Tag 2';

… and the output:

ffmpeg version N-85641-gdd49eff-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. 61.100 / 55. 61.100
  libavcodec     57. 93.100 / 57. 93.100
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 86.100 /  6. 86.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 
'debug'.
Reading option '-i' ... matched as input url with argument 'input.mov'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 
'dnxhd'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use 
-b:v)) with argument '115M'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) 
with argument 'yuv422p'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with 
argument 
'sendcmd=filename=commandFile1,drawtext=fontfile=/System/Library/Fonts/Helvetica.dfont:fontsize=20:fontcolor=white:x=10:y=30:text=,
sendcmd=filename=commandFile2,drawtext=fontfile=/System/Library/Fonts/Helvetica.dfont:fontsize=20:fontcolor=red:x=10:y=60:text='.
Reading option '-an' ... matched as option 'an' (disable audio) with argument 
'1'.
Reading option 'output.mov' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url input.mov.
Successfully parsed a group of options.
Opening an input file: input.mov.
[file @ 0x7f84705002a0] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Format mov,mp4,m4a,3gp,3g2,mj2 
probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] ISO: File Type Major Brand: qt
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Unknown dref type 0x73696c61 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Processing st: 0, edit list 0 - 
media time: 0, duration: 48000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Unknown dref type 0x73696c61 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Processing st: 1, edit list 0 - 
media time: 0, duration: 96000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Unknown dref type 0x73696c61 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Processing st: 2, edit list 0 - 
media time: 0, duration: 48000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f847100] Before avformat_find_stream_info() 
pos: 29676271 bytes read:38355 seeks:1 nb_streams:3
[dnxhd @ 0x7f8471017600] Profile cid 1237.
[dnxhd @ 0x7f8471017600] 1920x1080, 4:2:2 8

[FFmpeg-user] mjpegenc change to optimal huffman coding as default and Quicktime Player 7

2017-04-19 Thread Mark Burton
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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-18 Thread Mark Burton
On 15 Apr 2017, 09:18 +0100, Mark Burton , wrote:

> On 14 Apr 2017, 23:45 +0100, Carl Eugen Hoyos , wrote:
> > 2017-04-14 23:44 GMT+02:00 Mark Burton :
> > > 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-16 Thread Mark Burton
On 15 Apr 2017, 09:22 +0100, Christian Ebert , wrote:

> * Mark Burton on Friday, April 14, 2017 at 22:44:52 +0100
> > > On 14 Apr 2017, at 22:22, Christian Ebert  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.00’ 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-15 Thread Mark Burton
On 14 Apr 2017, 23:45 +0100, Carl Eugen Hoyos , wrote:

> 2017-04-14 23:44 GMT+02:00 Mark Burton :
> > 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-15 Thread Mark Burton
On 15 Apr 2017, 06:55 +0100, Marton Balint , wrote:

> On Sat, 15 Apr 2017, Carl Eugen Hoyos wrote:
>
> > 2017-04-14 23:44 GMT+02:00 Mark Burton :
> > > 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-14 Thread Mark Burton

> On 14 Apr 2017, at 22:22, Christian Ebert  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.00’ 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
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

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

2017-04-14 Thread Mark Burton
On 14 Apr 2017, 17:47 +0100, Christian Ebert , 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]
ffprobe -select_streams a:0 -show_packets ffmpeg_v2.mp4
ffprobe version N-85343-gd0a3143-tessus Copyright (c) 2007-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
  libavformat57. 72.100 / 5

Re: [FFmpeg-user] Drawtext - complex expression to show feet+frames

2017-04-11 Thread Mark Burton
> On 11 Apr 2017, at 22:39, Mark Burton  wrote:
> 
> One issue I am having is that as the numbers count the vertical position of 
> the text changes ever so slightly, looks like a judder. I’m guessing this is 
> due to the character size variations so the position of the text is 
> recalculated by tiny fractions. Is there a way to allow for this in the x and 
> y position? I’ve tried with max_glyph_h, but I think it would need to know 
> the height of all characters to come as it doesn’t make any difference.

OK, I added "-ascent” to the y coordinate and that fixed the text juddering. 
Here is the final filter:
drawtext=fontsize=60:fontcolor=white:text='%{eif\:(n+0)/16\:d}+%{eif\:mod((n+0),16)\:d\:02d}':x=200:y=75-ascent

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Drawtext - complex expression to show feet+frames

2017-04-11 Thread Mark Burton
> On 11 Apr 2017, at 21:51, Mark Burton  wrote:
>> On 11 Apr 2017, at 21:13, Moritz Barsnick > <mailto:barsn...@gmx.net>> wrote:

>> I haven't figured out how to format "12+6" as "12+06" though. Good luck
>> trying! :) (I know how to fake it, but there may be a proper way with
>> formatting expressions.)
> 
> Yes, thats really the only thing left to do here - I was looking at how this 
> could work and did wonder if the same principles that apply to printf could 
> be applied, but having tried a few variations of ‘d', it seems not. Hmm.

Adding 02d as the third parameter seems to work for padding the frame number:
text='%{eif\:(n+0)/16\:d}+%{eif\:mod((n+0),16)\:d\:02d}’

One issue I am having is that as the numbers count the vertical position of the 
text changes ever so slightly, looks like a judder. I’m guessing this is due to 
the character size variations so the position of the text is recalculated by 
tiny fractions. Is there a way to allow for this in the x and y position? I’ve 
tried with max_glyph_h, but I think it would need to know the height of all 
characters to come as it doesn’t make any difference.

Thanks
Mark



___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Drawtext - complex expression to show feet+frames

2017-04-11 Thread Mark Burton

> On 11 Apr 2017, at 21:13, Moritz Barsnick  wrote:
> 
> On Tue, Apr 11, 2017 at 19:36:36 +0100, Mark Burton wrote:
>> New here, hope this is an appropriate question layout...
> 
> To start things off, we always prefer to see the (or an example of an)
> actual ffmpeg command line and its complete, uncut console output. I'll
> show you why below.

Sorry about that, looking around the list I didn’t see many doing that so I 
left it out, but absolutely will do in future. Here is the full output of the 
original command (which used ’t’).

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
  libavformat57. 72.100 / 57. 72.100
  libavdevice57.  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
  libpostproc54.  6.100 / 54.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
creation_time   : 2017-04-11T17:11:18.00Z
timecode: 01:00:00:00
  Duration: 00:01:00.00, start: 0.00, bitrate: 118696 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-11T17:11:18.00Z
  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-11T17:11:18.00Z
  handler_name: Apple Alias Data Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
  creation_time   : 2017-04-11T17:11:32.00Z
  handler_name: Apple Alias Data Handler
  timecode: 01:00:00:00
Stream mapping:
  Stream #0:0 -> #0:0 (dnxhd (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7fe116012800] deprecated pixel format used, make sure you did set 
range correctly
Output #0, mov, to 'out.mov':
  Metadata:
major_brand : qt  
minor_version   : 537199360
compatible_brands: qt  
timecode: 01:00:00:00
encoder : Lavf57.72.100
Stream #0:0(eng): Video: mjpeg (jpeg / 0x6765706A), yuvj422p(pc), 1920x1080 
[SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
  creation_time   : 2017-04-11T17:11:18.00Z
  handler_name: Apple Alias Data Handler
  encoder : Lavc57.92.100 mjpeg
Side data:
  cpb: bitrate max/min/avg: 0/0/20 buffer size: 0 vbv_delay: -1
frame= 1440 fps=148 q=4.0 Lsize=  210807kB time=00:00:59.95 
bitrate=28802.1kbits/s speed=6.18x
video:210798kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 0.004177%

>> I’ve been trying to learn more about expression evaluation and some
>> of the more complex aspects of controlling drawing text.
> 
> Good job so far!

It really is amazing how powerful this part of ffmpeg is, what you have given 
me below is quite astounding!

> 0+00
>> 0+01
>> 0+02
>> 0+03
>> 0+04
>> 0+05
>> 0+06
>> 0+07
>> 0+08
>> 0+09
>> 0+10
>> 0+11
>> 0+12
>> 0+13
>> 0+14
>> 0+15
>> 1+00
>> 1+01
>> … and so on.
> 
> Mathematically, the first part is the frame number divided by 16
> (rounded down to integer), the second part the frame number modulo 16 -
> is that right?

Yes, thats correct.

>> drawtext=fontsize=80:fontcolor=white:fontfile=$fontFile:text='%{eif\:0+(t/((1/24)*16))\:d}':x=(w/2)-text_w:y=(h-text_h)/2,
>> drawtext=fontsize=55:fontcolor=white:fontfile=$fontFile:text='+':x=(w/2)+5:y=(h-text_h)/2"
>>  \
> [...]
>> The first drawtext for the feet value is 99% accurate, but sometimes
>> it does not change to the next number of th

[FFmpeg-user] Drawtext - complex expression to show feet+frames

2017-04-11 Thread Mark Burton
New here, hope this is an appropriate question layout...

I’ve been trying to learn more about expression evaluation and some of the more 
complex aspects of controlling drawing text. I’m trying to achieve something 
which is a bit far fetched, but I’d love to get any help I can and this would 
be a huge feature for me if we can get it working. I’ve not come across this 
anywhere in my numerous searches, but perhaps someone has an existing solution 
to this?

The idea is to write a drawtext expression which can draw a film footage 
counter onto my video. The 35mm 4perf counter I want to use counts 16 frames 
per foot, like so:

0+00
0+01
0+02
0+03
0+04
0+05
0+06
0+07
0+08
0+09
0+10
0+11
0+12
0+13
0+14
0+15
1+00
1+01
… and so on.

Although a single filter expression would be much more useful in the long run, 
I figured it may be easier to break the display into 3 drawtext filters to get 
started. One for the feet counter, one for the ‘+’ character and one for the 
frames counter. So far I have the feet working almost right, but I’m not 
getting anywhere with the third.

My source material is always going to be 24fps Avid DNx115.

Here is the basic command:

inputFile="in.mov"
outputFile="out.mov"
fontFile="/System/Library/Fonts/Helvetica.dfont"
ffmpeg \
-i $inputFile \
-y \
-c:v mjpeg -qscale:v 4 -pix_fmt yuvj422p \
-vf "
drawtext=fontsize=80:fontcolor=white:fontfile=$fontFile:text='%{eif\:0+(t/((1/24)*16))\:d}':x=(w/2)-text_w:y=(h-text_h)/2,
drawtext=fontsize=55:fontcolor=white:fontfile=$fontFile:text='+':x=(w/2)+5:y=(h-text_h)/2"
 \
-an \
$outputFile

The first drawtext for the feet value is 99% accurate, but sometimes it does 
not change to the next number of the exact frame it should. Is there a way to 
use a per frame value instead of ’t’? I’m guessing its this calculation is not 
producing an accurate enough result to calculate the exact frame each time? It 
needs to iterate to the next number every 16 frames exactly.

Any advice on where to begin with the frames counter. It needs to start at 0, 
count on every frame to 15 and then restart at 0 on the next frame.

Lastly (perhaps I’m dreaming here!) could this theoretically all be combined 
into a single expression with ability to set the starting counter to 12+06 for 
example and have it count accurately from there? Had to ask!

Thanks for your help,
Regards
Mark



___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".