Manish
Manish

Reputation: 53

How to create a mp4 video file from PNG images using Gstreamer

I am playing with gstreamer command line interface and stuck while creating a mp4 video file from PNG images. Can you guys please help to resolve this.

Using below command I created PNG images from video camera:

gst-launch-1.0.exe -v ksvideosrc ! queue ! decodebin ! videoconvert ! pngenc ! multifilesink location="frame%05d.png"

I was able to play the pPNG images using below command:

gst-launch-1.0 -v multifilesrc location="frame%05d.png" index=0 ! pngdec ! glimagesink

But while creating a mp4 video from PNG images I received EOS from pipeline:

Setting pipeline to PAUSED ... Pipeline is PREROLLING ... /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src: caps = image/png /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstPngParse:pngparse0.GstPad:sink: caps = image/png /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstPngDec:pngdec0.GstPad:sink: caps = image/png, width=(int)640, height=(int)480 /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstPngParse:pngparse0.GstPad:src: caps = image/png, width=(int)640, height=(int)480 /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstPngDec:pngdec0.GstPad:src: caps = video/x-raw, format=(string)RGB, width=(int)640, height=(int)480, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)0/1 /GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)640, height=(int)480, framerate=(fraction)0/1, format=(string)Y444, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:src: caps = video/x-raw, width=(int)640, height=(int)480, framerate=(fraction)0/1, format=(string)Y444, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1 Redistribute latency... /GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:sink: caps = video/x-raw, width=(int)640, height=(int)480, framerate=(fraction)0/1, format=(string)Y444, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:sink: caps = video/x-raw, width=(int)640, height=(int)480, framerate=(fraction)0/1, format=(string)Y444, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)RGB, width=(int)640, height=(int)480, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)0/1 /GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstDecodePad:src_0.GstProxyPad:proxypad1: caps = video/x-raw, format=(string)RGB, width=(int)640, height=(int)480, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)0/1 /GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:src: caps = video/x-h264, codec_data=(buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440, stream-format=(string)avc, alignment=(string)au, level=(string)3, profile=(string)high-4:4:4, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, chroma-site=(string)jpeg, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstQTMuxPad:video_0: caps = video/x-h264, codec_data=(buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440, stream-format=(string)avc, alignment=(string)au, level=(string)3, profile=(string)high-4:4:4, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, chroma-site=(string)jpeg, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = video/quicktime, variant=(string)iso /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = video/quicktime, variant=(string)iso, streamheader=(buffer)< 000003796d6f6f760000006c6d76686400000000d8ec7eeed8ec7eef00002710000000000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000002c87472616b0000005c746b686400000007d8ec7eeed8ec7eef000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000400000000280000001e0000000000024656474730000001c656c73740000000000000001000000000000000000010000000001e76d646961000000206d64686400000000d8ec7eeed8ec7eef000027100000000055c400000000002d68646c72000000000000000076696465000000000000000000000000566964656f48616e646c657200000001926d696e6600000014766d68640000000100000000000000000000002464696e660000001c6472656600000000000000010000000c75726c2000000001000001527374626c000000d2737473640000000000000001000000c261766331000000000000000100000000000000000000000000000000028001e0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff000000356176634301f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440000000146274727400000000002000000000000000000013636f6c726e636c78000600010006000000001070617370000000010000000100000018737474730000000000000001000000020000000000000014737473730000000000000001000000010000001c7374736300000000000000010000000100000002000000010000001c7374737a00000000000000000000000200002fc000000037000000147374636f0000000000000001000000300000005975647461000000516d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000024696c73740000001ca9746f6f00000014646174610000000100000000783236340000003d75647461000000356d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000008696c7374 > /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso, streamheader=(buffer)< 000003796d6f6f760000006c6d76686400000000d8ec7eeed8ec7eef00002710000000000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000002c87472616b0000005c746b686400000007d8ec7eeed8ec7eef000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000400000000280000001e0000000000024656474730000001c656c73740000000000000001000000000000000000010000000001e76d646961000000206d64686400000000d8ec7eeed8ec7eef000027100000000055c400000000002d68646c72000000000000000076696465000000000000000000000000566964656f48616e646c657200000001926d696e6600000014766d68640000000100000000000000000000002464696e660000001c6472656600000000000000010000000c75726c2000000001000001527374626c000000d2737473640000000000000001000000c261766331000000000000000100000000000000000000000000000000028001e0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff000000356176634301f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440000000146274727400000000002000000000000000000013636f6c726e636c78000600010006000000001070617370000000010000000100000018737474730000000000000001000000020000000000000014737473730000000000000001000000010000001c7374736300000000000000010000000100000002000000010000001c7374737a00000000000000000000000200002fc000000037000000147374636f0000000000000001000000300000005975647461000000516d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000024696c73740000001ca9746f6f00000014646174610000000100000000783236340000003d75647461000000356d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000008696c7374 > Got EOS from element "pipeline0". Execution ended after 0:00:00.814042926 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline …

Upvotes: 1

Views: 4404

Answers (1)

Prabhakar Lad
Prabhakar Lad

Reputation: 1438

To create a mp4 out of your png's you could use the following pipeline :

gst-launch-1.0 -e multifilesrc location="frame%05d.png"
caps="image/png,framerate=30/1" ! pngdec ! videoconvert ! queue ! x264enc ! queue ! mp4mux ! filesink location=image.mp4

Note:

  1. The above would create a 30fps mp4, if you need a 60fps video just change the caps in multifilesrc to caps="image/png,framerate=60/1" for a 60fps video.
  2. Also you could change the encoder if you have any hardware specific encoder.

Upvotes: 2

Related Questions