just post it on lemmy world as a meme, copypaste a comment that makes the code better along with the original code into the AI agent
I’m curious if you succeeded with this approach here - have you gotten your LLM to produce a bash function which you can use without needing to understand how to specify an ffmpeg filename pattern yet?
btw, if want to try learning the old-fashioned way, have a look at man ffmpeg-formats where you can find perhaps-useful information like this:
segment, stream_segment, ssegment
Basic stream segmenter.
This muxer outputs streams to a number of separate files of nearly
fixed duration. Output filename pattern can be setin a fashion similar
to image2, orbyusing a "strftime" template if the strftime option is
enabled.
"stream_segment"is a variant of the muxer used to write to streaming
output formats, i.e. which donot require global headers, andis
recommended for outputting e.g. to MPEG transport stream segments.
"ssegment"is a shorter aliasfor"stream_segment".
Every segment starts with a keyframe of the selected reference stream,
which isset through the reference_stream option.
Note that if you want accurate splitting for a video file, you need to
make the input key frames correspond to the exact splitting times
expected by the segmenter, or the segment muxer will start the new
segment with the key frame found next after the specified start time.
The segment muxer works best with a single constant frame rate video.
Optionally it can generate a list of the created segments, by setting
the option segment_list. The list type is specified by the
segment_list_type option. The entry filenames in the segment list are
setbydefault to the basename of the corresponding segment files.
See also the hls muxer, which provides a more specific implementation
for HLS segmentation.
Options
The segment muxer supports the following options:
[...]
From the image2 section, here is how the filename pattern works:
sequence
Select a sequence pattern type, used to specify a sequence of
files indexed by sequential numbers.
A sequence pattern may contain the string "%d" or "%0Nd", which
specifies the position of the characters representing a
sequential number ineach filename matched by the pattern. If
the form "%d0Nd" is used, the string representing the number ineach filename is0-padded and N is the total number of0-padded
digits representing the number. The literal character'%' can
be specified in the patternwith the string "%%".
If the sequence patterncontains "%d" or "%0Nd", the first
filename of the file list specified by the pattern must contain
a number inclusively contained between start_number and
start_number+start_number_range-1, andall the following
numbers must be sequential.
For example the pattern "img-%03d.bmp" will match a sequence of
filenames of the form img-001.bmp, img-002.bmp, ...,
img-010.bmp, etc.; the pattern "i%%m%%g-%d.jpg" will match a
sequence of filenames of the form i%m%g-1.jpg, i%m%g-2.jpg,
..., i%m%g-10.jpg, etc.
And btw, the ffmpeg-formats manual does also include examples:
Examples
• Remux the content of file in.mkv to a list of segments out-000.nut,
out-001.nut, etc., and write the list of generated segments to
out.list:
ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
• Segment input andset output format options for the output
segments:
ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
• Segment the input file according to the split points specified by
the segment_times option:
ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 out%03d.nut
• Use the ffmpeg force_key_frames optionto force key frames in the
input at the specified location, together with the segment option
segment_time_delta to account for possible roundings operated when
setting key frame times.
ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
-f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
Inorderto force key frames on the input file, transcoding is
required.
• Segment the input file by splitting the input file according to the
frame numbers sequence specified with the segment_frames option:
ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
• Convert the in.mkv to TS segments using the "libx264"and"aac"
encoders:
ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
• Segment the input file, and create an M3U8 live playlist (can be
used as live HLS source):
ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
-segment_list_flags +live -segment_time 10 out%03d.mkv
It is actually possible to figure out how to do this and many other ffmpeg tasks even without internet access :)
i really need to spend more time reading the mans and less time asking the bot. the mans are guaranteed to be right, but with the bot, who the fuck knows
I’m curious if you succeeded with this approach here - have you gotten your LLM to produce a bash function which you can use without needing to understand how to specify an ffmpeg filename pattern yet?
btw, if want to try learning the old-fashioned way, have a look at
man ffmpeg-formatswhere you can find perhaps-useful information like this:segment, stream_segment, ssegment Basic stream segmenter. This muxer outputs streams to a number of separate files of nearly fixed duration. Output filename pattern can be set in a fashion similar to image2, or by using a "strftime" template if the strftime option is enabled. "stream_segment" is a variant of the muxer used to write to streaming output formats, i.e. which do not require global headers, and is recommended for outputting e.g. to MPEG transport stream segments. "ssegment" is a shorter alias for "stream_segment". Every segment starts with a keyframe of the selected reference stream, which is set through the reference_stream option. Note that if you want accurate splitting for a video file, you need to make the input key frames correspond to the exact splitting times expected by the segmenter, or the segment muxer will start the new segment with the key frame found next after the specified start time. The segment muxer works best with a single constant frame rate video. Optionally it can generate a list of the created segments, by setting the option segment_list. The list type is specified by the segment_list_type option. The entry filenames in the segment list are set by default to the basename of the corresponding segment files. See also the hls muxer, which provides a more specific implementation for HLS segmentation. Options The segment muxer supports the following options: [...]From the
image2section, here is how the filename pattern works:sequence Select a sequence pattern type, used to specify a sequence of files indexed by sequential numbers. A sequence pattern may contain the string "%d" or "%0Nd", which specifies the position of the characters representing a sequential number in each filename matched by the pattern. If the form "%d0Nd" is used, the string representing the number in each filename is 0-padded and N is the total number of 0-padded digits representing the number. The literal character '%' can be specified in the pattern with the string "%%". If the sequence pattern contains "%d" or "%0Nd", the first filename of the file list specified by the pattern must contain a number inclusively contained between start_number and start_number+start_number_range-1, and all the following numbers must be sequential. For example the pattern "img-%03d.bmp" will match a sequence of filenames of the form img-001.bmp, img-002.bmp, ..., img-010.bmp, etc.; the pattern "i%%m%%g-%d.jpg" will match a sequence of filenames of the form i%m%g-1.jpg, i%m%g-2.jpg, ..., i%m%g-10.jpg, etc.And btw, the
ffmpeg-formatsmanual does also include examples:Examples • Remux the content of file in.mkv to a list of segments out-000.nut, out-001.nut, etc., and write the list of generated segments to out.list: ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut • Segment input and set output format options for the output segments: ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4 • Segment the input file according to the split points specified by the segment_times option: ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 out%03d.nut • Use the ffmpeg force_key_frames option to force key frames in the input at the specified location, together with the segment option segment_time_delta to account for possible roundings operated when setting key frame times. ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \ -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut In order to force key frames on the input file, transcoding is required. • Segment the input file by splitting the input file according to the frame numbers sequence specified with the segment_frames option: ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut • Convert the in.mkv to TS segments using the "libx264" and "aac" encoders: ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts • Segment the input file, and create an M3U8 live playlist (can be used as live HLS source): ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \ -segment_list_flags +live -segment_time 10 out%03d.mkvIt is actually possible to figure out how to do this and many other ffmpeg tasks even without internet access :)
i really need to spend more time reading the
mans and less time asking the bot. themans are guaranteed to be right, but with the bot, who the fuck knowsAnd with a command like ffmpeg a wrong bot command might just as well overwrite your source file.