[FFmpeg-user] Replacement for showinfo's former "pos"?
AT&T
llee040 at sbcglobal.net
Sat Nov 23 22:13:22 EET 2024
I wrote a shell script that you can use to enter start time and end time of the clip you want to preserve in your excerpt. It uses time of day functions to calculate duration from start point and end point (if I understand your needs correctly).
I've included here a rather wordy explanation in the interest of being as clear as possible and leaving nothing out.
Because of the use of time of day rather than actual video time specification, the excerpt start times and end times must be rounded to the second. Further refinement is possible in the actual shell script (by providing a 2-digit decimal value after the end of the value for seconds in a time stamp). It would be possible to make the script more complex to ascertain values to a higher resolution, I guess, but rounding to the second serves my purposes well enough.
In this example, I'll show the command I would use for creating an excerpt from a 15 minute video passage starting at 6 minutes and 33 seconds and ending at ten minutes and 3 seconds (the total duration of the source video doesn't matter, of course, except that for this example, it would need to be something greater than 10 minutes and 3 seconds). The duration of the excerpt passage is determined by the script. I just provide the start and end times of the excerpt I want to make. I can easily see the start and end times in my video viewer. I'm leaving the handling of start, end, and duration scripting variables to you (their handling depends on your scripting system).
With a start time of 6 minutes 33 seconds, you set the relative date value for start using the following:
date -j -f '%H:%M:%S' 00:06:33 '+%s'
or 1732341993
The end time I enter is 00:10:03.
date -j -f '%H:%M:%S' 00:10:03 '+%s'
or 1732341993
Then the calculation is made to find the duration
duration = expr $[end] - $[start]
or expr 1732342203 - 1732341993
resulting in a value of 210 seconds, which can be expressed as a time stamp with
date -u -r 210 +%T
or 00:03:30
The ffmpeg command to create the excerpt on my system for a source file named "test.ts" could be something like:
ffmpeg -ss 00:06:33 -noaccurate_seek -i test.ts -t 00:03:30.00 -codec copy -map v:0 -map a:0? -movflags +faststart test-1.ts
My completed script is an AppleScript, and the shell commands have not required change through system upgrades since I first developed it several years ago. You're welcomed to view my AppleScript on my blog. My version prompts me for the start and end values through dialog boxes, which I answer manually.
https://prehensileblog.wordpress.com/2023/11/04/applescript-source-for-exporting-a-video-excerpt-using-ffmpeg/
L. Lee
> On Nov 23, 2024, at 11:48 AM, Moritz Barsnick via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
>
> Hi,
>
> I'm looking for a replacement for what the "showinfo" filter used to be
> able to display.
>
> Before commit 27f8c9b27bce42a4a6a4c64e03fab769579c8683, filters got the
> information of the byte position within a file. I used this information
> from showinfo for this:
>
> I am trying to truncate MPEG-TS files on my disk. I know the timestamp
> of the last position I want to retain, so I did:
>
> $ ffmpeg -ss <timestamp to truncate from> -i video.ts -map 0:v -vf showinfo -t 2 -f null -
>
> and uses the "pos" information in a call to "truncate".
>
> This info is no longer available. Are there any alternatives using
> ffmpeg?
>
> A bitstream filter would be just as good as filter, as there's little
> need to actually decode the stream. And I noticed that struct AVPacket
> still contains pos.
>
> Thanks,
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list