Opened 8 years ago

Closed 7 years ago

#5743 closed defect (fixed)

SAR changes when stream copying y4m video to Matroska when SAR is present in source

Reported by: kieranjol Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mkv aspect
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug: Y4m videos that are stream copied to Matroska can have a different SAR.

Input.y4m = Video: rawvideo (I420 / 0x30323449), yuv420p,
176x144, SAR 128:117 DAR 1408:1053

Out.mkv = Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p,
176x144, SAR 193:176 DAR 193:144

Raised on ffmpeg-user, Carl Eugen Hoyos asked me to file a ticket: https://lists.ffmpeg.org/pipermail/ffmpeg-user/2016-July/032774.html

How to reproduce: Source can be downloaded from here
https://media.xiph.org/video/derf/y4m/bus_qcif_15fps.y4m

%  ffmpeg -i bus_qcif_15fps.y4m -c copy out.mkv
ffmpeg version N-44317-g7af44ce Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration:
--prefix=/home/kieranjol/.linuxbrew/Cellar/ffmpeg/HEAD --enable-shared
--enable-pthreads --enable-gpl --enable-version3
--enable-hardcoded-tables --enable-avresample --cc=/usr/bin/gcc-4.8
--host-cflags='-Os -w -pipe -march=core2'
--host-ldflags='-L/home/kieranjol/.linuxbrew/lib
-Wl,--dynamic-linker=/home/kieranjol/.linuxbrew/lib/ld.so
-Wl,-rpath,/home/kieranjol/.linuxbrew/lib' --enable-libx264
--enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, yuv4mpegpipe, from 'bus_qcif_15fps.y4m':
  Duration: 00:00:05.00, start: 0.000000, bitrate: 4562 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p,
176x144, SAR 128:117 DAR 1408:1053, 15 fps, 15 tbr, 15 tbn, 15 tbc
File 'out.mkv' already exists. Overwrite ? [y/N] y
[matroska @ 0x21ba860] Using AVStream.codec to pass codec parameters
to muxers is deprecated, use AVStream.codecpar instead.
Output #0, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144
[SAR 128:117 DAR 1408:1053], q=2-31, 15 fps, 15 tbr, 1k tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   75 fps=0.0 q=-1.0 Lsize=    2788kB time=00:00:04.93
bitrate=4629.1kbits/s speed= 115x
video:2784kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.134154%


2.


ffmpeg -i out.mkv
ffmpeg version N-44317-g7af44ce Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration:
--prefix=/home/kieranjol/.linuxbrew/Cellar/ffmpeg/HEAD --enable-shared
--enable-pthreads --enable-gpl --enable-version3
--enable-hardcoded-tables --enable-avresample --cc=/usr/bin/gcc-4.8
--host-cflags='-Os -w -pipe -march=core2'
--host-ldflags='-L/home/kieranjol/.linuxbrew/lib
-Wl,--dynamic-linker=/home/kieranjol/.linuxbrew/lib/ld.so
-Wl,-rpath,/home/kieranjol/.linuxbrew/lib' --enable-libx264
--enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 50.100 / 57. 50.100
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from 'out.mkv':
  Metadata:
    ENCODER         : Lavf57.41.100
  Duration: 00:00:05.00, start: 0.000000, bitrate: 4568 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p,
176x144, SAR 193:176 DAR 193:144, 15 fps, 15 tbr, 1k tbn, 1k tbc
(default)
    Metadata:
      DURATION        : 00:00:05.000000000
At least one output file must be specified

Change History (3)

comment:1 by Carl Eugen Hoyos, 8 years ago

Component: undeterminedavformat
Keywords: mkv aspect added; matroska y4m SAR DAR removed
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Iirc the issue is also reproducible with -vcodec rawvideo.

comment:2 by kieranjol, 8 years ago

It is. I tried to reproduce the attributes of my y4m file with testsrc, but my -vf setsar option was altered. I asked for a sar of 128:117 but I got a SAR of 93:85 . Possibly something to do with yuv420p?
3 outputs:

  1. testsrc generation
  2. stream copy to matroska
  3. ffmpeg -i of out.mkv
  1. testsrc generation
fmpeg -f lavfi -i testsrc=size=176x144 -vf setsar=128:117 -pix_fmt yuv420p -t 1 out.y4m
ffmpeg version N-43802-g376d8fb Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-ffplay --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 49.100 /  6. 49.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc=size=176x144':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 176x144 [SAR 1:1 DAR 11:9], 25 tbr, 25 tbn, 25 tbc
File 'out.y4m' already exists. Overwrite ? [y/N] y
[Parsed_setsar_0 @ 0x7f831b600000] num:den syntax is deprecated, please use num/den or named options instead
[yuv4mpegpipe @ 0x7f831b812400] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, yuv4mpegpipe, to 'out.y4m':
  Metadata:
    encoder         : Lavf57.44.100
    Stream #0:0: Video: wrapped_avframe, yuv420p, 176x144 [SAR 93:85 DAR 341:255], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.51.100 wrapped_avframe
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-0.0 Lsize=     928kB time=00:00:01.00 bitrate=7604.9kbits/s speed= 181x    
video:12kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7691.885254%
  1. stream copy to matroska
ffmpeg -i out.y4m -c copy sar.mkv
ffmpeg version N-43802-g376d8fb Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-ffplay --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 49.100 /  6. 49.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, yuv4mpegpipe, from 'out.y4m':
  Duration: 00:00:01.00, start: 0.000000, bitrate: 7604 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, SAR 93:85 DAR 341:255, 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'sar.mkv' already exists. Overwrite ? [y/N] y
[matroska @ 0x7fa19882ac00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, matroska, to 'sar.mkv':
  Metadata:
    encoder         : Lavf57.44.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144 [SAR 93:85 DAR 341:255], q=2-31, 25 fps, 25 tbr, 1k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-1.0 Lsize=     930kB time=00:00:00.96 bitrate=7925.7kbits/s speed= 556x    
video:928kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.175610%
  1. ffmpeg -i of out.mkv
 ffmpeg -i sar.mkv 
ffmpeg version N-43802-g376d8fb Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-ffplay --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-vda
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 44.100 / 57. 44.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 49.100 /  6. 49.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from 'sar.mkv':
  Metadata:
    ENCODER         : Lavf57.44.100
  Duration: 00:00:01.00, start: 0.000000, bitrate: 7616 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, SAR 193:176 DAR 193:144, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:00:01.000000000
At least one output file must be specified
ifi-mac-pro:~ admin$ 


comment:3 by James, 7 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.