This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] FFMPEG Help - x265 HDR HLG Encoding from MXF
#1
Hey folks!

I need a little help with my ffmpeg setup.

Source: MXF Op1A XAVC100 Rec2020 HLG 50fps with 8 mono audio streams

Now i need to convert this file to 25fps (frame drop) x265 (mp4 container) with correct meta data (video) and one more move to create a stereo track from audio stream 0 and 1 (the first two mono streams) and a 4sec offset (remove the first 4  seconds). I was able to encode the video stream correctly (I guess) and I was able to generate a stereo WAV from audio stream 0 and 1. But I was not able to combine both stringt to generate a h265/aac 320k mp4 stream.
With the help of FastFlix I got this (without the 4sec offset):
ffmpeg -y     -i "INPUT.mxf"   -max_muxing_queue_size 1024 -map 0:0   -c:v libx265 -pix_fmt yuv420p10le     -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=arib-std-b67:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0"   -crf:v 18 -preset:v slow   -map_metadata -1  -r 25  -default_mode infer_no_subs  "OUTPUT.MP4"

And the WAV works this way:
ffmpeg -i -ss 00:00:04.00 INPUT.mxf -filter_complex "[0:1][0:2]join=inputs=2:channel_layout=stereo[a]" -map "[a]" OUTPUT.wav

But I was not able to combine these two commands and use aac instead of pcm wav.

Thanks for your help!
Reply
#2
Have you tried something like: (can't test atm., so the following is untested)
ffmpeg -ss 00:00:04.0 -i "INPUT.mxf" -vn -i "INPUT.mxf" -an -max_muxing_queue_size 1024 -c:v libx265 -pix_fmt yuv420p10le -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=arib-std-67:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0" -crf:v 18 -preset:v slow -filter_complex "[0:1][0:2]join=inputs=2:channel_layout=stereo[a]"   -c:a libfaac -q:a 100 -map 1:0 -map "[a]" -map_metadata -1 -r 25  -default_mode infer_no_subs  "OUTPUT.MP4"
explanation:
-ss 00:00:04.0 -i "INPUT.mxf" -vn -i "INPUT.mxf" -anf"
loads the source two times (index: 0 and index: 1), while one of the input (index: 0) is delayed and video is disabled (-vn) for the first input (index: 0) and audio is disabled (-an) for the second input (index: 1); not sure if the disabling of the audio/video is necessary, might be covered by the mapping later.
-max_muxing_queue_size 1024
is used to avoid 'Too many packets buffered for output stream'
-c:v libx265 -pix_fmt yuv420p10le -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=arib-std-67:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0" -crf:v 18 -preset:v slow
does the video encoding
-filter_complex "[0:1][0:2]join=inputs=2:channel_layout=stereo[a]" -c:a libfaac -q:a 100
does the audio channel changes and the reencodeing
"[0:1][0:2]": take stream with index 1 and index 2 from the source with index 0
"join=inputs=2:channel_layout=stereo": join these inputs using a stereo layout
"[a]": output as "a"
-map 1:0 -map "[a]"
Map the first stream form the second input (index: 0) and 'a' to the output.
-map_metadata -1
drops meta data from the inputs
-r 25
sets the output frame rate that should be set on the output
-default_mode infer_no_subs
tells ffmpeg to set no subtitle track as default track (no clue why you use it here)
"OUTPUT.MP4"
sets the output.

Like I wrote I'm not sure whether the '-an' and '-vn' are necessary, so the above might still not work, but should give a hint how to do it.

Cu Selur
Reply
#3
Thanks a lot! I think I got it. Heart

ffmpeg -ss 4 -i "input.mxf" -ss 4.08 -i "input.mxf" -max_muxing_queue_size 1024 -c:v libx265 -pix_fmt yuv420p10le -x265-params "aq-mode=2:repeat-headers=0:strong-intra-smoothing=1:bframes=4:b-adapt=2:frame-threads=0:colorprim=bt2020:transfer=arib-std-67:colormatrix=bt2020nc:hdr10_opt=0:hdr10=0:chromaloc=0" -crf:v 18 -preset:v slow -filter_complex "[0:1][0:2]join=inputs=2:channel_layout=stereo[a]"   -c:a aac -b:a 320k -map 1:0 -map "[a]" -map_metadata -1 -r 25 -tag:v hvc1 "output.MP4"

-ss 4: 4 second offset for audio
-ss 4.08: 4 seconds and 2 frames offset for video (I guess because of 50fps to 25fps conversion)
-c:a aac -b:a 320k: libfaac is outdated.. (?) and I need CBR @ 320k

-tag:v hcv1: works with Apple Quicktime

I also deleted -vn and -an, because it results in "Stream map '1:0' matches disabled streams." error.

One more thing: does -ss affect the encoding speed? I just rendered a small part, but it seems to be much slower (encoded 125 frames in 20.06s (6.23 fps) VS. encoded 227 frames in 22.63s (10.03 fps)).
Reply
#4
Quote:-c:a aac -b:a 320k: libfaac is outdated.. (?) and I need CBR @ 320k
not necessarily, but libfaac isn't included in ffmpeg unless you compile it youself due to license restrictions.

Quote:-ss 4.08: 4 seconds and 2 frames offset for video (I guess because of 50fps to 25fps conversion)
Nope, frame rate change doesn't change offset, but encoding to aac might.

Quote:One more thing: does -ss affect the encoding speed? I just rendered a small part, but it seems to be much slower (encoded 125 frames in 20.06s (6.23 fps) VS. encoded 227 frames in 22.63s (10.03 fps)).
It should not, but the start will take a lot longer if your source doesn't have an index since then the first few seconds need to be decoded until the selected time is reached.

Cu Selur
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)