Re: [FFmpeg-user] xfade

2022-06-21 Thread Paul B Mahol
On Tue, Jun 21, 2022 at 9:42 AM Michael Koch 
wrote:

> Hi,
>
> I don't understand the examples in https://trac.ffmpeg.org/wiki/Xfade
>
> If the first input has length 5s and the offset is 4.5s and the duration
> is 1s, then from where comes the first input between t=5s and t=5.5s?
>

It is error.


>
> Michael
>
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


[FFmpeg-user] xfade

2022-06-21 Thread Michael Koch

Hi,

I don't understand the examples in https://trac.ffmpeg.org/wiki/Xfade

If the first input has length 5s and the offset is 4.5s and the duration 
is 1s, then from where comes the first input between t=5s and t=5.5s?


Michael

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

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


Re: [FFmpeg-user] xfade timing ambiguity

2021-09-30 Thread Rob Hallam
On Thu, 30 Sept 2021 at 10:57, Arif Driessen  wrote:

> Should we update the documentation to be clearer on this? (I am happy to do
> the work). It was the source of a frustating timing issue that took me all
> day to resolve. (back when I was emailing here about concating and fading
> sources).

You may be interested in the discussion thread here:

http://ffmpeg.org/pipermail/ffmpeg-user/2020-June/049022.html

(Next by thread is useful)

My last reply also wondered the same thing.

On Wed, 17 Jun 2020 at 16:19, Rob Hallam  wrote:

> Is it worth documenting this on the wiki, or, not to put too
> fine a point on it: am I the only one who has been initially
> confused by this?

It seems I was not!

Cheers,
Rob
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade timing ambiguity

2021-09-30 Thread Paul B Mahol
On Thu, Sep 30, 2021 at 11:58 AM Arif Driessen  wrote:

> Consider this script:
>
> ---
> #!/bin/bash
>
> ffmpeg \
> -v error \
> -filter_complex \
> "
> color=blue,
> trim=0:3
> [blue];
>
> color=red,
> trim=0:5
> [red];
>
> [blue][red]
> xfade
> " \
> -vcodec libx264 \
> -f matroska out.mkv && \
> ffprobe -v error \
> -select_streams v \
> -of csv=print_section=0 \
> -show_entries format=duration \
> out.mkv
>
> exit 0
> ---
>
> It will report the duration of the resultant mkv file is 5 seconds.
> Intuition would tell me to expect it to be 10 seconds long.
>
> Change the duration of [blue] to 3 seconds, and the resultant duration is
> still 5 seconds. Aha! So xfade blends the first input INTO the second. I
> don't believe the documentation is clear on this:
>
> > Apply cross fade from one input video stream to another input video
> stream. The cross fade is applied for specified duration
>
> Out of curiosity, what would happen if we keep the duration of [blue] to 3,
> but set the xfade=offset to 2 seconds, since xfade=duration by default is
> 1... Now the resultant mkv file is 7 seconds long!? Can you explain the
> rationale?
>
> Even weirder, now let's set the duration of [blue] to 3 seconds and make
> xfade=offset 3 seconds also... Now the resultant mkv file is 3 seconds
> long!! Is this just undefined behaviour because we have attempted illegal
> behaviour? (offset + duration >= input_duration)
>
> Should we update the documentation to be clearer on this? (I am happy to do
> the work). It was the source of a frustating timing issue that took me all
> day to resolve. (back when I was emailing here about concating and fading
> sources).
>
> Btw, acrossfade, works intuitively, and thus (for me) without fault. This
> concern/ambiguity is also expressed in Michael Koch's FFmpeg book.
>

It is the same workflow, xfade just use offset because it does not buffer
all your 8k video frames in 512MB RAM of your 10 years old laptop,
this was already mentioned to you several times, Offset specify when
overlapping is starting.

Can you think about overlapping in 1 dimensions?



>
> Thanks,
> Arif Driessen
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade timing ambiguity

2021-09-30 Thread Arif Driessen
Yikes In the example script please change:

color=blue,
trim=0:3
[blue];

to be 5 seconds long (trim=0:5), then follow along with the text below.
SORRY!

On Thu, Sep 30, 2021 at 11:57 AM Arif Driessen  wrote:

> Consider this script:
>
> ---
> #!/bin/bash
>
> ffmpeg \
> -v error \
> -filter_complex \
> "
> color=blue,
> trim=0:3
> [blue];
>
> color=red,
> trim=0:5
> [red];
>
> [blue][red]
> xfade
> " \
> -vcodec libx264 \
> -f matroska out.mkv && \
> ffprobe -v error \
> -select_streams v \
> -of csv=print_section=0 \
> -show_entries format=duration \
> out.mkv
>
> exit 0
> ---
>
> It will report the duration of the resultant mkv file is 5 seconds.
> Intuition would tell me to expect it to be 10 seconds long.
>
> Change the duration of [blue] to 3 seconds, and the resultant duration is
> still 5 seconds. Aha! So xfade blends the first input INTO the second. I
> don't believe the documentation is clear on this:
>
> > Apply cross fade from one input video stream to another input video
> stream. The cross fade is applied for specified duration
>
> Out of curiosity, what would happen if we keep the duration of [blue] to
> 3, but set the xfade=offset to 2 seconds, since xfade=duration by default
> is 1... Now the resultant mkv file is 7 seconds long!? Can you explain the
> rationale?
>
> Even weirder, now let's set the duration of [blue] to 3 seconds and make
> xfade=offset 3 seconds also... Now the resultant mkv file is 3 seconds
> long!! Is this just undefined behaviour because we have attempted illegal
> behaviour? (offset + duration >= input_duration)
>
> Should we update the documentation to be clearer on this? (I am happy to
> do the work). It was the source of a frustating timing issue that took me
> all day to resolve. (back when I was emailing here about concating and
> fading sources).
>
> Btw, acrossfade, works intuitively, and thus (for me) without fault. This
> concern/ambiguity is also expressed in Michael Koch's FFmpeg book.
>
> Thanks,
> Arif Driessen
>
>
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


[FFmpeg-user] xfade timing ambiguity

2021-09-30 Thread Arif Driessen
Consider this script:

---
#!/bin/bash

ffmpeg \
-v error \
-filter_complex \
"
color=blue,
trim=0:3
[blue];

color=red,
trim=0:5
[red];

[blue][red]
xfade
" \
-vcodec libx264 \
-f matroska out.mkv && \
ffprobe -v error \
-select_streams v \
-of csv=print_section=0 \
-show_entries format=duration \
out.mkv

exit 0
---

It will report the duration of the resultant mkv file is 5 seconds.
Intuition would tell me to expect it to be 10 seconds long.

Change the duration of [blue] to 3 seconds, and the resultant duration is
still 5 seconds. Aha! So xfade blends the first input INTO the second. I
don't believe the documentation is clear on this:

> Apply cross fade from one input video stream to another input video
stream. The cross fade is applied for specified duration

Out of curiosity, what would happen if we keep the duration of [blue] to 3,
but set the xfade=offset to 2 seconds, since xfade=duration by default is
1... Now the resultant mkv file is 7 seconds long!? Can you explain the
rationale?

Even weirder, now let's set the duration of [blue] to 3 seconds and make
xfade=offset 3 seconds also... Now the resultant mkv file is 3 seconds
long!! Is this just undefined behaviour because we have attempted illegal
behaviour? (offset + duration >= input_duration)

Should we update the documentation to be clearer on this? (I am happy to do
the work). It was the source of a frustating timing issue that took me all
day to resolve. (back when I was emailing here about concating and fading
sources).

Btw, acrossfade, works intuitively, and thus (for me) without fault. This
concern/ambiguity is also expressed in Michael Koch's FFmpeg book.

Thanks,
Arif Driessen
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-26 Thread Arif Driessen
Argh! That fixed it!! Thank you.

On Sun, Sep 26, 2021 at 2:06 PM Paul B Mahol  wrote:

> On Sun, Sep 26, 2021 at 1:02 PM Arif Driessen  wrote:
>
> > > Sorry, but loop filter does not work that way.
> >
> > size parameter of loop filter is by default 0, meaning it will loop
> > nothing.
> > For single images you must set this option to exactly 1.
> >
> > Hi Paul, unless I misunderstand, in my email I stated that i tried loop
> > with the option loop=1
> >
>
>
> try with loop=-1:1 next time
>
>
> > ___
> > ffmpeg-user mailing list
> > ffmpeg-user@ffmpeg.org
> > https://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
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-26 Thread Paul B Mahol
On Sun, Sep 26, 2021 at 1:02 PM Arif Driessen  wrote:

> > Sorry, but loop filter does not work that way.
>
> size parameter of loop filter is by default 0, meaning it will loop
> nothing.
> For single images you must set this option to exactly 1.
>
> Hi Paul, unless I misunderstand, in my email I stated that i tried loop
> with the option loop=1
>


try with loop=-1:1 next time


> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-26 Thread Arif Driessen
> Sorry, but loop filter does not work that way.

size parameter of loop filter is by default 0, meaning it will loop nothing.
For single images you must set this option to exactly 1.

Hi Paul, unless I misunderstand, in my email I stated that i tried loop
with the option loop=1
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-25 Thread Paul B Mahol
On Fri, Sep 24, 2021 at 10:55 PM Arif Driessen  wrote:

> > It is very hard to help when no info what exactly was tried is not
> provided.
> Well I tried every variation on what you said. that is:
>
> > One possible way is using loop video filter
> So I'm looking at this documentation:
> https://ffmpeg.org/ffmpeg-filters.html#loop,
> And so i stuck `loop=loop=$N` after `movie=filename=${THUMBNAIL}` with $N
> being -1, 0, and 1
>

Sorry, but loop filter does not work that way.

size parameter of loop filter is by default 0, meaning it will loop nothing.
For single images you must set this option to exactly 1.

This is all mentioned and examples are in official documentation.

Note that ffmpeg default fps will be 25 for loop input/output.

Recent ffmpeg version even error out if size option is not set.



> And I also played with the loop parameter in `movie` (
> https://ffmpeg.org/ffmpeg-filters.html#movie-1)
> setting it to both `0` and `1`
>
> I attached a prototypal bash script in the first email, perhaps you could
> maybe run it on your system and amend it with what you think the solution
> should be?
>
> Many thanks!
> Arif
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Arif Driessen
I have a work around:

# Generate a temp thumbnail video which we will insert back into
${THUMBNAIL}
# Because for some reason taking an image input is broken! :(
ffmpeg -loop 1 -i ${THUMBNAIL} -t ${THUMBNAIL_HOLD_SECONDS} -c:v libx264
-qp 0 -crf 0 -preset veryfast ${TMP_DIR}/temp_thumbnail.mkv
THUMBNAIL=${TMP_DIR}/temp_thumbnail.mkv

Then i just have to match the timebase of the generated video and it works.

I thought about using -c:v copy, which works, is about 10 times slower, but
also creates 10 times the disk space, and I bet writing and then reading
back from the disk is more costly than the compression.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Arif Driessen
I also just tried removing the trim filter and using the exact number of
loops as the value for loops (as determined by the duration in seconds *
fps). Didn't work, same infinite thumbnail video

On Fri, Sep 24, 2021 at 10:54 PM Arif Driessen  wrote:

> > It is very hard to help when no info what exactly was tried is not
> provided.
> Well I tried every variation on what you said. that is:
>
> > One possible way is using loop video filter
> So I'm looking at this documentation:
> https://ffmpeg.org/ffmpeg-filters.html#loop,
> And so i stuck `loop=loop=$N` after `movie=filename=${THUMBNAIL}` with $N
> being -1, 0, and 1
> And I also played with the loop parameter in `movie` (
> https://ffmpeg.org/ffmpeg-filters.html#movie-1)
> setting it to both `0` and `1`
>
> I attached a prototypal bash script in the first email, perhaps you could
> maybe run it on your system and amend it with what you think the solution
> should be?
>
> Many thanks!
> Arif
>
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Arif Driessen
> It is very hard to help when no info what exactly was tried is not
provided.
Well I tried every variation on what you said. that is:

> One possible way is using loop video filter
So I'm looking at this documentation:
https://ffmpeg.org/ffmpeg-filters.html#loop,
And so i stuck `loop=loop=$N` after `movie=filename=${THUMBNAIL}` with $N
being -1, 0, and 1
And I also played with the loop parameter in `movie` (
https://ffmpeg.org/ffmpeg-filters.html#movie-1)
setting it to both `0` and `1`

I attached a prototypal bash script in the first email, perhaps you could
maybe run it on your system and amend it with what you think the solution
should be?

Many thanks!
Arif
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Paul B Mahol
On Fri, Sep 24, 2021 at 7:49 PM Arif Driessen  wrote:

> > One possible way is using loop video filter, which will work with single
> images fine.
>
> Hi Paul, I've tried with this https://ffmpeg.org/ffmpeg-filters.html#loop
> and by setting the loop option on the `movie` filter. Both to no avail.
>

It is very hard to help when no info what exactly was tried is not provided.


> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Arif Driessen
> One possible way is using loop video filter, which will work with single
images fine.

Hi Paul, I've tried with this https://ffmpeg.org/ffmpeg-filters.html#loop
and by setting the loop option on the `movie` filter. Both to no avail.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Paul B Mahol
On Fri, Sep 24, 2021 at 7:31 PM Arif Driessen  wrote:

> Hi everyone,
>
> So I'm still working on my filter_complex graph that xfades an image to the
> beginning of another video.
>
> And I managed to figure it out, it works for any input source, except for
> the two different .png files I have tried. - where the video just stays
> stuck on the thumbnail and doesn't xfade.
>


Note that images are single frame, and thus. xfade will not work unless you
extend single frame to multiple frames.
One possible way is using loop video filter, which will work with single
images fine.



>
> Does anyone know why? I think it may have something to do with timebase?
>
> Here's a bash script you can use to test it:
>
> #!/bin/bash
>
> IN_VIDEO="input.avi"
> THUMBNAIL="thumbnail.png" # <-- use a video source here and it works fine
>
> THUMBNAIL_HOLD_SECONDS=0.4 # INVARIANT: HOLD MUST >= FADE_IN_SECONDS
> FADE_IN_SECONDS=0.2
> FADE_OUT_SECONDS=0.15
>
> VIDEO_RESOLUTION=$(ffprobe -v error -select_streams v -show_entries
> stream=width,height -of csv=s=x:p=0 "${IN_VIDEO}")
> PIXEL_FORMAT=$(ffprobe -v error -select_streams v -show_entries
> stream=pix_fmt -of csv=s=x:p=0 "${IN_VIDEO}")
> SAR=$(ffprobe -v error -select_streams v -show_entries
> format=sample_aspect_ratio -of csv=s=x:p=0 "${IN_VIDEO}")
>
> # `bc` doesn't print leading zeros, so let's fix it
> calc() { echo "$1" | bc | sed -e 's/^-\./-0./' -e 's/^\./0./'; }
>
> ffmpeg \
>   -hide_banner \
>   -filter_complex \
>   "
> `### DECLARE SOURCES ###`
>
> `# thumbnail_hold`
> movie=
>   filename=${THUMBNAIL},
> scale=${VIDEO_RESOLUTION},
> format=pix_fmts=${PIXEL_FORMAT},
> setsar=${SAR},
> trim=
>   start=0:
>   duration=${THUMBNAIL_HOLD_SECONDS}
> [thumbnail_hold_v];
>
> `# intro_a`
> aevalsrc=-2+random(0),
> atrim=
>   start=0:
>   duration=${THUMBNAIL_HOLD_SECONDS}
> [intro_a];
>
> `# main_v`
> movie=
>   filename=${IN_VIDEO},
> trim=
>   start=${TRIM_START_SECONDS}:
>   end=${TRIM_END_SECONDS}
> [main_v];
>
>   `# main_a`
> amovie=
> filename=${IN_VIDEO},
> atrim=
>   start=${TRIM_START_SECONDS}:
> end=${TRIM_END_SECONDS}
> [main_a];
>
> `### COMBINE AND OUTPUT ###`
>
> [thumbnail_hold_v][main_v]
> xfade=
>   duration=${FADE_IN_SECONDS}:
>   offset=$(calc "${THUMBNAIL_HOLD_SECONDS} - ${FADE_IN_SECONDS}");
>
> [intro_a][main_a]
> acrossfade=
>   duration=${FADE_IN_SECONDS}
>   `# (offset not needed here because acrossfade always starts from the
> end)`
>   " \
>   -vcodec libx264 \
>   -preset veryfast \
>   -crf 18 \
>   -pix_fmt yuv420p \
>   -acodec aac \
>   -b:a 192k \
>   -f nut - | ffplay -v error -f nut -
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


[FFmpeg-user] xfade works perfectly on any videosrc or video file, but not for images?

2021-09-24 Thread Arif Driessen
Hi everyone,

So I'm still working on my filter_complex graph that xfades an image to the
beginning of another video.

And I managed to figure it out, it works for any input source, except for
the two different .png files I have tried. - where the video just stays
stuck on the thumbnail and doesn't xfade.

Does anyone know why? I think it may have something to do with timebase?

Here's a bash script you can use to test it:

#!/bin/bash

IN_VIDEO="input.avi"
THUMBNAIL="thumbnail.png" # <-- use a video source here and it works fine

THUMBNAIL_HOLD_SECONDS=0.4 # INVARIANT: HOLD MUST >= FADE_IN_SECONDS
FADE_IN_SECONDS=0.2
FADE_OUT_SECONDS=0.15

VIDEO_RESOLUTION=$(ffprobe -v error -select_streams v -show_entries
stream=width,height -of csv=s=x:p=0 "${IN_VIDEO}")
PIXEL_FORMAT=$(ffprobe -v error -select_streams v -show_entries
stream=pix_fmt -of csv=s=x:p=0 "${IN_VIDEO}")
SAR=$(ffprobe -v error -select_streams v -show_entries
format=sample_aspect_ratio -of csv=s=x:p=0 "${IN_VIDEO}")

# `bc` doesn't print leading zeros, so let's fix it
calc() { echo "$1" | bc | sed -e 's/^-\./-0./' -e 's/^\./0./'; }

ffmpeg \
  -hide_banner \
  -filter_complex \
  "
`### DECLARE SOURCES ###`

`# thumbnail_hold`
movie=
  filename=${THUMBNAIL},
scale=${VIDEO_RESOLUTION},
format=pix_fmts=${PIXEL_FORMAT},
setsar=${SAR},
trim=
  start=0:
  duration=${THUMBNAIL_HOLD_SECONDS}
[thumbnail_hold_v];

`# intro_a`
aevalsrc=-2+random(0),
atrim=
  start=0:
  duration=${THUMBNAIL_HOLD_SECONDS}
[intro_a];

`# main_v`
movie=
  filename=${IN_VIDEO},
trim=
  start=${TRIM_START_SECONDS}:
  end=${TRIM_END_SECONDS}
[main_v];

  `# main_a`
amovie=
filename=${IN_VIDEO},
atrim=
  start=${TRIM_START_SECONDS}:
end=${TRIM_END_SECONDS}
[main_a];

`### COMBINE AND OUTPUT ###`

[thumbnail_hold_v][main_v]
xfade=
  duration=${FADE_IN_SECONDS}:
  offset=$(calc "${THUMBNAIL_HOLD_SECONDS} - ${FADE_IN_SECONDS}");

[intro_a][main_a]
acrossfade=
  duration=${FADE_IN_SECONDS}
  `# (offset not needed here because acrossfade always starts from the
end)`
  " \
  -vcodec libx264 \
  -preset veryfast \
  -crf 18 \
  -pix_fmt yuv420p \
  -acodec aac \
  -b:a 192k \
  -f nut - | ffplay -v error -f nut -
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


Re: [FFmpeg-user] xfade filter - custom expressions

2020-09-23 Thread Edward Park
Hi,

> "XY - The coordinates of the current sample." - Is the transition defined
> by selecting a color/state for each pixel?
> 
> "WH - The width and height of the image." - OK.
> 
> "P - Progress of transition effect." - Looking at the source, this is a
> float. Ranging from 0-1 I assume(?)
> 
> "PLANE - Currently processed plane." - Not sure what this means. How many
> planes are there? I'd say at least 2, one for each input. Are there more?
> 
> "A - Return value of first input at current location and plane." - This
> would return something like first_input[x][y] if the input were treated as
> an array? But I still don't understand what the plane refers to OR what the
> value returned would be. Would it be 0 or 1, or some color value?
> 
> "a0(x, y) a1(x, y) a2(x, y) a3(x, y) - Return the value of the pixel at
> location (x,y) of the first/second/third/fourth component of first input."
> - What does 'component' refer to? 1234 == RGBA ?
> 
> Is there an example that illustrates how to use a custom expression to
> achieve a meaningful transition?

Iā€™m not sure how to write equations for separate components on the command line 
either, but using your interpretation as reference, tried out 
expr='A*P+B*(1-P)ā€™ and got a basic working fade, at least looking at it 
visually with a couple sources.

Regards,
Ted Park

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

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

[FFmpeg-user] xfade filter - custom expressions

2020-09-23 Thread Peter
Hello,

Can someone help me to understand the xfade filter documentation regarding
custom expressions. I'm not really sure how to express a transition given
the variables provided.

"XY - The coordinates of the current sample." - Is the transition defined
by selecting a color/state for each pixel?

"WH - The width and height of the image." - OK.

"P - Progress of transition effect." - Looking at the source, this is a
float. Ranging from 0-1 I assume(?)

"PLANE - Currently processed plane." - Not sure what this means. How many
planes are there? I'd say at least 2, one for each input. Are there more?

"A - Return value of first input at current location and plane." - This
would return something like first_input[x][y] if the input were treated as
an array? But I still don't understand what the plane refers to OR what the
value returned would be. Would it be 0 or 1, or some color value?

"a0(x, y) a1(x, y) a2(x, y) a3(x, y) - Return the value of the pixel at
location (x,y) of the first/second/third/fourth component of first input."
- What does 'component' refer to? 1234 == RGBA ?

Is there an example that illustrates how to use a custom expression to
achieve a meaningful transition?

Thank you!
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Paul B Mahol
On 6/17/20, Rob Hallam  wrote:
> On Wed, 17 Jun 2020 at 16:19, Rob Hallam  wrote:
>
>> So it seems that (i) xfade shortens the inputs' combined duration
>> by half the transition duration; (ii) acrossfade does not shorten
>> if there is no overlap (as expected); (iii) acrossfade shortens
>> by the duration of fade if there is overlap.
>
> Pardon the self-reply, but I applied these observations
> to my real-world files and they have consistent A/V
> durations and seem to be in sync. Thanks to Paul for
> the help.
>
> Is it worth documenting this on the wiki, or, not to put too
> fine a point on it: am I the only one who has been initially
> confused by this?

Your offset in xfade is 9 seconds, but it should be 8 seconds.
Because duration of input is 10 seconds and transition duration is 2 seconds.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Rob Hallam
On Wed, 17 Jun 2020 at 16:19, Rob Hallam  wrote:

> So it seems that (i) xfade shortens the inputs' combined duration
> by half the transition duration; (ii) acrossfade does not shorten
> if there is no overlap (as expected); (iii) acrossfade shortens
> by the duration of fade if there is overlap.

Pardon the self-reply, but I applied these observations
to my real-world files and they have consistent A/V
durations and seem to be in sync. Thanks to Paul for
the help.

Is it worth documenting this on the wiki, or, not to put too
fine a point on it: am I the only one who has been initially
confused by this?

Cheers,
Rob
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Rob Hallam
On Wed, 17 Jun 2020 at 13:06, Paul B Mahol  wrote:

> First try single xfade and acrossfade combination.

Great suggestion. I tried that with synthetic inputs of 10 seconds
duration [1].

ffmpeg -i test10e.mkv -i test10d.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=9,format=yuv420p[x1];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[ax1]"
-map "[x1]" -map "[ax1]" -c:v libx264 -crf 18 -c:a aac text10-j2.mkv

This produced:

Duration: 00:00:19.10, start: 0.00, bitrate: 1048 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
  ENCODER : Lavc58.90.100 libx264
  DURATION: 00:00:19.10100
Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp (default)
Metadata:
  ENCODER : Lavc58.90.100 aac
  DURATION: 00:00:18.02400

So with overlap d=2:o=1, it is 18 seconds; 1 second shorter
than xfade video.

Without the overlap d=2:o=0, it is 20 seconds; 1 second
longer than xfade video.

Changing duration: d=1:o=0, the duration is still 20 seconds.

With overlap, d=1:o=1 the duration is 19 seconds, the same as
the video produced by xfade.

So it seems that (i) xfade shortens the inputs' combined duration
by half the transition duration; (ii) acrossfade does not shorten
if there is no overlap (as expected); (iii) acrossfade shortens
by the duration of fade if there is overlap.

Is this indeed the intended behaviour?

Cheers,
Rob

---

[1]:

ffmpeg -i test10e.mkv -i test10d.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=9,format=yuv420p[x1];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[ax1]"
-map "[x1]" -map "[ax1]" -c:v libx264 -crf 18 -c:a aac text10-j2.mkv
ffmpeg version N-53084-gd29aaf12f4-static https://johnvansickle.com/ffmpeg/
 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static
--disable-debug --disable-ffplay --disable-indev=sndio
--disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom
--enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-librubberband --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus
--enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi
--enable-libzimg
  libavutil  56. 50.100 / 56. 50.100
  libavcodec 58. 90.100 / 58. 90.100
  libavformat58. 44.100 / 58. 44.100
  libavdevice58.  9.103 / 58.  9.103
  libavfilter 7. 84.100 /  7. 84.100
  libswscale  5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc55.  6.100 / 55.  6.100
Input #0, matroska,webm, from 'test10e.mkv':
  Metadata:
ENCODER : Lavf58.44.100
  Duration: 00:00:10.08, start: 0.00, bitrate: 389 kb/s
Stream #0:0: Audio: vorbis, 48000 Hz, mono, fltp (default)
Metadata:
  ENCODER : Lavc58.90.100 libvorbis
  DURATION: 00:00:10.00300
Stream #0:1: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
  ENCODER : Lavc58.90.100 libx264
  DURATION: 00:00:10.08300
Input #1, matroska,webm, from 'test10d.mkv':
  Metadata:
ENCODER : Lavf58.44.100
  Duration: 00:00:10.08, start: 0.00, bitrate: 519 kb/s
Stream #1:0: Audio: vorbis, 48000 Hz, mono, fltp (default)
Metadata:
  ENCODER : Lavc58.90.100 libvorbis
  DURATION: 00:00:10.00300
Stream #1:1: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
  ENCODER : Lavc58.90.100 libx264
  DURATION: 00:00:10.08300
Stream mapping:
  Stream #0:0 (vorbis) -> acrossfade:crossfade0
  Stream #0:1 (h264) -> xfade:main
  Stream #1:0 (vorbis) -> acrossfade:crossfade1
  Stream #1:1 (h264) -> xfade:xfade
  format -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x59d2e80] using SAR=1/1
[libx264 @ 0x59d2e80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 0x59d2e80] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 0x59d2e80] 264 - core 160 r3000 33f9e14 - H.264/MPEG-4 AVC codec
- Copyleft 2003-2020 - 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=16 lookahead_threads=2
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_co

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Paul B Mahol
On 6/17/20, Rob Hallam  wrote:
> On Wed, 17 Jun 2020 at 11:34, Paul B Mahol  wrote:
>
>>> ie neither should change the length of the inputs they operate on.
>>>
>>> Is that a mistaken assumption perhaps?
>
>> Yes, very mistaken.
>
>> Duration of output is first input duration + second input duration -
>> duration of transition.
>> For xfade you need to set offset, acrossfade does not need that.
>
> D'oh, of course! Mistake on my part, I hadn't had my morning coffee.
> Thanks for keeping me right.
>
> What I meant was that they should both result in equal duration,
> **if overlap is set in acrossfade**. Is that a safe assumption?
>
> From the docs:
>
>> overlap, o
>>Should first stream end overlap with second stream start. Default is
> enabled.
> https://ffmpeg.org/ffmpeg-filters.html#acrossfade
>
> Also, from your earlier suggestion:
>
>> I believe this two should be - 2 seconds instead. Because both
>> transition durations for two xfade and acrossfade filters is 2
>> seconds.
>
> An offset of -2 produced desynched audio in the second segment (input
> 1 in the original filtergraph). The closest I can get to synch is an offset
> of -1 for the first input and -2 for the second; but it's still a little
> off.
>
> I'll try to create an example using generated 1Hz chirps and
> 'showspectrum'. If I can replicate there I will post a bug as you
> suggested.
>

First try single xfade and acrossfade combination.

For second xfade you will obviously need to substitute 2 seconds from
output of first xfade transition.

> Cheers,
> Rob
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Rob Hallam
On Wed, 17 Jun 2020 at 11:34, Paul B Mahol  wrote:

>> ie neither should change the length of the inputs they operate on.
>>
>> Is that a mistaken assumption perhaps?

> Yes, very mistaken.

> Duration of output is first input duration + second input duration -
> duration of transition.
> For xfade you need to set offset, acrossfade does not need that.

D'oh, of course! Mistake on my part, I hadn't had my morning coffee.
Thanks for keeping me right.

What I meant was that they should both result in equal duration,
**if overlap is set in acrossfade**. Is that a safe assumption?

From the docs:

> overlap, o
>Should first stream end overlap with second stream start. Default is
enabled.
https://ffmpeg.org/ffmpeg-filters.html#acrossfade

Also, from your earlier suggestion:

> I believe this two should be - 2 seconds instead. Because both
> transition durations for two xfade and acrossfade filters is 2
> seconds.

An offset of -2 produced desynched audio in the second segment (input
1 in the original filtergraph). The closest I can get to synch is an offset
of -1 for the first input and -2 for the second; but it's still a little
off.

I'll try to create an example using generated 1Hz chirps and
'showspectrum'. If I can replicate there I will post a bug as you
suggested.

Cheers,
Rob
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Paul B Mahol
On 6/17/20, Rob Hallam  wrote:
> On Tue, 16 Jun 2020 at 23:56, Paul B Mahol  wrote:
>
>>> TR1=764.3# input 0 duration - 1 second
>>> TR2=1250.498# input 0 + input 1 duration - 1 second
>
>> I believe this two should be - 2 seconds instead. Because both
>> transition durations for two xfade and acrossfade filters is 2
>> seconds.
>
> Thanks for the reply Paul, I will try that.
>
> My reading of xfade is that the transition start point should be
> half the duration from the end- the example on the wiki is 4.5s
> of a 5s input for a 1s transition. I am less sure about acrossfade,
> but thought it worked similarly.
>
> In either case diagram terms I figured they operated like:
>
> [AA AA AA AA][BB BB BB BB]
> ā†“
> [AA AA AA AB BA BB BB BB]
>
> ie neither should change the length of the inputs they operate on.
>
> Is that a mistaken assumption perhaps?

Yes, very mistaken.

Duration of output is first input duration + second input duration -
duration of transition.
For xfade you need to set offset, acrossfade does not need that.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-17 Thread Rob Hallam
On Tue, 16 Jun 2020 at 23:56, Paul B Mahol  wrote:

>> TR1=764.3# input 0 duration - 1 second
>> TR2=1250.498# input 0 + input 1 duration - 1 second

> I believe this two should be - 2 seconds instead. Because both
> transition durations for two xfade and acrossfade filters is 2
> seconds.

Thanks for the reply Paul, I will try that.

My reading of xfade is that the transition start point should be
half the duration from the end- the example on the wiki is 4.5s
of a 5s input for a 1s transition. I am less sure about acrossfade,
but thought it worked similarly.

In either case diagram terms I figured they operated like:

[AA AA AA AA][BB BB BB BB]
ā†“
[AA AA AA AB BA BB BB BB]

ie neither should change the length of the inputs they operate on.

Is that a mistaken assumption perhaps?

Cheers,
Rob
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: [FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-16 Thread Paul B Mahol
On 6/16/20, Rob Hallam  wrote:
> Hi all,
>
> tl;dr: with the same duration, should xfade and
> acrossfade produce synched output?
>
> I'd like to join three videos together, which have
> audio and video streams of virtually the same
> length. I thought I'd give the xfade [0] filter a
> try as it looked useful. To fade the audio as
> well I used acrossfade [1].
>
> However, the output has audio-video desync,
> which gets worse with each join- it is more
> noticeable after the second transition.
>
> Should I expect synchronised output if I use
> the same duration for both xfade and acrossfade
> (with overlap)?
>
> I don't often use a complex filtergraph, and though
> this one isn't terribly complex as filtergraphs go, I
> would appreciate pointers if there is a better
> approach.
>
> Command and output are appended [2].
>
> As a side note, is there a way to generate audio
> from ffmpeg for the purposes of testing
> synchronisation? I searched and had a quick look
> at 'audio sources', but didn't see anything obvious.
> It would make creating an MWE easier.
>
> Thanks in advance,
> Rob
>
>
> [0]: https://ffmpeg.org/ffmpeg-filters.html#xfade &
>  https://trac.ffmpeg.org/wiki/Xfade
>
> [1]: https://ffmpeg.org/ffmpeg-filters.html#acrossfade
>
> [2]: Full command and output:
>
> TR1=764.3# input 0 duration - 1 second
> TR2=1250.498# input 0 + input 1 duration - 1 second

I believe this two should be - 2 seconds instead. Because both
transition durations for two xfade and acrossfade filters is 2
seconds.

If this still does not work feel free to open bug report on trac.

>
> $ ffmpeg -i 2020-03-18\ 19-22-03.mkv -i 2020-03-18\ 20-02-07.mkv -i
>  2020-03-18\ 20-11-25.mkv -filter_complex
> "[0][1]xfade=transition=dissolve:duration=2:offset=$TR1,format=yuv420p[x1]
> ;[x1][2]xfade=transition=dissolve:duration=2:offset=$TR2,format=yuv420p[x2];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[a
> x1];[ax1][2]acrossfade=d=2:o=1:c1=tri:c2=tri[ax2]" -map "[x2]" -map "[ax2]"
> -c:v libx264 -crf 18 -c:a aac 2020-03-18
> \ 19-22-03-jx.mkv
> ffmpeg version N-98238-g276dfa9d91 Copyright (c) 2000-2020 the FFmpeg
> developers
>   built with gcc 10.1.0 (GCC)
>   configuration: --prefix=/usr --disable-debug --disable-static
> --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp
> --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
> --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm
> --enable-libfreetype --enable-libfribidi --enable-libgsm
> --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug
> --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
> --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr
> --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
> --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
> --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec
> --enable-nvenc --enable-omx --enable-shared --enable-version3
>   libavutil  56. 55.100 / 56. 55.100
>   libavcodec 58. 92.100 / 58. 92.100
>   libavformat58. 46.101 / 58. 46.101
>   libavdevice58. 11.100 / 58. 11.100
>   libavfilter 7. 86.100 /  7. 86.100
>   libswscale  5.  8.100 /  5.  8.100
>   libswresample   3.  8.100 /  3.  8.100
>   libpostproc55.  8.100 / 55.  8.100
> Input #0, matroska,webm, from '2020-03-18 19-22-03.mkv':
>   Metadata:
> ENCODER : Lavf58.29.100
>   Duration: 00:12:45.88, start: 0.00, bitrate: 16786 kb/s
> Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
> Metadata:
>   DURATION: 00:12:45.88400
> Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
> Metadata:
>   title   : Track1
>   DURATION: 00:12:45.79400
> Input #1, matroska,webm, from '2020-03-18 20-02-07.mkv':
>   Metadata:
> ENCODER : Lavf58.29.100
>   Duration: 00:08:07.12, start: 0.00, bitrate: 20933 kb/s
> Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
> Metadata:
>   DURATION: 00:08:07.11700
> Stream #1:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
> Metadata:
>   title   : Track1
>   DURATION: 00:08:07.06200
> Input #2, matroska,webm, from '2020-03-18 20-11-25.mkv':
>   Metadata:
> ENCODER : Lavf58.29.100
>   Duration: 00:06:49.10, start: 0.00, bitrate: 20261 kb/s
> Stream #2:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
> Metadata:
>   DURATION: 00:06:49.1
> Stream #2:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
> Metadata:
>   title   : Track1
>   DURATION: 00:06:49.06600
> Stream mapping:
>   Stream #0:0 (h2

[FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync

2020-06-16 Thread Rob Hallam
Hi all,

tl;dr: with the same duration, should xfade and
acrossfade produce synched output?

I'd like to join three videos together, which have
audio and video streams of virtually the same
length. I thought I'd give the xfade [0] filter a
try as it looked useful. To fade the audio as
well I used acrossfade [1].

However, the output has audio-video desync,
which gets worse with each join- it is more
noticeable after the second transition.

Should I expect synchronised output if I use
the same duration for both xfade and acrossfade
(with overlap)?

I don't often use a complex filtergraph, and though
this one isn't terribly complex as filtergraphs go, I
would appreciate pointers if there is a better
approach.

Command and output are appended [2].

As a side note, is there a way to generate audio
from ffmpeg for the purposes of testing
synchronisation? I searched and had a quick look
at 'audio sources', but didn't see anything obvious.
It would make creating an MWE easier.

Thanks in advance,
Rob


[0]: https://ffmpeg.org/ffmpeg-filters.html#xfade &
 https://trac.ffmpeg.org/wiki/Xfade

[1]: https://ffmpeg.org/ffmpeg-filters.html#acrossfade

[2]: Full command and output:

TR1=764.3# input 0 duration - 1 second
TR2=1250.498# input 0 + input 1 duration - 1 second

$ ffmpeg -i 2020-03-18\ 19-22-03.mkv -i 2020-03-18\ 20-02-07.mkv -i
 2020-03-18\ 20-11-25.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=$TR1,format=yuv420p[x1]
;[x1][2]xfade=transition=dissolve:duration=2:offset=$TR2,format=yuv420p[x2];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[a
x1];[ax1][2]acrossfade=d=2:o=1:c1=tri:c2=tri[ax2]" -map "[x2]" -map "[ax2]"
-c:v libx264 -crf 18 -c:a aac 2020-03-18
\ 19-22-03-jx.mkv
ffmpeg version N-98238-g276dfa9d91 Copyright (c) 2000-2020 the FFmpeg
developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static
--disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm
--enable-libfreetype --enable-libfribidi --enable-libgsm
--enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug
--enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
--enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec
--enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil  56. 55.100 / 56. 55.100
  libavcodec 58. 92.100 / 58. 92.100
  libavformat58. 46.101 / 58. 46.101
  libavdevice58. 11.100 / 58. 11.100
  libavfilter 7. 86.100 /  7. 86.100
  libswscale  5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc55.  8.100 / 55.  8.100
Input #0, matroska,webm, from '2020-03-18 19-22-03.mkv':
  Metadata:
ENCODER : Lavf58.29.100
  Duration: 00:12:45.88, start: 0.00, bitrate: 16786 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
Metadata:
  DURATION: 00:12:45.88400
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
Metadata:
  title   : Track1
  DURATION: 00:12:45.79400
Input #1, matroska,webm, from '2020-03-18 20-02-07.mkv':
  Metadata:
ENCODER : Lavf58.29.100
  Duration: 00:08:07.12, start: 0.00, bitrate: 20933 kb/s
Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
Metadata:
  DURATION: 00:08:07.11700
Stream #1:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
Metadata:
  title   : Track1
  DURATION: 00:08:07.06200
Input #2, matroska,webm, from '2020-03-18 20-11-25.mkv':
  Metadata:
ENCODER : Lavf58.29.100
  Duration: 00:06:49.10, start: 0.00, bitrate: 20261 kb/s
Stream #2:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
Metadata:
  DURATION: 00:06:49.1
Stream #2:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
Metadata:
  title   : Track1
  DURATION: 00:06:49.06600
Stream mapping:
  Stream #0:0 (h264) -> xfade:main
  Stream #0:1 (aac) -> acrossfade:crossfade0
  Stream #1:0 (h264) -> xfade:xfade
  Stream #1:1 (aac) -> acrossfade:crossfade1
  Stream #2:0 (h264) -> xfade:xfade
  Stream #2:1 (aac) -> acrossfade:crossfade1
  format -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x55813c4e] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55813c4e] pr

Re: [FFmpeg-user] xfade and acrossfade

2020-01-31 Thread Michael Koch

Am 31.01.2020 um 19:09 schrieb Paul B Mahol:

On 1/31/20, Michael Koch  wrote:

Paul,

is there any chance that the new xfade filter and the acrossfade filter
could be harmonized, so that they accept the same parameters?
The acrossfade filter does always fade near the end of the first input
stream. Only the duration must be specified.
The xfade filter expects a duration and an offset. If you want to fade
near the end of the first stream, you have to know its length.
I prefer the behaviour of acrossfilter because it's unnecessary to know
the length.
If you want the video fade earlier in the stream, the trim filter could
be used before xfade.

Nope, because storing 1000 frames (duration of transition) in RAM is not free.


A maximum of 100 frames (4s at 25fps) would be sufficient for 99% of all 
cases.


Michael

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

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

Re: [FFmpeg-user] xfade and acrossfade

2020-01-31 Thread Paul B Mahol
On 1/31/20, Michael Koch  wrote:
> Paul,
>
> is there any chance that the new xfade filter and the acrossfade filter
> could be harmonized, so that they accept the same parameters?
> The acrossfade filter does always fade near the end of the first input
> stream. Only the duration must be specified.
> The xfade filter expects a duration and an offset. If you want to fade
> near the end of the first stream, you have to know its length.
> I prefer the behaviour of acrossfilter because it's unnecessary to know
> the length.
> If you want the video fade earlier in the stream, the trim filter could
> be used before xfade.

Nope, because storing 1000 frames (duration of transition) in RAM is not free.

>
> Michael
>
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> https://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
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

[FFmpeg-user] xfade and acrossfade

2020-01-31 Thread Michael Koch

Paul,

is there any chance that the new xfade filter and the acrossfade filter 
could be harmonized, so that they accept the same parameters?
The acrossfade filter does always fade near the end of the first input 
stream. Only the duration must be specified.
The xfade filter expects a duration and an offset. If you want to fade 
near the end of the first stream, you have to know its length.
I prefer the behaviour of acrossfilter because it's unnecessary to know 
the length.
If you want the video fade earlier in the stream, the trim filter could 
be used before xfade.


Michael

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

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