[FFmpeg-user] Raw YUV Conversion

Chema Gonzalez chema at berkeley.edu
Sat Sep 1 02:02:48 EEST 2018


I'm trying to convert a yuv file in nv12 format (semi-planar) to
yuv420p (planar).

```
$ ffmpeg -y -f rawvideo -pixel_format nv12 -s 1280x720 -i in.yuv -f
rawvideo -pixel_format yuv420p out.yuv
...
$ md5sum in.yuv out.yuv
5ca2d65e292fde88932165fef7bd068a  in.yuv
5ca2d65e292fde88932165fef7bd068a  out.yuv
```
Getting the same file out doesn't seem right to me.

If I increase the debug level, I see the output pixel format is not respected.

```
 $ ffmpeg -y -loglevel debug -f rawvideo -pixel_format nv12 -s
1280x720 -i in.yuv -f rawvideo -pixel_format yuv420p out.yuv
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the
FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1
--build-suffix=-ffmpeg --toolchain=hardened
--libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl
--enable-shared --disable-stripping --disable-decoder=libopenjpeg
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
--enable-libflite --enable-libfontconfig --enable-libfreetype
--enable-libfribidi --enable-libgme --enable-libgsm
--enable-libmodplug --enable-libmp3lame --enable-libopenjpeg
--enable-libopus --enable-libpulse --enable-librtmp
--enable-libschroedinger --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid
--enable-libzvbi --enable-openal --enable-opengl --enable-x11grab
--enable-libdc1394 --enable-libiec61883 --enable-libzmq
--enable-frei0r --enable-libx264 --enable-libopencv
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr
--extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl
--enable-shared --disable-stripping --disable-decoder=libopenjpeg
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libass
--enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
--enable-libflite --enable-libfontconfig --enable-libfreetype
--enable-libfribidi --enable-libgme --enable-libgsm
--enable-libmodplug --enable-libmp3lame --enable-libopenjpeg
--enable-libopus --enable-libpulse --enable-librtmp
--enable-libschroedinger --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid
--enable-libzvbi --enable-openal --enable-opengl --enable-x11grab
--enable-libdc1394 --enable-libiec61883 --enable-libzmq
--enable-frei0r --enable-libx264 --enable-libopencv --enable-version3
--disable-doc --disable-programs --disable-avdevice --disable-avfilter
--disable-avformat --disable-avresample --disable-postproc
--disable-swscale --enable-libopencore_amrnb
--enable-libopencore_amrwb --enable-libvo_aacenc
--enable-libvo_amrwbenc
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files)
with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set
logging level) with argument 'debug'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'rawvideo'.
Reading option '-pixel_format' ... matched as AVOption 'pixel_format'
with argument 'nv12'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or
abbreviation)) with argument '1280x720'.
Reading option '-i' ... matched as input url with argument 'in.yuv'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'rawvideo'.
Reading option '-pixel_format' ... matched as AVOption 'pixel_format'
with argument 'yuv420p'.
Reading option 'out.yuv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url in.yuv.
Applying option f (force format) with argument rawvideo.
Applying option s (set frame size (WxH or abbreviation)) with argument 1280x720.
Successfully parsed a group of options.
Opening an input file: in.yuv.
[rawvideo @ 0x6d50e0] Before avformat_find_stream_info() pos: 0 bytes
read:32768 seeks:0
[rawvideo @ 0x6d50e0] All info found
[rawvideo @ 0x6d50e0] Estimating duration from bitrate, this may be inaccurate
[rawvideo @ 0x6d50e0] After avformat_find_stream_info() pos: 1382400
bytes read:1382400 seeks:0 frames:1
Input #0, rawvideo, from 'in.yuv':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 276480 kb/s
    Stream #0:0, 1, 1/25: Video: rawvideo, 1 reference frame (NV12 /
0x3231564E), nv12, 1280x720, 1/25, 276480 kb/s, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output url out.yuv.
Applying option f (force format) with argument rawvideo.
Successfully parsed a group of options.
Opening an output file: out.yuv.
Successfully opened the file.
detected 24 logical cores
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'video_size' to
value '1280x720'
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'pix_fmt' to value '25'
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'sws_param' to
value 'flags=2'
[graph 0 input from stream 0:0 @ 0x83a320] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x83a320] w:1280 h:720 pixfmt:nv12
tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[AVFilterGraph @ 0x831ae0] query_formats: 3 queried, 2 merged, 0
already done, 0 delayed
Output #0, rawvideo, to 'out.yuv':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0, 0, 1/25: Video: rawvideo, 1 reference frame (NV12 /
0x3231564E), nv12, 1280x720, 1/25, q=2-31, 200 kb/s, 25 fps, 25 tbn,
25 tbc
    Metadata:
      encoder         : Lavc56.60.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Cliping frame in rate conversion by 0.000008
[output stream 0:0 @ 0x83d6c0] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
frame=    1 fps=0.0 q=-0.0 Lsize=    1350kB time=00:00:00.04
bitrate=276480.0kbits/s
video:1350kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.000000%
Input file #0 (in.yuv):
  Input stream #0:0 (video): 1 packets read (1382400 bytes); 1 frames decoded;
  Total: 1 packets (1382400 bytes) demuxed
Output file #0 (out.yuv):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1382400 bytes);
  Total: 1 packets (1382400 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x839c20] Statistics: 0 seeks, 43 writeouts
[AVIOContext @ 0x6dda00] Statistics: 1382400 bytes read, 0 seeks
```

I'm running HEAD as of today (aeb73c73e112130fe344529bebb71bca3d286cb9).

Thanks,
-Chema


More information about the ffmpeg-user mailing list