Eu recebo proporção incorreta para imagens e vídeo convertidos usando o ffmpeg

1

Estou tentando converter alguns arquivos de filmes antigos em imagens (e depois reencodificá-las como h.264). O problema é que as imagens resultantes são esticadas verticalmente.

Aqui está o comando ffmpeg:

ffmpeg -i preview.mpg -filter_complex "[0:v]fps=fps=1[onepersec]; [onepersec]scale=min(200\, iw):-2[rescaled]" -map "[rescaled]" -f image2 image%4d.jpg

Eu tenho um palpite: o filtro scale , conforme eu o uso, ignora a proporção de exibição DAR e simplesmente dimensiona os valores de pixel. Eu quero que a largura das imagens seja de, no máximo, 200 pixels, e a altura pode ser o que for preciso, desde que pareça correta, ou seja, não esticada.

Como devo converter o arquivo de filme para obter imagens (e vídeos codificados novamente) que não parecem esticados?

Informações adicionais sobre o arquivo de vídeo:

No VLC, ele é reproduzido com boa aparência. Parece uma proporção normal de 4: 3. VLC exibe o seguinte em Current media information > Codec :

Stream 0
Type: Video
Codec: MPEG-1/2 Video (mpgv)
Resolution: 352x576
Frame rate: 25
Decoded format: Planar 4:2:0 YUV

Aqui está a saída da execução do comando ffmpeg acima:

ffmpeg version git-2014-07-24-f753956 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 24 2014 13:39:56 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
  configuration: --prefix=/home/somename/ffmpeg_build --extra-cflags=-I/home/somename/ffmpeg_build/include --extra-ldflags=-L/home/somename/ffmpeg_build/lib --bindir=/home/somename/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3la
me --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-libspeex --enable-libtheora
  libavutil      52. 92.101 / 52. 92.101
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 49.100 / 55. 49.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.102 /  4. 11.102
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'preview.mpg':
  Duration: 00:14:23.59, start: 1.646067, bitrate: 2244 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 352x576 [SAR 24:11 DAR 4:3], max. 2500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s
[swscaler @ 0x3f6fae0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'image%4d.jpg':
  Metadata:
    encoder         : Lavf55.49.100
    Stream #0:0: Video: mjpeg, yuvj420p, 200x328 [SAR 164:75 DAR 4:3], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
    Metadata:
      encoder         : Lavc55.69.100 mjpeg
Stream mapping:
  Stream #0:1 (mpeg2video) -> fps
  scale -> Stream #0:0 (mjpeg)
Press [q] to stop, [?] for help
frame=   41 fps=0.0 q=1.6 size=N/A time=00:00:41.00 bitrate=N/A    ^Mframe=   80 fps= 79 q=1.6 size=N/A time=00:01:20.00 bitrate=N/A    ^Mframe=  125 fps= 71 q=1.6 size=N/A time=00:02:05.00 bitrate=N/A    ^Mframe=  156 fps= 69 q=1.6 size=N/A time=00:02:36.00 bitrate=N/A    ^Mframe=  203 fps= 74 q=1.6 size=N/A time=00:03:23.00 bitrate=N/A    ^Mframe=  248 fps= 76 q=1.6 size=N/A time=00:04:08.00 bitrate=N/A    ^Mframe=  295 fps= 79 q=1.6 size=N/A time=00:04:55.00 bitrate=N/A    ^Mframe=  336 fps= 79 q=1.6 size=N/A time=00:05:36.00 bitrate=N/A    ^Mframe=  377 fps= 79 q=1.6 size=N/A time=00:06:17.00 bitrate=N/A    ^Mframe=  424 fps= 81 q=1.6 size=N/A time=00:07:04.00 bitrate=N/A    ^Mframe=  465 fps= 81 q=1.6 size=N/A time=00:07:45.00 bitrate=N/A    ^Mframe=  508 fps= 81 q=1.6 size=N/A time=00:08:28.00 bitrate=N/A    ^Mframe=  547 fps= 79 q=1.6 size=N/A time=00:09:07.00 bitrate=N/A    ^Mframe=  580 fps= 78 q=1.6 size=N/A time=00:09:40.00 bitrate=N/A    ^Mframe=  621 fps= 79 q=1.6 size=N/A time=00:10:21.00 bitrate=N/A    ^Mframe=  665 fps= 79 q=1.6 size=N/A time=00:11:05.00 bitrate=N/A    ^Mframe=  709 fps= 80 q=1.6 size=N/A time=00:11:49.00 bitrate=N/A    ^Mframe=  746 fps= 79 q=1.6 size=N/A time=00:12:26.00 bitrate=N/A    ^Mframe=  794 fps= 80 q=1.6 size=N/A time=00:13:14.00 bitrate=N/A
^Mframe=  833 fps= 80 q=1.6 size=N/A time=00:13:53.00 bitrate=N/A    ^Mframe=  865 fps= 81 q=1.6 Lsize=N/A time=00:14:25.00 bitrate=N/A
video:11118kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Talvez eu precise fazer algo sobre [swscaler @ 0x3f6fae0] formato de pixel reprovado usado, verifique se você definiu o intervalo corretamente ?

Aqui está a saída de mediainfo :

$ mediainfo preview.mpg
General
Complete name                            : /[...]/preview.mpg
Format                                   : MPEG-PS
File size                                : 231 MiB
Duration                                 : 14mn 23s
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 244 Kbps

Video
ID                                       : 224 (0xE0)
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : Main@Main
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Custom
Format settings, GOP                     : M=2, N=12
Duration                                 : 14mn 23s
Bit rate mode                            : Variable
Bit rate                                 : 1 943 Kbps
Maximum bit rate                         : 2 500 Kbps
Width                                    : 352 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 25.000 fps
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.383
Time code of first frame                 : 00:00:00:12
Time code source                         : Group of pictures header
Stream size                              : 200 MiB (87%)

Audio
ID                                       : 189 (0xBD)-128 (0x80)
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Muxing mode                              : DVD-Video
Duration                                 : 14mn 23s
Bit rate mode                            : Constant
Bit rate                                 : 256 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : -31ms
Stream size                              : 26.3 MiB (11%)

Menu

Aqui está a saída de ffprobe :

$ ffprobe preview.mpg
ffprobe version git-2014-07-24-f753956 Copyright (c) 2007-2014 the FFmpeg developers
  built on Jul 24 2014 13:39:56 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
  configuration: --prefix=/home/sadmin/ffmpeg_build --extra-cflags=-I/home/somename/ffmpeg_build/include --extra-ldflags=-L/home/somename/ffmpeg_build/lib --bindir=/home/somename/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-libspeex --enable-libtheora
  libavutil      52. 92.101 / 52. 92.101
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 49.100 / 55. 49.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.102 /  4. 11.102
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'preview.mpg':
  Duration: 00:14:23.59, start: 1.646067, bitrate: 2244 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 352x576 [SAR 24:11 DAR 4:3], max. 2500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s
Unsupported codec with id 1145979222 for input stream 0
$

Aqui, o texto Codec não suportado com o ID 1145979222 para o fluxo de entrada 0 é destacado. Eu acho que é sobre Stream #0.0 (?) Que eu não preciso.

Aqui está o que eu recebo para uma das imagens:

$ ffprobe image0001.jpg
ffprobe version git-2014-07-24-f753956 Copyright (c) 2007-2014 the FFmpeg developers
  built on Jul 24 2014 13:39:56 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
  configuration: --prefix=/home/somename/ffmpeg_build --extra-cflags=-I/home/somename/ffmpeg_build/include --extra-ldflags=-L/home/somename/ffmpeg_build/lib --bindir=/home/somename/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-libspeex --enable-libtheora
  libavutil      52. 92.101 / 52. 92.101
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 49.100 / 55. 49.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.102 /  4. 11.102
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
[mjpeg @ 0x24c7e40] ignoring invalid SAR: 164/75
Input #0, image2, from 'mov0001.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg), 200x328, 25 tbr, 25 tbn, 25 tbc

Interessante aqui pode ser [mjpeg @ 0x24c7e40] ignorando o SAR inválido: 164/75 mas o que isso significa?

    
por tomsv 08.09.2014 / 14:07

0 respostas