代码之家  ›  专栏  ›  技术社区  ›  Mutant Bob

如何使用gst launch(gstreamer)将.mp4文件转换为不丢失帧的.yuv(原始视频i420)?

  •  0
  • Mutant Bob  · 技术社区  · 5 年前

    我在gstreamer截断gst启动管道的yuv输出时遇到问题。简化的例子是

    gst-launch-1.0 filesrc location="$input" \
                   ! decodebin \
                   ! 'video/x-raw, format=I420' \
                   ! rawvideoparse \
                   ! filesink location="$output" buffer-mode=2
    

    当我在一个MP4文件上运行它时,它的H.264视频为7680x3840,帧数为600帧,它给了我一个6280934400字节长的文件。算术快速位6280934400/7680/3840/600=0.3549609375。这是每像素三分之一字节多一点。

    Setting pipeline to PAUSED ...
    0:00:00.354592385 16438 0x555e06766b30 WARN                 basesrc gstbasesrc.c:3600:gst_base_src_start_complete:<filesrc0> pad not activated yet
    Pipeline is PREROLLING ...
    0:00:00.536788393 16438 0x7f3f90073680 WARN                 qtdemux qtdemux_types.c:239:qtdemux_type_get: unknown QuickTime node type uuid
    0:00:00.536830878 16438 0x7f3f90073680 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:<qtdemux0> failed to find fragment defaults for stream 1
    0:00:00.536861715 16438 0x7f3f90073680 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:<qtdemux0> failed to find fragment defaults for stream 2
    Redistribute latency...
    Redistribute latency...
    Pipeline is PREROLLED ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    0:01:11.471563917 16438 0x7f3f8000d4a0 WARN                   libav gstavauddec.c:628:gst_ffmpegauddec_drain:<avdec_aac0> send packet failed, could not drain decoder
    Got EOS from element "pipeline0".
    Execution ended after 0:01:10.085660675
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...
    

    如果我跑了 ffmpeg -i $input -c:v rawvideo -pix_fmt yuv420p $output 然后我得到26542080000字节,这是7680*3840*600*1.5。

    我的目标管道要比这个复杂得多(使用GLSL进行投影重映射),但我希望如果有人能修复这个微不足道的例子,它也能修复我真正的管道。

    我如何才能建立一个gst启动管道,正确地将文件转换成原始视频,而不需要默默地放弃20%的工作方式?

    0 回复  |  直到 5 年前
        1
  •  1
  •   Florian Zwoch    5 年前

    gst-launch-1.0 filesrc location="$input" \
                   ! decodebin \
                   ! filesink location="$output"
    

    应该够了。因为解码器在默认情况下应该输出I420(除非它是一个特殊的配置文件)。之后无需解析数据(实际上可能是问题的根源,因为该元素的内部宽度和高度属性设置为320x240)。你只想把解码器里的东西转储到磁盘上。