• NEILSON_MANDALA@lemmy.worldOP
    link
    fedilink
    arrow-up
    107
    ·
    edit-2
    3 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

      • NEILSON_MANDALA@lemmy.worldOP
        link
        fedilink
        arrow-up
        4
        ·
        3 days ago

        oh yeah, THAT line…trust me i know a MUCH more damaging one liner than the “remove french” one. it send an email from you to the secret service

        • mech@feddit.org
          link
          fedilink
          arrow-up
          19
          ·
          3 days ago

          How about one that can damage your speakers and your ears, without root access?

          ls -R / | aplay
          
          • emotional_soup_88@programming.dev
            link
            fedilink
            English
            arrow-up
            5
            ·
            3 days ago

            Haven’t checked my low level sound drivers in a long time - I’m using pipewire and wireplumber to control it all. Is ALSA still there at the bottom/as a dependency? Arch btw.

            • mech@feddit.org
              link
              fedilink
              arrow-up
              30
              ·
              edit-2
              3 days ago

              It doesn’t read it out.
              It just feeds the characters directly into your sound driver as raw data, which will play it as a cacophony of noise at max volume, with no regard for your speakers’ frequency limitations.

                • nocteb@feddit.org
                  link
                  fedilink
                  arrow-up
                  9
                  ·
                  3 days ago

                  Pull the master slider in alsamixer. I don’t think it will break anything anyway (except your ears if it’s loud). Most audio outputs are AC coupled meaning they will filter out DC and very low frequency which is the most dangerous part for a speaker.

              • squaresinger@lemmy.world
                link
                fedilink
                arrow-up
                2
                ·
                3 days ago

                I’d be very surprised if that was able to damage your speakers. If it could, then so could any sound you play. It would have to be an exceptionally bad design if playing a youtube video could destroy your speakers.

            • nocteb@feddit.org
              link
              fedilink
              arrow-up
              5
              ·
              3 days ago

              No it interprets the list of filenames as raw sound data which basically makes random noise maybe with a few bleeps when there are patterns

    • Arthur Besse@lemmy.ml
      link
      fedilink
      English
      arrow-up
      9
      ·
      3 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.worldOP
        link
        fedilink
        arrow-up
        7
        ·
        3 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