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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Kieran O Leary
Hello,

I posted a similar issue recently where an unknown SAR was declared as
1:1 when stream copied to matroska.

I think this is a different issue because the SAR is declared in the
source in this instance. I am running some tests on the xiph/derf
collection and found that a lot of the videos had different aspect
ratios when stream copied to matroska.

I am wondering if this is an issue with the Matroska specifcation or
some issue with ffmpeg. For what it's worth, I looked at the output
file in mediaconch and PixelWidth is listed as 176, and DisplayWidth
is listed as 193.

Source can be downloaded from here
https://media.xiph.org/video/derf/y4m/bus_qcif_15fps.y4m
Full command and output at the bottom of the email, but here's the key
details from the input:

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

and the output:

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)

2 outputs will follow:

1. Stream copy to Matroska
2. ffmpeg -i  of output file


1.

 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


Best,

Kieran.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

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

Carl Eugen Hoyos
Kieran O Leary <kieran.o.leary <at> gmail.com> writes:

> I posted a similar issue recently where an unknown SAR was
> declared as 1:1 when stream copied to matroska.

Allow me to repeat that this is not correct:
If SAR is unknown, no sar is written to mkv output (when
stream copied or reencoded).

The demuxer does indeed output a sar even if no sar was
specified in the mkv file. This could be changed but as
said, for 3D content with unspecified sar, the demuxer
would have to output sar, so the change would make the
behaviour less consistent.

> I think this is a different issue because the SAR is
> declared in the source in this instance. I am running some
> tests on the xiph/derf collection and found that a lot of
> the videos had different aspect ratios when stream copied
> to matroska.
>
> I am wondering if this is an issue with the Matroska
> specifcation or some issue with ffmpeg. For what it's worth,
> I looked at the output file in mediaconch and PixelWidth is
> listed as 176, and DisplayWidth is listed as 193.

Which - without really verifying myself! - are probably
the correct display dimensions for the given input.

I don't know why FFmpeg writes display dimensions instead
of DAR: My guess is that there are players which would
fill the screen if your input would be remuxed with dar
instead of display dimensions.
(Difficult to test with your use case since many video
players do not support rawvideo in mkv...)

Feel free to open a ticket.

> ffmpeg version N-44317-g7af44ce

Unrelated: I am curious how this version string gets created
(it should be "N-80980-g7af44ce"): What does the following
command show for you?
$ git describe --tags --match N

Thank you for the interesting report, Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

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

Kieran O Leary
Hi Carl,

Thanks for replying.

On Mon, Jul 25, 2016 at 9:47 AM, Carl Eugen Hoyos <[hidden email]> wrote:

> Which - without really verifying myself! - are probably
> the correct display dimensions for the given input.
>
> I don't know why FFmpeg writes display dimensions instead
> of DAR: My guess is that there are players which would
> fill the screen if your input would be remuxed with dar
> instead of display dimensions.
> (Difficult to test with your use case since many video
> players do not support rawvideo in mkv...)
>
> Feel free to open a ticket.

Will do. Let me know if any further info or testing should go into the
trac report. I think I should probably try to replicate in mkvmerge as
well.

>> ffmpeg version N-44317-g7af44ce
>
> Unrelated: I am curious how this version string gets created
> (it should be "N-80980-g7af44ce"): What does the following
> command show for you?
> $ git describe --tags --match N
>

I updated ffmpeg before seeing your email, but I think the issue may
persist. I use linuxbrew to compile ffmpeg on Ubuntu, so I'm not
cloning ffmpeg manually.
:~/.cache/Homebrew/ffmpeg--git$ git describe --tags --match N
N-44450-g71167f7



> Thank you for the interesting report, Carl Eugen

Best,

Kieran.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

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

Carl Eugen Hoyos
Kieran O Leary <kieran.o.leary <at> gmail.com> writes:

> > Feel free to open a ticket.
>
> Will do. Let me know if any further info or testing should
> go into the trac report.

I'd love to see a saner FFmpeg version string there
(but that's only me) ;-)

I originally wanted to suggest replicating with FFmpeg alone
(without an external source file) but feel free to use the
mentioned file.

> I updated ffmpeg before seeing your email, but I think the issue may
> persist. I use linuxbrew to compile ffmpeg on Ubuntu, so I'm not
> cloning ffmpeg manually.

That shouldn't make a difference (and it doesn't, it seems
your git binary is doing something differently).

> :~/.cache/Homebrew/ffmpeg--git$ git describe --tags --match N
> N-44450-g71167f7

What does the following show?
$ git --version

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

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

Kieran O Leary
On Mon, Jul 25, 2016 at 10:34 AM, Carl Eugen Hoyos <[hidden email]> wrote:

>
> I originally wanted to suggest replicating with FFmpeg alone
> (without an external source file) but feel free to use the
> mentioned file.
>

Do you mean that I should use -f lavfi to generate a sample? If so , I
can try to do this.

>
> What does the following show?
> $ git --version
>

git version 1.9.1

-Kieran.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

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

Carl Eugen Hoyos
Kieran O Leary <kieran.o.leary <at> gmail.com> writes:

> > I originally wanted to suggest replicating with FFmpeg alone
> > (without an external source file) but feel free to use the
> > mentioned file.
> >
>
> Do you mean that I should use -f lavfi to generate a sample? If
> so , I can try to do this.

I first thought so, now I am less sure...

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".