cannot seek into png 'video'

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

cannot seek into png 'video'

Thorsten von Eicken
I'm trying to put an overlay over a video and I'm having difficulties
seeking into the png in order to time-shift the video and overlay
relative to one another. In short, using `-ss` on the png results in an
error like "overlay.png: could not seek to position 10.000". Is there a
work-around?

What I'm doing is I'm generating a png 'video' for the overlay, i.e., a
file with png images one after the other at a frame rate of 1 fps. I can
do the overlay with something like:

ffmpeg -i 20190928_155656_stab.mp4 -framerate 1 -c:v png -i overlay.png \
     -filter_complex "[0:v]setpts=PTS-STARTPTS[top];
[1:v]setpts=PTS-STARTPTS[bottom];
[top][bottom]overlay=x=(W-w)/2:eof_action=pass" \
     -acodec aac -vcodec libx264 final.mp4

If I'd now like to skip the first 10 seconds of the overlay in order to
line up the timing better I try to use:

ffmpeg -i 20190928_155656_stab.mp4 -framerate 1 -ss 10 -c:v png -i
overlay.png ...

But that results in the error. Using `-ss` on the mp4 input works great
to time-shit in the other direction.

Can anyone recommend a work-around?

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

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

Re: cannot seek into png 'video'

Moritz Barsnick
Moin Thorsten,

On Tue, Oct 01, 2019 at 00:56:33 +0000, Thorsten von Eicken wrote:
> I'm trying to put an overlay over a video and I'm having difficulties
> seeking into the png in order to time-shift the video and overlay
> relative to one another.

I don't really understand what you are trying to do, neither from this
sentence:

> If I'd now like to skip the first 10 seconds of the overlay in order to
> line up the timing better I try to use:

"Line up timing" or "time shift" are nice terms, but all "-ss" does it
to shift the starting point of the input file to a certain point. E.g.
"-ss 10" skips the first 10 seconds.

> In short, using `-ss` on the png results in an
> error like "overlay.png: could not seek to position 10.000". Is there a
> work-around?

When providing a static image as overlay, the image is overlaid over
all the base video's frames. What do you expect to change if you jump
10 seconds into the overlay? It would still be the identical image
(assuming the image is converted to a video stream or interpreted
repeatedly - see below).

> What I'm doing is I'm generating a png 'video' for the overlay, i.e., a
> file with png images one after the other at a frame rate of 1 fps. I can
> do the overlay with something like:

"images one after another" - are you saying that the images are
changing? I.e. different images, changing every second?

> ffmpeg -i 20190928_155656_stab.mp4 -framerate 1 -c:v png -i overlay.png \
>      -filter_complex "[0:v]setpts=PTS-STARTPTS[top];
> [1:v]setpts=PTS-STARTPTS[bottom];
> [top][bottom]overlay=x=(W-w)/2:eof_action=pass" \
>      -acodec aac -vcodec libx264 final.mp4

With "eof_action=pass", only one frame of the overlay will be used, as
the PNG stream only provides one frame with your current command line.
If you want to make the PNG into a video stream, you can add the input
option "-stream_loop -1". But you can just as well just omit the
"eof_action=" option, which will make the filter use
"eof_action=repeat", which will automatically use the PNG as a sort of
video stream. (Actually, the filter just re-uses the last frame
encountered.)

> But that results in the error. Using `-ss` on the mp4 input works great
> to time-shit in the other direction.

(Nice typo.) Now back to the original issue: What are you trying to
do? If you want to skip over the first 10 seconds of the input video,
then "-ss" needs to be an option for the input video of course, not for
the PNG.

Sorry if I'm adding to the confusion, but I personally am confused. ;-)

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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

Re: cannot seek into png 'video'

Carl Eugen Hoyos-2
In reply to this post by Thorsten von Eicken
Am Di., 1. Okt. 2019 um 02:56 Uhr schrieb Thorsten von Eicken
<[hidden email]>:

> ffmpeg -i 20190928_155656_stab.mp4 -framerate 1 -c:v png -i overlay.png \
>      -filter_complex "[0:v]setpts=PTS-STARTPTS[top];
> [1:v]setpts=PTS-STARTPTS[bottom];
> [top][bottom]overlay=x=(W-w)/2:eof_action=pass" \
>      -acodec aac -vcodec libx264 final.mp4
>
> If I'd now like to skip the first 10 seconds of the overlay in order to
> line up the timing better I try to use:
>
> ffmpeg -i 20190928_155656_stab.mp4 -framerate 1 -ss 10 -c:v png -i
> overlay.png ...

(Complete, uncut console output missing.)

I believe you are searching for "-loop 1", I don't think stream_loop
works here.

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

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

Re: cannot seek into png 'video'

Thorsten von Eicken
In reply to this post by Moritz Barsnick
On 10/1/19 12:35 AM, Moritz Barsnick wrote:

> Moin Thorsten,
>
> On Tue, Oct 01, 2019 at 00:56:33 +0000, Thorsten von Eicken wrote:
>> I'm trying to put an overlay over a video and I'm having difficulties
>> seeking into the png in order to time-shift the video and overlay
>> relative to one another.
> I don't really understand what you are trying to do, neither from this
> sentence:
>
>> If I'd now like to skip the first 10 seconds of the overlay in order to
>> line up the timing better I try to use:
> "Line up timing" or "time shift" are nice terms, but all "-ss" does it
> to shift the starting point of the input file to a certain point. E.g.
> "-ss 10" skips the first 10 seconds.

The png input is not a single static image, it is a sequence of images,
i.e. a video in png format. Like mjpeg but png. There is one image per
second as the overlay is not static, it's showing GPS info (speed, track
position, etc). The problem I have is that it's not trivial to
synchronize the overlay with the video. I generate the overlay from a
GPS track recording and the video comes from an action cam. So after
generating the overlay I'd like to tweak the synchronization by skipping
a few frames at the start of either of the video or of the overlay. Does
that make sense?

Thanks!

Thorsten

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

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

Re: cannot seek into png 'video'

Carl Eugen Hoyos-2
Am Di., 1. Okt. 2019 um 16:48 Uhr schrieb Thorsten von Eicken
<[hidden email]>:

>
> On 10/1/19 12:35 AM, Moritz Barsnick wrote:
> > Moin Thorsten,
> >
> > On Tue, Oct 01, 2019 at 00:56:33 +0000, Thorsten von Eicken wrote:
> >> I'm trying to put an overlay over a video and I'm having difficulties
> >> seeking into the png in order to time-shift the video and overlay
> >> relative to one another.
> > I don't really understand what you are trying to do, neither from this
> > sentence:
> >
> >> If I'd now like to skip the first 10 seconds of the overlay in order to
> >> line up the timing better I try to use:
> > "Line up timing" or "time shift" are nice terms, but all "-ss" does it
> > to shift the starting point of the input file to a certain point. E.g.
> > "-ss 10" skips the first 10 seconds.
>
> The png input is not a single static image, it is a sequence of images,
> i.e. a video in png format. Like mjpeg but png.

You cannot (in general) seek in such a stream.

Use files that can be accessed with %d instead, seeking works
with img2dec for multiple files.

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

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

Re: cannot seek into png 'video'

Thorsten von Eicken
On 10/1/19 8:37 AM, Carl Eugen Hoyos wrote:

> Am Di., 1. Okt. 2019 um 16:48 Uhr schrieb Thorsten von Eicken
> <[hidden email]>:
>> On 10/1/19 12:35 AM, Moritz Barsnick wrote:
>>> Moin Thorsten,
>>>
>>> On Tue, Oct 01, 2019 at 00:56:33 +0000, Thorsten von Eicken wrote:
>>>> I'm trying to put an overlay over a video and I'm having difficulties
>>>> seeking into the png in order to time-shift the video and overlay
>>>> relative to one another.
>>> I don't really understand what you are trying to do, neither from this
>>> sentence:
>>>
>>>> If I'd now like to skip the first 10 seconds of the overlay in order to
>>>> line up the timing better I try to use:
>>> "Line up timing" or "time shift" are nice terms, but all "-ss" does it
>>> to shift the starting point of the input file to a certain point. E.g.
>>> "-ss 10" skips the first 10 seconds.
>> The png input is not a single static image, it is a sequence of images,
>> i.e. a video in png format. Like mjpeg but png.
> You cannot (in general) seek in such a stream.
>
> Use files that can be accessed with %d instead, seeking works
> with img2dec for multiple files.
>
> Carl Eugen


I did figure it out, the way to synchronize the two videos with
one-another is to use the setpts filter. Instead of:

-filter_complex "[0:v]setpts=PTS-STARTPTS[top];
[1:v]setpts=PTS-STARTPTS[bottom];
[top][bottom]overlay=x=(W-w)/2:eof_action=pass"

I can use something like the following to make the overlay start 5
minutes 51 seconds into the 'base' video:

-filter_complex '[0:v]setpts=PTS-STARTPTS[top];
[1:v]setpts=PTS-STARTPTS+351[bottom];
[top][bottom]overlay=x=(W-w)/2:eof_action=pass'

Note that 351 frames corresponds to 351 seconds due to the 1 fps and 1
tbn of the overlay and 351 seconds = 5 minutes 51 secs.

Thanks for the replies!

Thorsten

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

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