我正在尝试更改视频的宽高比,导致它以错误的方式显示(它应该是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.
使用setdar=16/9
不成功:它会更改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
(使用setsar
时,参数720x576 [SAR 16:9 DAR 20:9]
,setdar
- 720x576 [SAR 64:45 DAR 16:9]
时
我也尝试应用scale=720:-1
和-aspect 16:9
,并且都保持不变。
BUT !我写ffplay -vf setsar=16/9 rtmp://localhost/in/ngoraltest
它完全展示了我的需要。
什么可能是问题,锄头解决它?
P.S。我有点困惑的是没有关于输入信号的SAR和DAR的信息,但我完全不能做任何事情。
答案 0 :(得分:0)
ffmpeg -i infile -aspect 16:9 -c copy outputfile
设置视频显示宽高比。如果
-aspect
一起使用的话 stream copying,它会影响存储的宽高比 容器级别,但不是存储在编码帧中的宽高比,如果 它存在。
据我所知。当DAR数字变高时,视频媒体存在此问题。我猜媒体是如此紧密地卷起来,它不会与其他同样方面的媒体联系起来。我可以看到的唯一方法是将其转换为原始格式并重新压缩它。当我尝试连接或拼接视频剪辑时,我遇到了这个问题。与不同文件中的DAR不匹配的数字会出错。我被迫使用Windows电影制作人手动附加媒体。
答案 1 :(得分:0)
您需要使用
ffmpeg -y -i rtmp://localhost/in/air-hdmi -vf "setdar=16/9" -f flv rtmp://localhost/in/ngoraltestffmpeg
setsar
是样本的宽高比,即一个像素。 setdar
用于视频。当然,setdar
所做的是在考虑视频尺寸的情况下改变SAR,以便获得显示比率。 DAR = Width x SAR / height
答案 2 :(得分:0)
因此,基于此处的所有内容,我遇到了相同的问题,并尝试了一些超级简单的方法来工作:(就我而言,它显示为4:3,但我需要将其显示为16:9)
但是请注意,我第一次尝试失败的输出通知我,它告诉了我:
Stream #0:0: Video ...(other stuff)... 640x480 [SAR 1:1 DAR 4:3], ... (other stuff)...
所以我认为我只需要更改DAR 4:3,就可以运行它:
ffmpeg -i "input.avi" -vf setdar=16:9 -c:a copy "output.mp4"
它就像一种魅力。