How to splice sections of a video with avconv?












6















I have figured out so far that you can cut a section from a video with avconv with a command like this (cuts from 1:00-3:00):



avconv -ss 00:01:00 -i "input.avi" -t 00:02:00 -c:v libx264 -crf 23 "output.mp4"


But how would I cut two (or more) sections from the video and combine them into one video? For example, taking 1:00-3:00 as above, plus 8:00-10:00, making a final 4 minute video.



I guess I can do them separately then concatenate them, but is there a simpler way?










share|improve this question























  • Did you ever figure this out? I'm interested in doing exactly the same

    – Benoir
    Jul 3 '15 at 4:12











  • @Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

    – DisgruntledGoat
    Jul 4 '15 at 22:08
















6















I have figured out so far that you can cut a section from a video with avconv with a command like this (cuts from 1:00-3:00):



avconv -ss 00:01:00 -i "input.avi" -t 00:02:00 -c:v libx264 -crf 23 "output.mp4"


But how would I cut two (or more) sections from the video and combine them into one video? For example, taking 1:00-3:00 as above, plus 8:00-10:00, making a final 4 minute video.



I guess I can do them separately then concatenate them, but is there a simpler way?










share|improve this question























  • Did you ever figure this out? I'm interested in doing exactly the same

    – Benoir
    Jul 3 '15 at 4:12











  • @Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

    – DisgruntledGoat
    Jul 4 '15 at 22:08














6












6








6


3






I have figured out so far that you can cut a section from a video with avconv with a command like this (cuts from 1:00-3:00):



avconv -ss 00:01:00 -i "input.avi" -t 00:02:00 -c:v libx264 -crf 23 "output.mp4"


But how would I cut two (or more) sections from the video and combine them into one video? For example, taking 1:00-3:00 as above, plus 8:00-10:00, making a final 4 minute video.



I guess I can do them separately then concatenate them, but is there a simpler way?










share|improve this question














I have figured out so far that you can cut a section from a video with avconv with a command like this (cuts from 1:00-3:00):



avconv -ss 00:01:00 -i "input.avi" -t 00:02:00 -c:v libx264 -crf 23 "output.mp4"


But how would I cut two (or more) sections from the video and combine them into one video? For example, taking 1:00-3:00 as above, plus 8:00-10:00, making a final 4 minute video.



I guess I can do them separately then concatenate them, but is there a simpler way?







ffmpeg video-editing avconv






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 31 '12 at 0:46









DisgruntledGoatDisgruntledGoat

4821512




4821512













  • Did you ever figure this out? I'm interested in doing exactly the same

    – Benoir
    Jul 3 '15 at 4:12











  • @Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

    – DisgruntledGoat
    Jul 4 '15 at 22:08



















  • Did you ever figure this out? I'm interested in doing exactly the same

    – Benoir
    Jul 3 '15 at 4:12











  • @Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

    – DisgruntledGoat
    Jul 4 '15 at 22:08

















Did you ever figure this out? I'm interested in doing exactly the same

– Benoir
Jul 3 '15 at 4:12





Did you ever figure this out? I'm interested in doing exactly the same

– Benoir
Jul 3 '15 at 4:12













@Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

– DisgruntledGoat
Jul 4 '15 at 22:08





@Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...

– DisgruntledGoat
Jul 4 '15 at 22:08










3 Answers
3






active

oldest

votes


















0














I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.



If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:



mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4





share|improve this answer

































    0














    ffmpeg already has an option called concatenate.
    It works with most formats, not just for mpg files.



    You can find instructions in the ffmpeg wiki.






    share|improve this answer

































      -1














      For combining videos use:



      cat video1 video2 > video3


      Click here for more info.



      If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.



      For the whole process of cutting and combining videos maybe you need a script like this:



      #! /bin/bash
      folder="/home/user/path-to-folder"
      input="input.avi"
      out1="1.mp4"
      out2="2.mp4"
      combine="3.mp4"

      cd $folder

      avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
      avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
      # add as many lines as you like

      cat $out1 $out2 > $combine


      You only have to change the names of variables at the start of the script.



      Also You could try MENCODER for joining videos:



      mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi





      share|improve this answer





















      • 3





        Simply concatenating files doesn't work for most video formats AFAIK...

        – DisgruntledGoat
        Nov 20 '12 at 0:16






      • 1





        @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

        – Janus Troelsen
        Jul 25 '13 at 11:40











      • Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

        – peterph
        Oct 10 '14 at 18:46











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53387%2fhow-to-splice-sections-of-a-video-with-avconv%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.



      If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:



      mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4





      share|improve this answer






























        0














        I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.



        If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:



        mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4





        share|improve this answer




























          0












          0








          0







          I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.



          If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:



          mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4





          share|improve this answer















          I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.



          If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:



          mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 5 '15 at 23:02









          roaima

          43.9k555118




          43.9k555118










          answered Sep 5 '15 at 22:54









          TiberiusKirkTiberiusKirk

          613




          613

























              0














              ffmpeg already has an option called concatenate.
              It works with most formats, not just for mpg files.



              You can find instructions in the ffmpeg wiki.






              share|improve this answer






























                0














                ffmpeg already has an option called concatenate.
                It works with most formats, not just for mpg files.



                You can find instructions in the ffmpeg wiki.






                share|improve this answer




























                  0












                  0








                  0







                  ffmpeg already has an option called concatenate.
                  It works with most formats, not just for mpg files.



                  You can find instructions in the ffmpeg wiki.






                  share|improve this answer















                  ffmpeg already has an option called concatenate.
                  It works with most formats, not just for mpg files.



                  You can find instructions in the ffmpeg wiki.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 11 mins ago









                  anonymoose

                  1034




                  1034










                  answered Jun 23 '17 at 16:38









                  Mario G.Mario G.

                  913




                  913























                      -1














                      For combining videos use:



                      cat video1 video2 > video3


                      Click here for more info.



                      If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.



                      For the whole process of cutting and combining videos maybe you need a script like this:



                      #! /bin/bash
                      folder="/home/user/path-to-folder"
                      input="input.avi"
                      out1="1.mp4"
                      out2="2.mp4"
                      combine="3.mp4"

                      cd $folder

                      avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
                      avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
                      # add as many lines as you like

                      cat $out1 $out2 > $combine


                      You only have to change the names of variables at the start of the script.



                      Also You could try MENCODER for joining videos:



                      mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi





                      share|improve this answer





















                      • 3





                        Simply concatenating files doesn't work for most video formats AFAIK...

                        – DisgruntledGoat
                        Nov 20 '12 at 0:16






                      • 1





                        @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                        – Janus Troelsen
                        Jul 25 '13 at 11:40











                      • Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                        – peterph
                        Oct 10 '14 at 18:46
















                      -1














                      For combining videos use:



                      cat video1 video2 > video3


                      Click here for more info.



                      If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.



                      For the whole process of cutting and combining videos maybe you need a script like this:



                      #! /bin/bash
                      folder="/home/user/path-to-folder"
                      input="input.avi"
                      out1="1.mp4"
                      out2="2.mp4"
                      combine="3.mp4"

                      cd $folder

                      avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
                      avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
                      # add as many lines as you like

                      cat $out1 $out2 > $combine


                      You only have to change the names of variables at the start of the script.



                      Also You could try MENCODER for joining videos:



                      mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi





                      share|improve this answer





















                      • 3





                        Simply concatenating files doesn't work for most video formats AFAIK...

                        – DisgruntledGoat
                        Nov 20 '12 at 0:16






                      • 1





                        @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                        – Janus Troelsen
                        Jul 25 '13 at 11:40











                      • Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                        – peterph
                        Oct 10 '14 at 18:46














                      -1












                      -1








                      -1







                      For combining videos use:



                      cat video1 video2 > video3


                      Click here for more info.



                      If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.



                      For the whole process of cutting and combining videos maybe you need a script like this:



                      #! /bin/bash
                      folder="/home/user/path-to-folder"
                      input="input.avi"
                      out1="1.mp4"
                      out2="2.mp4"
                      combine="3.mp4"

                      cd $folder

                      avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
                      avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
                      # add as many lines as you like

                      cat $out1 $out2 > $combine


                      You only have to change the names of variables at the start of the script.



                      Also You could try MENCODER for joining videos:



                      mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi





                      share|improve this answer















                      For combining videos use:



                      cat video1 video2 > video3


                      Click here for more info.



                      If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.



                      For the whole process of cutting and combining videos maybe you need a script like this:



                      #! /bin/bash
                      folder="/home/user/path-to-folder"
                      input="input.avi"
                      out1="1.mp4"
                      out2="2.mp4"
                      combine="3.mp4"

                      cd $folder

                      avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
                      avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
                      # add as many lines as you like

                      cat $out1 $out2 > $combine


                      You only have to change the names of variables at the start of the script.



                      Also You could try MENCODER for joining videos:



                      mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 29 '13 at 0:58

























                      answered Nov 19 '12 at 19:13









                      ispasovispasov

                      85413




                      85413








                      • 3





                        Simply concatenating files doesn't work for most video formats AFAIK...

                        – DisgruntledGoat
                        Nov 20 '12 at 0:16






                      • 1





                        @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                        – Janus Troelsen
                        Jul 25 '13 at 11:40











                      • Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                        – peterph
                        Oct 10 '14 at 18:46














                      • 3





                        Simply concatenating files doesn't work for most video formats AFAIK...

                        – DisgruntledGoat
                        Nov 20 '12 at 0:16






                      • 1





                        @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                        – Janus Troelsen
                        Jul 25 '13 at 11:40











                      • Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                        – peterph
                        Oct 10 '14 at 18:46








                      3




                      3





                      Simply concatenating files doesn't work for most video formats AFAIK...

                      – DisgruntledGoat
                      Nov 20 '12 at 0:16





                      Simply concatenating files doesn't work for most video formats AFAIK...

                      – DisgruntledGoat
                      Nov 20 '12 at 0:16




                      1




                      1





                      @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                      – Janus Troelsen
                      Jul 25 '13 at 11:40





                      @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f

                      – Janus Troelsen
                      Jul 25 '13 at 11:40













                      Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                      – peterph
                      Oct 10 '14 at 18:46





                      Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.

                      – peterph
                      Oct 10 '14 at 18:46


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53387%2fhow-to-splice-sections-of-a-video-with-avconv%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      濃尾地震

                      How to rewrite equation of hyperbola in standard form

                      No ethernet ip address in my vocore2