The command it created looks correct, but is subtly wrong. $3 isn't the "length" of each segment, it's the template for the output file. $2 is in fact the (approximate) length of each segment in seconds, not the "N" value as the function name suggests. Also, you probably want to set reset_timestamps so the timing information is correct.
The command it created looks correct, but is subtly wrong. $3 isn’t the “length” of each segment, it’s the template for the output file. $2 is in fact the (approximate) length of each segment in seconds, not the “N” value as the function name suggests. Also, you probably want to set reset_timestamps so the timing information is correct.
this is another way to write code without having any idea what you're doing. 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
Sounds like a good way to remove the French language pack from your system. :P
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 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 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 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-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 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.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
And with a command like ffmpeg a wrong bot command might just as well overwrite your source file.
how do you know this off-hand? ffmpeg always felt like the most incantationest of all incantations to me
also, upvoted for good feedback
I actually just Googled (well, Kagi'd) it, and found the article that the AI presumably hallucinated this command from.
10 minutes later...
divideMp4IntoNSegmentsOfLengthTButPleaseDoItCorrectlyThisTimePrettyPrettyPleaseJesusFuckWhyAreYouSoFuckingStupid(){
}
I'm pretty sure the awful formatting of the comment is here to trigger us.
Anyway, merge request rejected for that alone.
What's so special about that? It's basically just googling, but it takes a second instead of an hour. With the added downside that you don't learn a thing, so you'll never be able to do it without AI.
whether you learn something new or not it's up to you, not the ai
likewise, you can copy and paste from SO and learn nothing
exactly. ppl are like "AI can't teach you anything" and i'm like "well if you make zero effort to learn, you won't learn from humans either"
See, a teacher will give you a task to solve, preferably on your own, to teach you a thing. They won't give you a task and the solution so you can look at the solution and go "ah, yes, I understand".
I mean, literally anything is possible if your codenase is fundamentally broken.
How can a function like this exist without parameters for N and T?
it's a shell function. the code should work for bash or zsh. with those, it doesn't look like there are any parameters in function definitons, but there are.
Knowing how to write code has only ever been half (or less) of the job. A real programmer solves problems with code, especially problems that aren’t like any they’ve seen before. Someone who can write code but can’t solve problems or can only ‘solve’ problems they’ve seen before is just a code monkey. AI can regurgitate code it’s seen before (that is, code it was trained on) and it can do some problem solving but it falls on its face quickly if you ask it to do anything complex (at least for my metric of what is complex).
i want to be clear that AI can't do your entire job for you, and if you start pushing vibe coded shit to prod, you should start looking for a new job. still, AI is ridiculously useful- maybe not for you, but i'm an amateur with major gaps in my coding knowledge, so AI is incredibly useful for folks like me. of course if i actually get paid to do this shit, every line i write will have to be my own.
As a dev that recently transitioned from a decade of sys admin experience, to two years of ServiceNow admin/developer/et all, to now full stack development, I have found AI useful for somethings. I asked it how to do a thing, and it regurgitated a bunch of code that didn't do what I was looking for, however, it did give me a framework for what files I needed to modify. I then put nose to the grindstone and write all of the rest of the code myself, researching the docs when needed, and I got it done.
For me, if I use AI to assist in something code, I always type everything out myself whether it's right or not, because like taking notes, typing it out does help learn what I'm doing, not just finding a solution and running with it. I've disabled most of the auto complete copilot garbage in Visual Studio because it would generate huge blocks of code that may or may not be correct, and the accept button is the tab key, which I use frequently. I still have some degree of auto complete for single lines, but that's it.
My advice would be to use AI as a prompt to get ideas or steer direction, but if you want to get better at coding and problem solving, I would suggest trying to find solutions yourself because digging through docs will be far more beneficial to your growth. AI does a good job of helping fill the gaps in packages or frameworks when your ignorant to all of the functions and stuff, but striving to understand them instead of relying on unreliable tools will make you a much better developer long term
You always need to read what the machine generated for you; the machine can only write code for you, not understand code for you. Here, the biggest issue is that copy might not work if the input and output containers are different, if the input has multiple framerates or audio tracks, etc.
Programmer Humor
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics