Mutant Bob
Mutant Bob

Reputation: 3549

How can I use gst-launch (gstreamer) to convert a .mp4 file into a .yuv (raw video i420) that is not missing frames?

I am having a problem with gstreamer truncating the yuv output of a gst-launch pipeline. The simplified example is

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

When I run this on an MP4 file with H.264 video at 7680x3840 for 600 frames it gives me a file that is 6280934400 bytes long. A quick bit of arithmetic 6280934400 / 7680 / 3840 / 600 = 0.3549609375 . That is a little over a third of a byte per pixel.

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

I am expecting 1.5 bytes per pixel (because format=I420).

If I instead run ffmpeg -i $input -c:v rawvideo -pix_fmt yuv420p $output then I get 26542080000 bytes which is 7680 * 3840 * 600 * 1.5 as expected.

My target pipeline is rather more complicated than this (projection remapping using GLSL), but I am hoping that if somebody can fix this trivial example it will fix my real pipeline too.

How can I build a gst-launch pipeline that properly converts a file to raw video without silently giving up 20% of the way through the job?

Upvotes: 0

Views: 3492

Answers (1)

Florian Zwoch
Florian Zwoch

Reputation: 7373

I think:

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

should be enough. Since the decoder should output I420 by default (unless it is a special profile). No need to parse the data afterwards (and actually may be the root of your problem as the internal width and height properties of that element are set to 320x240). You just want to dump whats coming from the decoder to disk.

Upvotes: 1

Related Questions