我試圖改變視頻的縱橫比,導致它顯示錯誤的方式(它應該是16:9,但顯示3:4)。 我試了很多東西,都沒有工作。 例如我試圖設置SAR,但它改變了DAR,因此寬高比保持不變。這裏有一個例子:Ffmpeg改變縱橫比沒有成功
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
,該PARAMS是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
它完全顯示我需要什麼。 什麼可能是thae問題和鋤頭來解決它?
P.S.我有點困惑,沒有關於輸入信號的SAR和DAR的信息,但我完全可以不做任何事情。
您正在使用編碼器「flv1」。我懷疑你想要那樣。 – LordNeckbeard
@LordNeckbeard Whatshoul我用?如何? :) – Ngoral
添加'-c:v libx264'作爲H.264視頻的輸出選項。 – LordNeckbeard