[FFmpeg-user] Can transpose and between done in one command

Cecil Westerhof Cecil at decebal.nl
Tue Sep 26 15:38:23 EEST 2023


Moritz Barsnick <barsnick at gmx.net> writes:

> Hi Cecil,
>
>> In principle that would lead to a little better output video I think,
>> because it is processed one time less. Or would it not make much
>> difference?
>
> Oh, yes, absolutely it would make a difference. Each (lossy) reencoding
> is a loss in quality. Also, you could save a lot of time.

OK, I was not kidding myself. :-D

Saving time probably not in my case. Before I define the times by
looking at the video, I have to transpose it already.


> As the ffmpeg-filters docs say,
>> Filters in the same linear chain are separated by commas, [...]
>
> You're already doing this with "select,(a)setpts".

That is the problem with copying from the internet: you (or better
said I) do not really know what you are (I am) doing. :'-(


> I would suggest selecting first, then transposing (which saves you from
> transposing content which is later discarded), but it shouldn't matter.

I will try to do both. Just to satisfy my curiosity. ;-)


> I'm just not sure whether the t's in your select filter need to be
> adapted, because you changed the video timestamps in the original
> "first" step.

That is the problem with the copy paste. Most of my videos I had to
cut several parts out of the video. But the last one was taken in one
go so I only needed to transpose and take a part from it.
There was an exit after the first ffmpeg and the output file was
outputVideo instead of inputVideoTurned.

Sloppy of me. %-{


>>             -vf "transpose=cclock"  \
>
>>             -vf "
>>                  select='between(t,   0.7,  13.0) +
>>                          between(t,  26.0,  67.0) +
>>                          between(t,  82.0,  87.2)',
>>                   setpts=N/FRAME_RATE/TB
>>             "                                       \
>>             -af "
>>                 aselect='between(t,   0.7,  13.0) +
>>                          between(t,  26.0,  67.0) +
>>                          between(t,  82.0,  87.2)',
>>                  asetpts=N/SR/TB
>>             "                                       \
>
>
> So ultimately, your filters would be:
>
>             -vf "
>                  select='between(t,   0.7,  13.0) +
>                          between(t,  26.0,  67.0) +
>                          between(t,  82.0,  87.2)',
>                  setpts=N/FRAME_RATE/TB,
>                  transpose=cclock
>             "                                       \
>             -af "
>                 aselect='between(t,   0.7,  13.0) +
>                          between(t,  26.0,  67.0) +
>                          between(t,  82.0,  87.2)',
>                  asetpts=N/SR/TB
>             "

Thank you. I am going to try it out.


> I'm not sure how you manage to collect content from 82.0 to 87.2 in a
> 59 second long video, but I may be missing something. ;-)

My stupidity. It was parts of two different scripts. I have to polish
my workflow, but at the moment I copy the script and change it. I have
to make it data driven.


By the way in my long way to get here it seamed that the
inputVideoTurned was best to be a .ts file. The inputVideo is a .mts
file. First I used .mkv instead of .ts. Could that really have been a
problem, or was I led astray?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list