简体   繁体   English

如何使用Gstreamer从PNG图像创建mp4视频文件

[英]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. 我正在玩gstreamer命令行界面,并在从PNG图像创建mp4视频文件时卡住了。 Can you guys please help to resolve this. 你们能帮忙解决这个问题吗?

Using below command I created PNG images from video camera: 使用以下命令,我从摄像机创建了PNG图像:

gst-launch-1.0.exe -v ksvideosrc ! gst-launch-1.0.exe -v ksvideosrc! queue ! 排队! decodebin ! 解码器! videoconvert ! 视频转换! pngenc ! pngenc! multifilesink location="frame%05d.png" multifilesink location =“ frame%05d.png”

I was able to play the pPNG images using below command: 我可以使用以下命令播放pPNG图像:

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

But while creating a mp4 video from PNG images I received EOS from pipeline: 但是,当从PNG图像创建mp4视频时,我从管道中收到了EOS:

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/GstVideo 将管道设置为PAUSED ...管道正在预修... /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src:caps = image / png / GstPipeline:pipeline0 / GstDecodeBin:decodebin0 / GstPngParse:pngPased。下沉:caps = image / png /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstPngDec:pngdec0.GstPad:sink:caps = image / png,width =(int)640,height =(int)480 / GstPipeline:pipeline0 / GstDecodeBin: encodebin0 / 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,隔行扫描模式=(string)逐行,multiview-mode =(string)mono,multiview-flags =(GstVideoMultiviewFlagsSet) 0:ffffffff:/右视优先/左翻转/左翻转/右翻转/右翻转/半纵横/混合单,像素纵横比=(分数)1/1,色度= (string)sRGB,framerate =(fraction)0/1 / GstPipeline:pipeline0 / GstVideo Convert: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 Convert:videoconvert0.GstPad:src:caps = video / x-raw,width =(int)640,height =(int)480,framerate =(fraction)0/1,format =(string)Y444,interlace-mode = (字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/右翻转/半长宽比/混合单像素,像素长宽比=(分数)1/1 /GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:src:caps = video / x-raw,width =(int)640,height =(int )480,帧率=(分数)0/1,格式=(字符串)Y444,隔行扫描模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/ right -view-first / left-flipped / left-flop / right-flipped / right-flop / half-aspect / mixed-mono,pixel-aspect-ratio =(fraction)1/1重新分配延迟... / GstPipeline:pipeline0 /GstX264Enc:x264enc0.GstPad:sink:caps = video / x-raw,width =(int)640,height =(int)480,framerate =(fraction)0/1,format =(string)Y444,隔行扫描模式=(字符串)渐进 , 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=(fract ,multiview-mode =(string)mono,multiview-flags =(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/半视角/混合-单声道,像素纵横比=(分数)1/1 / GstPipeline:管道0 / GstVideoRate:videorate0.GstPad:sink:caps = video / x-raw,width =(int)640,height =(int)480,framerate =(分数)0/1,格式=(字符串)Y444,隔行扫描模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标记=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/半纵横/混合单像素,像素纵横比=(分数)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:/右视图优先/左翻转/左翻转/右翻转/右翻转/半视角/混合单声道,像素纵横比=(分数 ion)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=(st 离子)1/1,比色法=(字符串)sRGB,帧率=(分数)0/1 / GstPipeline:管道0 / GstDecodeBin:decodebin0.GstDecodePad:src_0.GstProxyPad:proxypad1:caps = video / x-raw,format =(string )RGB,宽度=(int)640,高度=(int)480,隔行扫描模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标记=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图-第一个/左翻转/左翻转/右翻转/右翻转/半纵横/混合单像素像素纵横比=(分数)1/1,比色法=(字符串)sRGB,帧率=(分数)0/1 /GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:src:caps = video / x-h264,codec_data =(buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440,字符串,水平) =(字符串)3,轮廓=(字符串)高4:4:4,宽度=(整数)640,高度=(整数)480,像素长宽比=(分数)1/1,帧率=(分数)0/1,隔行扫描模式=(字符串)逐行,比色法=(字符串)bt601,色度位=(字符串)jpeg,多视图模式=(st ring)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=(strin ring)mono,multiview-flags =(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/半视角/混合单声道/ GstPipeline:pipeline0 / GstMP4Mux:mp4mux0.GstQTMuxPad:video_0:caps = video / x-h264,codec_data = {buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440,stream-format = {string)avc,level = {string)高4:4:4,宽度=(整数)640,高度=(整数)480,像素长宽比=(分数)1/1,帧率=(分数)0/1,隔行扫描模式=(字符串)渐进式,色度=(字符串)bt601,色度位=(字符串)jpeg,多视图模式=(字符串)单声道,多视图标记=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/ left-flopd / 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 =(strin g)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)< > /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso, streamheader=(buffer)< > Got EOS from element "pipeline0". g)iso管道已预卷...正在设置管道以进行播放...新时钟:GstSystemClock /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src:caps = video / quicktime,variant =(string)iso,streamheader =(buffer )<> /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink:caps = video / quicktime,variant =(string)iso,streamheader =(buffer)<>从元素“ pipeline0”获得了EOS。 Execution ended after 0:00:00.814042926 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline … 0:00:00.814042926之后执行结束。将管道设置为PAUSED ...将管道设置为READY ...将管道设置为NULL ...释放管道...

To create a mp4 out of your png's you could use the following pipeline : 要从png中创建mp4,可以使用以下管道:

gst-launch-1.0 -e multifilesrc location="frame%05d.png" gst-launch-1.0 -e multifilesrc location =“ frame%05d.png”
caps="image/png,framerate=30/1" ! caps =“ image / png,framerate = 30/1”! pngdec ! pngdec! videoconvert ! 视频转换! queue ! 排队! x264enc ! x264enc! queue ! 排队! mp4mux ! mp4mux! filesink location=image.mp4 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. 上面的代码会创建30fps的mp4,如果您需要60fps的视频,只需将multifilesrc中的caps更改为caps =“ image / png,framerate = 60/1”即可获取60fps的视频。
  2. Also you could change the encoder if you have any hardware specific encoder. 如果您有任何特定于硬件的编码器,也可以更改编码器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用ffmpeg从硬盘上的一批图像压缩和创建mp4视频文件? - How can I compress and create mp4 video file from batch of images on hard disk using ffmpeg? 来自一组png图像的python imageio mp4视频 - python imageio mp4 video from a set of png images 如何通过gstreamer将RTSP视频流保存到MP4文件? - How to save a RTSP video stream to MP4 file via gstreamer? 如何从 mp4 视频创建 .mpd mpeg dash 文件 - how to create .mpd mpeg dash File from mp4 video 如何在Windows Phone 8上从视频文件(.mp4)创建缩略图? - How to create Thumbnail from video file(.mp4) on Windows Phone 8? 如何使用appsScript Google从数组png生成视频mp4 - How generate video mp4 from array png with appsScript Google 如何将.MP4视频与.WAV音频结合使用命令行参数中的ffmpeg创建新的.MP4视频? - How to combine a .MP4 video with a .WAV audio to create a new .MP4 video using ffmpeg from command line arguments? 在 opencv 中使用 video.write 从图像创建 mp4 文件 - Creating an mp4 file from images using video.write in opencv 仅播放.mp4文件中的视频时,Gstreamer管道停止了 - Gstreamer pipeline stopped while playing only video from .mp4 file 使用GStreamer播放mp4文件时同步音频和视频 - Sync audio and video when playing mp4 file with GStreamer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM