Fixing an unmuxed image/jpeg stream from webcam using gstreamer












0














I made a broken footage using the following pipeline:



gst-launch-1.0 v4l2src ! filesink location=encode.mjpeg


Somehow gstreamer can still play it back:



gst-launch-1.0 filesrc location=encode.mjpeg ! jpegdec ! videoconvert ! xvimagesink


However as I by mistake didn't use any container, the stream is played back at a very fast pace framerate=(fraction)0/1. Is there any way to convert my broken file into an .avi or any other container without recompression?



The following trivial muxing didn't work as expected:



gst-launch-1.0 filesrc location=encode.mjpeg 
! 'image/jpeg,framerate=30/1,width=1280,height=720' ! avimux
! filesink location=encode.avi . -v


Somehow gstreamer plays encode.avi back very slowly at ~1 FPS without consuming significant CPU. And neither Vlc` nor Adobe Aftereffects can import it - they only display a correctly decoded stipe of the first frame at the top.










share|improve this question





























    0














    I made a broken footage using the following pipeline:



    gst-launch-1.0 v4l2src ! filesink location=encode.mjpeg


    Somehow gstreamer can still play it back:



    gst-launch-1.0 filesrc location=encode.mjpeg ! jpegdec ! videoconvert ! xvimagesink


    However as I by mistake didn't use any container, the stream is played back at a very fast pace framerate=(fraction)0/1. Is there any way to convert my broken file into an .avi or any other container without recompression?



    The following trivial muxing didn't work as expected:



    gst-launch-1.0 filesrc location=encode.mjpeg 
    ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! avimux
    ! filesink location=encode.avi . -v


    Somehow gstreamer plays encode.avi back very slowly at ~1 FPS without consuming significant CPU. And neither Vlc` nor Adobe Aftereffects can import it - they only display a correctly decoded stipe of the first frame at the top.










    share|improve this question



























      0












      0








      0







      I made a broken footage using the following pipeline:



      gst-launch-1.0 v4l2src ! filesink location=encode.mjpeg


      Somehow gstreamer can still play it back:



      gst-launch-1.0 filesrc location=encode.mjpeg ! jpegdec ! videoconvert ! xvimagesink


      However as I by mistake didn't use any container, the stream is played back at a very fast pace framerate=(fraction)0/1. Is there any way to convert my broken file into an .avi or any other container without recompression?



      The following trivial muxing didn't work as expected:



      gst-launch-1.0 filesrc location=encode.mjpeg 
      ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! avimux
      ! filesink location=encode.avi . -v


      Somehow gstreamer plays encode.avi back very slowly at ~1 FPS without consuming significant CPU. And neither Vlc` nor Adobe Aftereffects can import it - they only display a correctly decoded stipe of the first frame at the top.










      share|improve this question















      I made a broken footage using the following pipeline:



      gst-launch-1.0 v4l2src ! filesink location=encode.mjpeg


      Somehow gstreamer can still play it back:



      gst-launch-1.0 filesrc location=encode.mjpeg ! jpegdec ! videoconvert ! xvimagesink


      However as I by mistake didn't use any container, the stream is played back at a very fast pace framerate=(fraction)0/1. Is there any way to convert my broken file into an .avi or any other container without recompression?



      The following trivial muxing didn't work as expected:



      gst-launch-1.0 filesrc location=encode.mjpeg 
      ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! avimux
      ! filesink location=encode.avi . -v


      Somehow gstreamer plays encode.avi back very slowly at ~1 FPS without consuming significant CPU. And neither Vlc` nor Adobe Aftereffects can import it - they only display a correctly decoded stipe of the first frame at the top.







      video-editing video-encoding gstreamer multiplexing mjpeg






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 17 '13 at 15:54









      Mathieu_Du

      1283




      1283










      asked Sep 17 '13 at 12:44









      nponeccop

      154114




      154114






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.



          This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert !
          <some encoder> ! <some muxer> ! filesink location=outputfile


          You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.



          Edit: To attempt to mux the content into avi without decoding, try something like:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux
          ! filesink location=encode.avi . -v


          If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.






          share|improve this answer























          • without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
            – nponeccop
            Sep 17 '13 at 17:40










          • If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
            – thiagoss
            Sep 18 '13 at 14:32











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fsuperuser.com%2fquestions%2f646523%2ffixing-an-unmuxed-image-jpeg-stream-from-webcam-using-gstreamer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.



          This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert !
          <some encoder> ! <some muxer> ! filesink location=outputfile


          You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.



          Edit: To attempt to mux the content into avi without decoding, try something like:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux
          ! filesink location=encode.avi . -v


          If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.






          share|improve this answer























          • without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
            – nponeccop
            Sep 17 '13 at 17:40










          • If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
            – thiagoss
            Sep 18 '13 at 14:32
















          0














          The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.



          This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert !
          <some encoder> ! <some muxer> ! filesink location=outputfile


          You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.



          Edit: To attempt to mux the content into avi without decoding, try something like:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux
          ! filesink location=encode.avi . -v


          If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.






          share|improve this answer























          • without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
            – nponeccop
            Sep 17 '13 at 17:40










          • If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
            – thiagoss
            Sep 18 '13 at 14:32














          0












          0








          0






          The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.



          This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert !
          <some encoder> ! <some muxer> ! filesink location=outputfile


          You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.



          Edit: To attempt to mux the content into avi without decoding, try something like:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux
          ! filesink location=encode.avi . -v


          If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.






          share|improve this answer














          The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.



          This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert !
          <some encoder> ! <some muxer> ! filesink location=outputfile


          You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.



          Edit: To attempt to mux the content into avi without decoding, try something like:



          gst-launch-1.0 filesrc location=encode.mjpeg 
          ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux
          ! filesink location=encode.avi . -v


          If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 18 '13 at 14:31

























          answered Sep 17 '13 at 17:07









          thiagoss

          1011




          1011












          • without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
            – nponeccop
            Sep 17 '13 at 17:40










          • If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
            – thiagoss
            Sep 18 '13 at 14:32


















          • without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
            – nponeccop
            Sep 17 '13 at 17:40










          • If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
            – thiagoss
            Sep 18 '13 at 14:32
















          without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
          – nponeccop
          Sep 17 '13 at 17:40




          without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc.
          – nponeccop
          Sep 17 '13 at 17:40












          If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
          – thiagoss
          Sep 18 '13 at 14:32




          If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue>
          – thiagoss
          Sep 18 '13 at 14:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


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





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fsuperuser.com%2fquestions%2f646523%2ffixing-an-unmuxed-image-jpeg-stream-from-webcam-using-gstreamer%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

          Probability when a professor distributes a quiz and homework assignment to a class of n students.

          Aardman Animations

          Are they similar matrix