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

时间:2019-04-29 10:25:45

标签: video gstreamer gstreamer-1.0

我正在玩gstreamer命令行界面,并在从PNG图像创建mp4视频文件时卡住了。你们能帮忙解决这个问题吗?

我使用以下命令从摄像机创建了PNG图像:

  

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

我可以使用以下命令播放pPNG图像:

  

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

但是在从PNG图像创建mp4视频时,我从管道中收到了EOS:

  

将管道设置为PAUSED ...   管道正在预卷...   /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 = (字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/右翻转/半宽高比/混合单像素,像素长宽比=(分数)1/1,比色法=(字符串)sRGB,帧率=(分数)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 ,隔行模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右跌落/半纵横比/混合单像素像素纵横比=(分数)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 ,隔行模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右跌落/半纵横比/混合单像素像素纵横比=(分数)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 ,隔行模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右跌落/半纵横比/混合单像素像素纵横比=(分数)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 ,隔行模式=(字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(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:/右视图优先/左翻转/左翻转/右翻转/右翻转/半视角/混合-单声道,像素纵横比=(分数)1/1,比色法=(字符串)sRGB,帧率=(分数)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 = (字符串)逐行,多视图模式=(字符串)单声道,多视图标志=(GstVideoMultiviewFlagsSet)0:ffffffff:/右视图优先/左翻转/左翻转/右翻转/右翻转/右翻转/半宽高比/混合单像素,像素长宽比=(分数)1/1,比色法=(字符串)sRGB,帧率=(分数)0/1   /GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:src:caps = video / x-h264,codec_data =(buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440,流格式=(字符串),() ,配置文件=(字符串)高4:4:4,宽度=(整数)640,高度=(整数)480,像素长宽比=(分数)1/1,帧率=(分数)0/1,隔行扫描模式=(字符串)逐行,比色法=(字符串)bt601,色度位=(字符串)jpeg,多视图模式=(字符串)单声道,多视图标记=(GstVideoMultiviewFlagsSet)0:ffffffff:/ right-view-第一/左翻转/左翻转/右翻转/右翻转/半视角/混合单声道   /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstQTMuxPad:video_0:caps = video / x-h264,codec_data =(buffer)01f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440(string),string(align),string(level),string(align), ,配置文件=(字符串)高4:4:4,宽度=(整数)640,高度=(整数)480,像素长宽比=(分数)1/1,帧率=(分数)0/1,隔行扫描模式=(字符串)逐行,比色法=(字符串)bt601,色度位=(字符串)jpeg,多视图模式=(字符串)单声道,多视图标记=(GstVideoMultiviewFlagsSet)0:ffffffff:/ right-view-第一/左翻转/左翻转/右翻转/右翻转/半视角/混合单声道   /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src:caps = video / quicktime,variant =(string)iso   /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink:caps = video / quicktime,variant =(string)iso   管道已预磨...   将管道设置为PLAYING ...   新时钟:GstSystemClock   /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src:帽=视频/ QuickTime的,变体=(字符串)异,streamheader =(缓冲)<000003796d6f6f760000006c6d76686400000000d8ec7eeed8ec7eef00002710000000000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000002c87472616b0000005c746b686400000007d8ec7eeed8ec7eef000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000400000000280000001e0000000000024656474730000001c656c73740000000000000001000000000000000000010000000001e76d646961000000206d64686400000000d8ec7eeed8ec7eef000027100000000055c400000000002d68646c72000000000000000076696465000000000000000000000000566964656f48616e646c657200000001926d696e6600000014766d68640000000100000000000000000000002464696e660000001c6472656600000000000000010000000c75726c2000000001000001527374626c000000d2737473640000000000000001000000c2617663310000000000000 00100000000000000000000000000000000028001e0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff000000356176634301f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440000000146274727400000000002000000000000000000013636f6c726e636c78000600010006000000001070617370000000010000000100000018737474730000000000000001000000020000000000000014737473730000000000000001000000010000001c7374736300000000000000010000000100000002000000010000001c7374737a00000000000000000000000200002fc000000037000000147374636f0000000000000001000000300000005975647461000000516d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000024696c73740000001ca9746f6f00000014646174610000000100000000783236340000003d75647461000000356d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000008696c7374>   /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink:帽=视频/ QuickTime的,变体=(字符串)异,streamheader =(缓冲)<000003796d6f6f760000006c6d76686400000000d8ec7eeed8ec7eef00002710000000000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000002c87472616b0000005c746b686400000007d8ec7eeed8ec7eef000000010000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000400000000280000001e0000000000024656474730000001c656c73740000000000000001000000000000000000010000000001e76d646961000000206d64686400000000d8ec7eeed8ec7eef000027100000000055c400000000002d68646c72000000000000000076696465000000000000000000000000566964656f48616e646c657200000001926d696e6600000014766d68640000000100000000000000000000002464696e660000001c6472656600000000000000010000000c75726c2000000001000001527374626c000000d2737473640000000000000001000000c26176633100000000 0000000100000000000000000000000000000000028001e0004800000048000000000000000100000000000000000000000000000000000000000000000000000000000000000018ffff000000356176634301f4001effe1001c67f4001e919b281407b602d41804150000030001773594000f162d9601000668ebec448440000000146274727400000000002000000000000000000013636f6c726e636c78000600010006000000001070617370000000010000000100000018737474730000000000000001000000020000000000000014737473730000000000000001000000010000001c7374736300000000000000010000000100000002000000010000001c7374737a00000000000000000000000200002fc000000037000000147374636f0000000000000001000000300000005975647461000000516d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000024696c73740000001ca9746f6f00000014646174610000000100000000783236340000003d75647461000000356d657461000000000000002168646c72000000006d686c726d6469720000000000000000000000000000000008696c7374>   从元素“ pipeline0”获得了EOS。   0:00:00.814042926后执行结束   将管道设置为PAUSED ...   将管道设置为READY ...   将管道设置为NULL ...   正在释放管道……

1 个答案:

答案 0 :(得分:1)

要从png中创建mp4,可以使用以下管道:

  

gst-launch-1.0 -e multifilesrc location =“ frame%05d.png”
  caps =“ image / png,framerate = 30/1”! pngdec!视频转换!排队!   x264enc!排队! mp4mux! filesink location = image.mp4

注意:

  1. 如果您只需要60fps的视频,上面的视频将创建30fps的mp4 将multifilesrc中的大写更改为caps =“ image / png,framerate = 60/1” 播放60fps的视频。
  2. 如果您有任何特定的硬件,也可以更改编码器 编码器。