ffmpeg 更改宽高比未成功

Ngo*_*ral 2 ffmpeg

我正在尝试更改视频的宽高比,因为它以错误的方式显示(它应该是 16:9,但显示为 3:4)。我尝试了很多方法,但没有一个有效。例如,我尝试设置 SAR,但它改变了 DAR,因此纵横比保持不变。这是一个例子:

ffmpeg -y -i rtmp://localhost/in/air-hdmi -vf "setsar=sar=16/9" -f flv rtmp://localhost/in/ngoraltestffmpeg 


    ffmpeg version N-80388-gfd1d84b Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --prefix=/home/anastasia/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/anastasia/ffmpeg_build/include --extra-ldflags=-L/home/anastasia/ffmpeg_build/lib --bindir=/home/anastasia/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 46.100 / 57. 46.100
  libavformat    57. 38.101 / 57. 38.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.101 /  6. 46.101
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100

[flv @ 0x38143c0] audio stream discovered after head already parsed
[aac @ 0x3818f20] element type mismatch 1 != 0
[flv @ 0x38143c0] video stream discovered after head already parsed
Input #0, flv, from 'rtmp://localhost/in/air-hdmi':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 720
    displayHeight   : 576
    fps             : 0
    profile         : 
    level           : 
  Duration: 00:00:00.00, start: 181748.084000, bitrate: N/A
    Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp
    Stream #0:1: Video: h264 (High), yuv420p, 720x576, 25 fps, 25 tbr, 1k tbn, 50 tbc
[flv @ 0x39bf5a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, flv, to 'rtmp://localhost/in/ngoraltest':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 720
    displayHeight   : 576
    fps             : 0
    profile         : 
    level           : 
    encoder         : Lavf57.38.101
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 16:9 DAR 20:9], q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.46.100 flv
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp
    Metadata:
      encoder         : Lavc57.46.100 libmp3lame
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> flv1 (flv))
  Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[aac @ 0x3a37000] element type mismatch 1 != 0
    Last message repeated 7 times
[flv @ 0x39bf5a0] Failed to update header with correct duration.ate= 942.7kbits/s speed=2.37x    
[flv @ 0x39bf5a0] Failed to update header with correct filesize.
frame=  112 fps= 48 q=31.0 Lsize=     633kB time=00:00:05.18 bitrate= 999.9kbits/s speed=2.23x    
video:546kB audio:82kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.846813%
Exiting normally, received signal 2.
Run Code Online (Sandbox Code Playgroud)

使用setdar=16/9do 不成功:它改变了 PAR,所以结果是相同的:

Input #0, flv, from 'rtmp://localhost/in/air-hdmi':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 720
    displayHeight   : 576
    fps             : 0
    profile         : 
    level           : 
  Duration: 00:00:00.00, start: 287464.746000, bitrate: N/A
    Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp
    Stream #0:1: Video: h264 (High), yuv420p, 720x576, 25 fps, 25 tbr, 1k tbn, 50 tbc
[flv @ 0x3a5ea20] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, flv, to 'rtmp://localhost/in/ngoraltest':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 720
    displayHeight   : 576
    fps             : 0
    profile         : 
    level           : 
    encoder         : Lavf57.38.101
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.46.100 flv
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp
    Metadata:
      encoder         : Lavc57.46.100 libmp3lame
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> flv1 (flv))
  Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Run Code Online (Sandbox Code Playgroud)

(使用时setsar,参数为720x576 [SAR 16:9 DAR 20:9],当setdar- 720x576 [SAR 64:45 DAR 16:9]

我也尝试过申请scale=720:-1,但-aspect 16:9一切都一样。

!当我写下它时ffplay -vf setsar=16/9 rtmp://localhost/in/ngoraltest,它完美地展示了我所需要的。这个问题可能是什么以及解决它的方法是什么?

PS 我有点困惑,没有关于输入信号的 SAR 和 DAR 的信息,但我对此完全无能为力。

Adm*_*ith 6

ffmpeg -i infile -aspect 16:9 -c copy outputfile
Run Code Online (Sandbox Code Playgroud)

文档中:

设置视频显示宽高比。如果在流复制-aspect时一起使用 ,它将影响容器级别存储的宽高比,但不会影响编码帧中存储的宽高比(如果存在)。

据我所知。当 DAR 数字变高时,视频媒体就会出现此问题。我想媒体缠绕得太紧了,它不会与具有相同方面的其他媒体连接。我能看到的唯一方法是将其转换为原始格式并重新压缩。当我尝试将视频剪辑连接或拼接在一起时,我遇到了这个问题。与不同文件中的 DAR 不匹配的数字会产生错误。我被迫使用 Windows Movie Maker 手动附加媒体。