more options for ffmpeg recording

pkv

Developer
Hello,

this is a series of suggestions for a better use of ffmpeg capabilities.
(this is related to this thread: https://obsproject.com/forum/threads/protocol-support-on-obs-multiplatform-mpeg-dash-hls.22969/ )

(1) better codec selections (at least for mpegts):

At the moment when selecting any given muxer in recording > Custom Output (FFmpeg), a default encoder is selected but there is not always freedom to select another compatible codec.

Ex: mpegts ===> video encoder is only mpeg2video and audio encoder is: mp2

But mpegts is compatible with x264 and aac ... The difference in quality is huge ...

(2) increase the number of audio tracks to at least 16 or better 32:

case use: SDI with embedded audio (16 channels usually) corresponding to various languages, commentary, etc ...
case use: surround audio recorded in different channels

coupled to mpegts (see (1) ) , this is useful in professional settings (stb iptv dvb)


(3) enable custom filter options on ffmpeg input:

case use: -filter_complex on audio and video
One would need to pass options to ffmpeg here: ffmpeg -i INPUT [HERE] -c:v [video codec options] -c:a [audio options] -f muxer [ muxer options] OUTPUT

Ex: ffmpeg -channels 8 -f decklink -i Decklink-INPUT -filter_complex "[0:a]pan=mono|c0=c0[a0];[0:a]pan=mono|c0=c1[a1];[0:a]pan=mono|c0=c2[a2];[0:a]pan=mono|c0=c3[a3];[0:a]pan=mono|c0=c4[a4];[0:a]pan=mono|c0=c5[a5];[0:a]pan=mono|c0=c6[a6];[0:a]pan=mono|c0=c7[a7]" /
-c:v ...
-c:a ...
This command separates for instance a 7.1 sourround audio in 8 streams (+ video stream).
This can be useful for mepgts or mkv (multi-language) for sdi embedded audio input
But all the filters of ffmeg are available ... quite powerful.

(4) enable tee muxer
The tee muxer is quite convenient in that it enables multiple outputs.
case_use: This would allow streaming to various destinations, URL and files (streaming and recording).
case_use: this would allow more muxing options (the video and audio streams can be muxed differently on the various tee muxer outputs)
The tee muxer does a single encode for all the outputs so it is better for the CPU.

Maybe a way to implement all this in a single stroke would be the ability to pipe OBS with ffmepg scripts:
obs | ffmpeg -i - -c:v etc
OBS would specify the inputs and ffmpeg process them.
 

Jack0r

The Helping Squad
  1. my guess is that OBS "asks" ffmpeg which encoders should be available, but I agree that it would be awesome to have the option to freely choose it when necessary. Its probably easily done but Jim will have to take a look at it.
  2. Currently there is no plan to increase the number of channels, there was a discussion about adding channels but it was decided to do this probably later on in the future.
  3. not totally sure what you mean with ffmpeg input in this case. generally I think its not a bad idea to have the option to use filters that ffmpeg offers.
  4. again, not a bad idea and definitely something for the future of the custom ffmpeg output.
 

pkv

Developer
Hi Jack0r,
by 3. I meant: given an INPUT provided by OBS to ffmpeg , enable ffmpeg audio and video filters, which would therefore come in the pipeline after OBS filters, rescaling, overlays, etc.
thanks for your feedback
:)
 
Last edited:

pkv

Developer
on suggestion 1: I checked that indeed, the default codec for a given muxer is actually specified by ffmpeg
ex: ffmpeg -h muxer=mpegts
shows
Default video codec: mpeg2video.
Default audio codec: mp2.
 

Bubbles00

New Member
Hello Jack0r,

We are as well very much interested in all the features listed above.
We have an end-to-end solution for multilingual streaming. But we are missing a GUI for the broadcast client.

Ultimately OBS streaming would be configurable in advanced mode, like recording. So "start streaming" would lauch a MPEG-TS stream and "start recording" would record a multi-track file locally.
But features 1 to 4 listed above would already bring us very far...

Could a donation speed up these specific features? Or is it possible to hire an OBS developer for this job?
 

pkv

Developer
partial follow-up:

regarding suggestion (1), I noticed today a tweak which allows h264 with mpeg-ts output for ffmpeg recording:
specify the codec on basic.ini in the appdata>roaming>obs-studio profiles folder.
This forces the video codec to h264 while the setup through the GUI allows only mp2.
 

ICAN

New Member
Thanks PKV.
From what I see in basic.ini is that the codec and container show up as h.264, as listed below:

FFFormat=h264
FFFormatMimeType=
FFExtension=h264,264
FFRescale=true
FFVEncoder=libx264
FFAEncoder=
were you also able to note any quality difference also?
Can you share any test results?
 

ICAN

New Member
Edit:
PKV, i am not sure basic.ini is getting updated. please see my ectract:
[General]
Name=Untitled

[Output]
Mode=Advanced

[SimpleOutput]
VBitrate=800
ABitrate=64
RecFormat=mp4
UseAdvanced=true

[AdvOut]
TrackIndex=1
RecType=FFmpeg
RecTracks=1
FFOutputToFile=false
FFVEncoderId=28
FFAEncoderId=0
FFAudioTrack=1
Rescale=true
FFFormat=h264
FFFormatMimeType=
FFExtension=h264,264
FFRescale=true
FFVEncoder=libx264
FFAEncoder=
FFURL=udp://239.1.1.1:9000
Track1Bitrate=64

[Audio]
ChannelSetup=Mono

[Video]
OutputCX=1280
OutputCY=720


However, I have configured the address to be 225.1,1.1: 9000 and not 239.1.1.1, and also the container to be mpegts. Even then the above capture shows h264. This is strange.

Further, as I understand we need ts container, but x264 encoder. Please confirm that indeed you had this combination.
 

pkv

Developer
here's how my basic ini file looks and in bold is what I manually changed from what the GUI records in the file:

[AdvOut]
RescaleRes=2560x1440
TrackIndex=4
RecType=FFmpeg
RecRescaleRes=2560x1440
RecTracks=15
FFOutputToFile=false
FFRescaleRes=2560x1440
FFVEncoderId=28
FFAEncoderId=86018

FFAudioTrack=6
FFURL=udp://xxxxxxx:10000
FFFormat=mpegts
FFFormatMimeType=video/MP2T
FFVBitrate=2500
FFVEncoder=libx264
FFVCustom=-map 0:v -c:a libx264 -s 1920x1080 -r 30 -pix_fmt yuv420p -preset veryfast -b:v 2500k -profile:v high -g 60
FFABitrate=64
FFAEncoder=aac
FFACustom=
FFExtension=ts
RecEncoder=obs_x264
Track1Bitrate=64
RecFormat=ts
Track2Bitrate=64
FFMCustom=

After editing, I start OBS-studio and press 'start recording' ;
the quality is fine
 

ICAN

New Member
Edit 2:

[General]
Name=1

[Output]
Mode=Advanced

[AdvOut]
TrackIndex=1
RecType=FFmpeg
RecFilePath=udp://@235.1.1.1:9000
RecFormat=mp4
RecEncoder=obs_qsv11
RecTracks=1
FFOutputToFile=false
FFURL=udp://225.1.1.1:9000
FFFormat=mpegts
FFExtension=ts,m2t,m2ts,mts
FFVBitrate=800
FFVEncoderId=2
FFABitrate=64
FFAEncoderId=86016
FFAudioTrack=1
FFRescale=false
FFRescaleRes=872x490
Encoder=obs_x264
ApplyServiceSettings=true
FFVEncoder=mpeg2video
FFFormatMimeType=video/MP2T
FFAEncoder=mp2

[Video]
OutputCX=544
OutputCY=306

finally Managed to locate the right file.

Q: How to edit or make the system change in the encoder type?
 

pkv

Developer
i'll post a detailed walkthrough later today; after streaming in udp, I recorded to a file; I was testing whether a multi-track record can be done in ts, it worked
The files are in mpegt-s muxer + x264 + aac
check the captures (mediainfo of ts file created with mp4 and aac with 4 stereo tracks)
Capture1.JPG Capture2.JPG
After doing that, I messed the parameters so I have not recovered the udp setup yet; I'll do it again and post the right changes to do to the basic.ini file when I find the right recipe again, so discard the previous posts.
 

pkv

Developer
ok got the recipe back:

1) setup on Setting > output > recording > Output to URL
==> enter your udp address
==> select container format: mpegts
video encoder and audio encoder are then : mp2

2) locate your profile folder or : File > Show Profile folder

3) exit OBS-Studio

4) edit as follows the basic.ini file (bold entries):

[General]
Name=local

[Output]
Mode=Advanced

[AdvOut]
RescaleRes=2560x1440
TrackIndex=2
RecType=FFmpeg
RecRescaleRes=2560x1440
RecTracks=15
FFOutputToFile=false
FFRescaleRes=2560x1440
FFVEncoderId=28
FFAEncoderId=86018

FFAudioTrack=2
FFURL=udp://server.fbt-asso.org:10000
FFFormat=mpegts
FFFormatMimeType=video/MP2T
FFVBitrate=2500
FFVEncoder=libx264
FFVCustom=-map 0:v -c:v libx264 -s 1920x1080 -r 30 -pix_fmt yuv420p -preset veryfast -b:v 2500k -profile:v high -g 60
FFABitrate=64
FFAEncoder=aac
FFExtension=ts,m2t,m2ts,mts
RecEncoder=obs_x264
Track1Bitrate=64
RecFormat=ts
Track2Bitrate=64
FFACustom=-c:a aac -ab 128k -ac 2

[Video]
BaseCX=1920
BaseCY=1080
OutputCX=1280
OutputCY=720
FPSType=1
FPSInt=25

[SimpleOutput]
UseAdvanced=true
RecFormat=ts
RecQuality=Small


5) start OBS-studio
6) crucial step ==> click on 'Start Recording' (don't go to Settings to check that the parameters have been updated, it doesn't work, I was stuck on that this evening when starting to recover the tweak)
7) this connects and you should have some stream
8) now you can click on Setting > output > recording , you should have the following screen, tada, enjoy !!! :)

Capture3.JPG
 

pkv

Developer
mpegts with x264 aac officially enabled in obs 18 thanks to derrod !!!

But the huge news is VST support !
so now, please increase the number of tracks supported!
asio support as in audacity (not bundled due to licensing reasons) would be a huge huge plus.

since obs 18, mpegts supports x264 + aac thanks to derrod !

UPDATE:
mpeg-ts tcp protocol working in addition to mpeg-ts udp
BUT multichannel audio does not while it works when recording to a file; only the last two channels are taken into account ...
 
Last edited by a moderator:

Othni

New Member
I need to use the ffmpeg option "localaddr=addr" to specify the network interface to use for broadcast to multicast address.

How do I do this?
 

Othni

New Member
I need to use the ffmpeg option "localaddr=addr" to specify the network interface to use for broadcast to multicast address.

How do I do this?
Never mind, I just created a static route for the multicast traffic and this worked for me.
 

nak1

New Member
Guys,

I'm running into the same issue where i have a raw stream that I need to convert into MP4 (within OBS) but when I try to select the MP4 I still have to preform the hack mentioned above to the basic.ini file. It sounds like this is no longer needed, but I have the latest version of OBS (version 22.0.2) and it doesn't allow for MP4 when mepgts is the content container. Anyone has any idea why that is the case?
 

pkv

Developer
hi
you do not make sense; mpegts and mp4 are both containers;
you meant perhaps x264 with mpegts ?
if so, the hack is not needed; you just need to tick 'Show all codecs"
obs64_2018-12-04_21-07-53.png
 

ICAN

New Member
Hello PKV, Great work here!
I need some help on this issue, if you would please.
Using the setup and guidance above, on atest setup I have connected two PCs directly, on the same subnet. Tested the connectivity through ping.
I am able to stream out the multicast (mpeg-ts, x264, aac), I can see the bits streaming out in the network interface, but the video does not show up in the receving PC on VLC. I am see the receiver counter ticking which means conenction is made and bits are accepted but I seem to be getting a TS container error on the VLC debug console.

Any idea or help ?
Anybody who has received obs/multicast on VLC should be able to guide as well.
 
Top