89
top 50 comments
sorted by: hot top controversial new old
[-] savvywolf@pawb.social 88 points 5 days ago

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.

[-] NEILSON_MANDALA@lemmy.world 104 points 5 days ago* (last edited 5 days ago)

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

[-] savvywolf@pawb.social 59 points 5 days ago

Sounds like a good way to remove the French language pack from your system. :P

load more comments (13 replies)
[-] cypherpunks@lemmy.ml 9 points 5 days ago

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 :)

[-] NEILSON_MANDALA@lemmy.world 6 points 5 days ago

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

[-] squaresinger@lemmy.world 2 points 4 days ago

And with a command like ffmpeg a wrong bot command might just as well overwrite your source file.

[-] ragingHungryPanda@piefed.keyboardvagabond.com 6 points 5 days ago* (last edited 5 days ago)

how do you know this off-hand? ffmpeg always felt like the most incantationest of all incantations to me

also, upvoted for good feedback

[-] savvywolf@pawb.social 3 points 5 days ago

I actually just Googled (well, Kagi'd) it, and found the article that the AI presumably hallucinated this command from.

[-] jubilationtcornpone@sh.itjust.works 69 points 5 days ago* (last edited 5 days ago)

10 minutes later...

divideMp4IntoNSegmentsOfLengthTButPleaseDoItCorrectlyThisTimePrettyPrettyPleaseJesusFuckWhyAreYouSoFuckingStupid(){
}
load more comments (9 replies)
[-] 6nk06@sh.itjust.works 48 points 5 days ago

I'm pretty sure the awful formatting of the comment is here to trigger us.

Anyway, merge request rejected for that alone.

load more comments (1 replies)
[-] abbadon420@sh.itjust.works 27 points 5 days ago

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.

[-] eager_eagle@lemmy.world 8 points 5 days ago* (last edited 4 days ago)

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

[-] NEILSON_MANDALA@lemmy.world 3 points 5 days ago

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"

[-] Lumidaub@feddit.org 8 points 5 days ago

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".

load more comments (14 replies)
load more comments (13 replies)

I mean, literally anything is possible if your codenase is fundamentally broken.

[-] schnurrito@discuss.tchncs.de 10 points 4 days ago

How can a function like this exist without parameters for N and T?

[-] NEILSON_MANDALA@lemmy.world 13 points 4 days ago

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.

[-] firelizzard@programming.dev 17 points 5 days ago

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).

[-] NEILSON_MANDALA@lemmy.world 5 points 5 days ago

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.

[-] BassTurd@lemmy.world 2 points 5 days ago

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

load more comments (2 replies)
[-] Corbin@programming.dev 5 points 5 days ago

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.

load more comments (1 replies)
[-] slazer2au@lemmy.world 3 points 5 days ago
load more comments (4 replies)
load more comments
view more: next ›
this post was submitted on 07 Jan 2026
89 points (74.1% liked)

Programmer Humor

28398 readers
1570 users here now

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

founded 2 years ago
MODERATORS