我如何只为每个HLS输出输出单个视频流

时间:2018-10-19 22:14:22

标签: ffmpeg

我已经成功使用-map 360、720和1080p输出了3个HLS输出。我的源文件是540p。生成后,我在新创建的360.ts,720.ts和1080.ts上使用ffprobe,请注意还有另一个视频通道。该频道是输入视频。 FFmpeg如何不将原始视频作为输出的一部分输出?

这是360.ts上的ffprobe

流#0:0 [0x100]:视频:h264(主)([27] [0] [0] [0] / 0x001B),yuv420p,640x360 [SAR 1:1 DAR 16:9],29.97 fps,29.97 tbr,90k tbn,59.94 tbc     流#0:10x101:音频:aac([15] [0] [0] [0] / 0x000F),48000 Hz,立体声,fltp,100 kb / s     流#0:2 [0x102]:视频:h264(主)([27] [0] [0] [0] / 0x001B),yuv420p,960x540 [SAR 1:1 DAR 16:9],29.97 fps,29.97 tbr,90k tbn,59.94 tbc

这是FFmpeg命令

%ffmpeg%-loglevel致命-threads%threads%-hide_banner -y -i%input%-i%overlayImg%^        -filter_complex“ [1] colorchannelmixer = aa =%thumbopacity%,scale = iw *%thumbscale%:-1 [wm]; [0:v] [wm] overlay =(main_w-overlay_w)-36:(main_h-overlay_h )-21,split = 4 [a] [b] [c] [d]; [a] scale = w = 640:h = 360:force_original_aspect_ratio =减少[a]; [b] scale = w = 1280:h = 720:force_original_aspect_ratio =降低[b]; [c] scale = w = 1920:h = 1080:force_original_aspect_ratio = decrease [c]; [d] scale = w = 1280:h = 720:force_original_aspect_ratio = decrease [d]“ ^        -map“ [a]” -map 0 -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags + faststart -tune film -crf%crf%-preset%preset%-sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 800k-最大856k -bufsize 1200k -b:a 96k -hls_flags single_file ^   %output%\ 360p.m3u8 ^        -map“ [b]” -map 0 -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags + faststart -tune film -crf%crf%-preset%preset%-sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 2800k -maxrate 2996k -bufsize 4200k -b:a 128k -hls_flags single_file ^   %output%\ 720p.m3u8 ^        -map“ [c]” -map 0 -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags + faststart -tune film -crf%crf%-preset%preset%-sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 5000k-最大5350k -bufsize 7500k -b:a 192k -hls_flags single_file ^   %output%\ 1080p.m3u8 ^   -map“ [d]” -map 0 -c:a aac -ar 48000 -c:v h264 -profile:v main -preset%preset%^   %output%\ 720.mp4 ^   -map 0:v -y -ss 0.5 -vframes 1 -s%thumbsize%-ss 30 ^   %outputthumb%

谢谢。

1 个答案:

答案 0 :(得分:0)

1)-map 0将包括所有原始流,包括视频。更改为-map 0:a

2)您无需两次缩放至720p。一次缩放并拆分。

3)b:vcrf在libx264(h264编码器)中是专有的。选择一个(最好是crf)

使用

%ffmpeg% -loglevel fatal -threads %threads% -hide_banner -y -i %input% -i %overlayImg%^ -filter_complex "[1]colorchannelmixer=aa=%thumbopacity%,scale=iw*%thumbscale%:-1[wm];[0:v][wm]overlay=(main_w-overlay_w)-36:(main_h-overlay_h)-21,split=4[a][b][c][d];[a]scale=w=640:h=360:force_original_aspect_ratio=decrease[a];[b]scale=w=1280:h=720:force_original_aspect_ratio=decrease,split=2[b][d];[c]scale=w=1920:h=1080:force_original_aspect_ratio=decrease[c]"^ -map "[a]" -map 0:a -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags +faststart -tune film -crf %crf% -preset %preset% -sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 800k -maxrate 856k -bufsize 1200k -b:a 96k -hls_flags single_file^ %output%\360p.m3u8^ -map "[b]" -map 0:a -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags +faststart -tune film -crf %crf% -preset %preset% -sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 2800k -maxrate 2996k -bufsize 4200k -b:a 128k -hls_flags single_file^ %output%\720p.m3u8^ -map "[c]" -map 0:a -c:a aac -ar 48000 -c:v h264 -profile:v main -movflags +faststart -tune film -crf %crf% -preset %preset% -sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:v 5000k -maxrate 5350k -bufsize 7500k -b:a 192k -hls_flags single_file^ %output%\1080p.m3u8^ -map "[d]" -map 0:a -c:a aac -ar 48000 -c:v h264 -profile:v main -preset %preset%^ %output%\720.mp4^ -map 0:v -y -ss 0.5 -vframes 1 -s %thumbsize% -ss 30^ %outputthumb%