datarhei / restreamer

The Restreamer is a complete streaming server solution for self-hosting. It has a visually appealing user interface and no ongoing license costs. Upload your live stream to YouTube, Twitch, Facebook, Vimeo, or other streaming solutions like Wowza. Receive video data from OBS and publish it with the RTMP and SRT server.
https://docs.datarhei.com/restreamer/
Apache License 2.0
3.78k stars 438 forks source link

Incorrect Application of Video Filters in ffmpeg #787

Open VoidNullNil opened 1 month ago

VoidNullNil commented 1 month ago

Description: Encountered an issue where the system ignores or generates incorrect filter parameters for ffmpeg.

Steps to Reproduce:

  1. Edit Video
  2. Go to Video settings -> Edit -> Probe
  3. Select your encoding setting
  4. Apply the following filters:
    • Scale: By height
    • Scale size: 360
    • Horizontal Flip

Expected Behavior: The video filters should be applied.

Actual Result: The video filters were not applied.

Process Details -> Command:

ffmpeg -err_detect ignore_err -vaapi_device /dev/dri/renderD128 -y -fflags +genpts -thread_queue_size 512 -probesize 5000000 -analyzeduration 3000000 -rtmp_enhanced_codecs hvc1,av01,vp09 -i rtmp://127.0.0.1/stream/2b3ef742-e0af-4248-8ba5-949ac7666ef0.stream -dn -sn -map 0:0 -filter:v scale=960x540,hflip -vf format=nv12,hwupload -codec:v h264_vaapi -profile:v 578 -quality -1 -b:v 256k -maxrate 256k -bufsize 256k -r 15 -g 4 -g 60 -map 0:1 -filter:a aresample=osr=44100 -codec:a aac -b:a 64k -shortest -bsf:a aac_adtstoasc -metadata title=https://web.site/3c00b753-9d2e-43d0-819d-0fba1b8d5c33/oembed.json -metadata service_provider=datarhei-Restreamer -f hls -start_number 0 -hls_time 2 -hls_list_size 6 -hls_flags append_list+delete_segments+program_date_time+temp_file -hls_delete_threshold 4 -hls_segment_filename http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0_%04d.ts -master_pl_name 3c00b753-9d2e-43d0-819d-0fba1b8d5c33.m3u8 -master_pl_publish_rate 2 -method PUT http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0.m3u8

Process Details -> Banner:

ffmpeg version 6.1.1-datahrei Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --extra-version=datahrei --prefix=/usr/local --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-static --enable-openssl --enable-libxml2 --enable-vaapi --enable-libv4l2 --enable-libfreetype --enable-alsa --enable-libsrt --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libdav1d --enable-librav1e --disable-ffplay --disable-ffprobe --disable-debug --disable-doc
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, flv, from 'rtmp://127.0.0.1/stream/2b3ef742-e0af-4248-8ba5-949ac7666ef0.stream':
  Metadata:
    displayWidth    : 1920
    displayHeight   : 1080
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080, 14.25 fps, 14.29 tbr, 1k tbn
  Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp
Multiple -filter, -af or -vf options specified for stream 0, only the last option '-filter:v format=nv12,hwupload' will be used.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[http @ 0x64f0e0533d40] HTTP error 404 Not Found
hls.streammap:{"address":"http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0.m3u8","variants":[{"variant":0,"address":"http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0.m3u8","streams":[0,1]}]}
Output #0, hls, to 'http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0.m3u8':
  Metadata:
    displayWidth    : 1920
    displayHeight   : 1080
    title           : https://web.site/3c00b753-9d2e-43d0-819d-0fba1b8d5c33/oembed.json
    service_provider: datarhei-Restreamer
    encoder         : Lavf60.16.100
  Stream #0:0: Video: h264 (Constrained Baseline), vaapi(tv, bt709, progressive), 1920x1080, q=2-31, 256 kb/s, 15 fps, 90k tbn
    Metadata:
      encoder         : Lavc60.31.102 h264_vaapi
  Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp, 64 kb/s
    Metadata:
      encoder         : Lavc60.31.102 aac
ffmpeg.mapping:{"graphs":[{"index":0,"graph":[{"src_name":"Parsed_format_0","src_filter":"format","dst_name":"Parsed_hwupload_1","dst_filter":"hwupload","inpad":"default","outpad":"default","timebase": "1/1000","type":"video","format":"nv12","width":1920,"height":1080},{"src_name":"Parsed_hwupload_1","src_filter":"hwupload","dst_name":"format","dst_filter":"format","inpad":"default","outpad":"default","timebase": "1/1000","type":"video","format":"vaapi","width":1920,"height":1080},{"src_name":"graph 0 input from stream 0:0","src_filter":"buffer","dst_name":"auto_scale_0","dst_filter":"scale","inpad":"default","outpad":"default","timebase": "1/1000","type":"video","format":"yuv420p","width":1920,"height":1080},{"src_name":"format","src_filter":"format","dst_name":"out_0_0","dst_filter":"buffersink","inpad":"default","outpad":"default","timebase": "1/1000","type":"video","format":"vaapi","width":1920,"height":1080},{"src_name":"auto_scale_0","src_filter":"scale","dst_name":"Parsed_format_0","dst_filter":"format","inpad":"default","outpad":"default","timebase": "1/1000","type":"video","format":"nv12","width":1920,"height":1080}]},{"index":1,"graph":[{"src_name":"Parsed_aresample_0","src_filter":"aresample","dst_name":"format_out_0_1","dst_filter":"aformat","inpad":"default","outpad":"default","timebase": "1/44100","type":"audio","format":"fltp","sampling_hz":44100,"layout":"mono"},{"src_name":"graph_1_in_0_1","src_filter":"abuffer","dst_name":"Parsed_aresample_0","dst_filter":"aresample","inpad":"default","outpad":"default","timebase": "1/44100","type":"audio","format":"fltp","sampling_hz":44100,"layout":"mono"},{"src_name":"format_out_0_1","src_filter":"aformat","dst_name":"out_0_1","dst_filter":"abuffersink","inpad":"default","outpad":"default","timebase": "1/44100","type":"audio","format":"fltp","sampling_hz":44100,"layout":"mono"}]}],"mapping":[{"input":{"index":0,"stream":0},"graph":{"index":0,"name":"graph 0 input from stream 0:0"},"output":null},{"input":{"index":0,"stream":1},"graph":{"index":1,"name":"graph_1_in_0_1"},"output":null},{"input":null,"graph":{"index":0,"name":"out_0_0"},"output":{"index":0,"stream":0}},{"input":null,"graph":{"index":1,"name":"out_0_1"},"output":{"index":0,"stream":1}}]}

Error Message:

Multiple -filter, -af or -vf options specified for stream 0, only the last option '-filter:v format=nv12,hwupload' will be used.

-filter:v scale=960x540,hflip -vf format=nv12,hwupload

How the Command Should Look:

ffmpeg -err_detect ignore_err -vaapi_device /dev/dri/renderD128 -y -fflags +genpts -thread_queue_size 512 -probesize 5000000 -analyzeduration 3000000 -rtmp_enhanced_codecs hvc1,av01,vp09 -i rtmp://127.0.0.1/stream/2b3ef742-e0af-4248-8ba5-949ac7666ef0.stream -dn -sn -map 0:0 -vf "scale=960x540,hflip,format=nv12,hwupload" -codec:v h264_vaapi -profile:v 578 -quality -1 -b:v 256k -maxrate 256k -bufsize 256k -r 15 -g 4 -g 60 -map 0:1 -filter:a aresample=osr=44100 -codec:a aac -b:a 64k -shortest -bsf:a aac_adtstoasc -metadata title=https://web.site/3c00b753-9d2e-43d0-819d-0fba1b8d5c33/oembed.json -metadata service_provider=datarhei-Restreamer -f hls -start_number 0 -hls_time 2 -hls_list_size 6 -hls_flags append_list+delete_segments+program_date_time+temp_file -hls_delete_threshold 4 -hls_segment_filename http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0_%04d.ts -master_pl_name 3c00b753-9d2e-43d0-819d-0fba1b8d5c33.m3u8 -master_pl_publish_rate 2 -method PUT http://localhost:8080/memfs/3c00b753-9d2e-43d0-819d-0fba1b8d5c33_output_0.m3u8
-vf "scale=960x540,hflip,format=nv12,hwupload"
VoidNullNil commented 4 weeks ago

ioppermann has Restreamer been abandoned? It’s strange that no one is checking the bugs.

ioppermann commented 3 weeks ago

This is indeed a bug and we'll have look at it.

Reastreamer is not abandoned. We had a summer break and are working on other projects that are currently constrain the time for Restreamer.

ioppermann commented 1 day ago

This has been fixed in the latest release: https://github.com/datarhei/restreamer/releases/tag/v2.12.0