Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th January 2019, 07:31   #21  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
Quote:
Originally Posted by Selur View Post
I used the default values there for desat&peak, see: https://www.ffmpeg.org/ffmpeg-all.html#tonemap-1
While at is has anyone tested tonemap_opencl ? (see: https://www.ffmpeg.org/ffmpeg-all.ht...map_005fopencl)
Got it ok I'll give it a shot thanks.

So my output files (from the code I used in #14) for a UHD/HDR to HD/SDR are approximately 2-3GB in size. This is unusually low compared to the output files I get from Handbrake (HEVC/CRF18/Slow) with a normal HD Blu Ray rip (same file). Is FFmpeg compressing more heavily than Handbrake?

Edit: also, I tried using the code you provided with no luck. CMD said it wasn't a command. Again, new to FFmpeg and trying to understand each command and its structure.

Last edited by EmKayVe; 8th January 2019 at 18:01.
EmKayVe is offline   Reply With Quote
Old 12th February 2019, 06:51   #22  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
Subtitles? Yep... I just realized I have a movie that needs English subs for Spanish speaking parts and the encoder didn't include them. Anyway to mux these back in? Perhaps there is a guide?
EmKayVe is offline   Reply With Quote
Old 22nd February 2019, 16:42   #23  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,049
Quote:
Originally Posted by qyot27 View Post
I don't know if/how well FFmpeg can handle LFE mixing. Most of the time when I process my (4K or not) Blu-ray rips for watching on my desktop, I use eac3to to downmix and mix the LFE channel into the stereo signal (then encode the result to Opus and remux with the original video stream) so that when watching it back with mpv it doesn't cause nasty clipping when I try to use any volume boosting.

Of course, if you've got the right speaker setup, this is probably a completely moot point, but it is something to consider if not.

Usually LFE is ignored during downmixing (Dolby recommendation - personally i think this is due high risk of over-ranging but sane amount of LFE should be fine). Personally i use private down-mix:

for more than 5.1 to 5.1 scheme (critical feedback appreciated - didn't found anything on this topic - also Dolby documentation not very helpful)

Quote:
"pan=5.1(side)|FL<1.414FL+FLC|FR<1.414FR+FRC|FC<2.828FC+FLC+FRC|LFE=LFE|SL<SL+BL|SR<SR+BR,aresample=resampler=soxrsr=48000:cutoff=0.990:dither_method=0"
or quite classic 5.1 (compatible with 5.1 side and rear) to 2.0 downmixing (additional dynamic normalizer and resampler to 48k active)

Quote:
"pan=stereo|FL < FL+1.414FC+0.5BL+0.5SL+0.25LFE|FR < FR+1.414FC+0.5BR+0.5SR+0.25LFE,dynaudnorm=p=1/sqrt(2):m=100:s=20,aresample=resampler=soxrsr=48000:cutoff=0.990recision=20"

or quite interesting HRTF based downmixed (main intention is headphone listening for example on your portable audio device
7.1 to 2.0@HRTF:

Quote:
"[0:a:0]aformat=channel_layouts=7.1,aresample=resampler=soxrsr=48000:cutoff=0.990:dither_method=0,asplit[71][sofai];[sofai]sofalizer=sofa=dodeca_and_7channel_3DSL_HRTF.sofa:gain=11:lfegain=9[sofao]"
File 'dodeca_and_7channel_3DSL_HRTF.sofa' is a HRTF coefficient set available for example in VLC distribution

Last edited by tebasuna51; 31st October 2019 at 11:03.
pandy is offline   Reply With Quote
Old 22nd February 2019, 16:50   #24  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,049
Quote:
Originally Posted by EmKayVe View Post
Subtitles? Yep... I just realized I have a movie that needs English subs for Spanish speaking parts and the encoder didn't include them. Anyway to mux these back in? Perhaps there is a guide?
Same as adding audio track to existing set

https://superuser.com/questions/1140...-existing-file

However you may wish to add additional metadata info (for example language descriptor) about this sub.
It can be done like this:
Code:
-map 1? -c:s copy -metadata:s:s:0 language=eng
question mark perform conditional processing - i.e. if input is not present ffmpeg will continue without error - useful thing for large scripts doing universal (many files) processing
pandy is offline   Reply With Quote
Old 22nd February 2019, 16:54   #25  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,049
Quote:
Originally Posted by EmKayVe View Post
Got it ok I'll give it a shot thanks.

So my output files (from the code I used in #14) for a UHD/HDR to HD/SDR are approximately 2-3GB in size. This is unusually low compared to the output files I get from Handbrake (HEVC/CRF18/Slow) with a normal HD Blu Ray rip (same file). Is FFmpeg compressing more heavily than Handbrake?

Edit: also, I tried using the code you provided with no luck. CMD said it wasn't a command. Again, new to FFmpeg and trying to understand each command and its structure.
Asking such details you need to provide your command set - it may be case where default values used by ffmpeg are different than desired - x265/x264 are using private settings and not all ffmpeg global commands are mapped to external libraries (as ffmpeg use many external libraries side to own codecs).

for example my command line (script) may look like this:

Quote:
@SET x264opts="crf=%vq%:level=4.1:qpmin=8:cabac=1:keyint=infinite:no-deblock=1:no-mbtree=1:me=dia:rc-lookahead=5:ref=3:subme=0:no-weightb=1:weightp=0:trellis=0:no-scenecut=1:no_psnr=1:no_ssim=1:fullrange=onverscan=show:colorprim=bt709:transfer=bt709:colormatrix=bt709"

@ffmpeg.exe -hide_banner -v 32 -stats -y -color_range 2 -loop 1 -r 1 -i "%fimage%" -i "%faudio%" -vf %vproc% -c:v libx264 -preset faster -tune stillimage -profile:v high -level:v 4.1 -x264opts %x264opts% -x264-params %x264opts% -color_range 2 -c:a libfdk_aac -b:a 8k -af %aproc% -sn -dn -shortest -movflags faststart -f mp4 "%~n2_%~n1.mp4"

Last edited by tebasuna51; 31st October 2019 at 11:02.
pandy is offline   Reply With Quote
Old 8th March 2019, 03:24   #26  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
Quote:
Originally Posted by pandy View Post
Asking such details you need to provide your command set
Thanks pandy, here is my code:

Quote:
ffmpeg.exe -i D:\Videos\Media\Temp\video.mkv -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p,zscale=s=1920x1080 -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -c:a:1 aac -ac:a:1 2 -c:v libx265 -crf 20 -preset slower D:\Videos\Media\Temp\output.mp4
Looking for a "burn in" (since the output container is .mp4) of the 3rd subtitle track which is English.

Last edited by tebasuna51; 31st October 2019 at 11:01.
EmKayVe is offline   Reply With Quote
Old 30th October 2019, 20:09   #27  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
I tried the following code which I added in the code for burning the 3rd English sub track. The code is invalid. Can anyone provide a fix?

Quote:
ffmpeg.exe -i G:\Videos\ffmpeg\video.mkv -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=2,zscale=t=bt709:m=bt709:r=tv,format=yuv420p,zscale=s=1920x1080 -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -c:a:1 aac -ac:a:1 2 -c:v libx265 -crf 20 -preset slower -map 3? -c:s copy -metadata:s:s:0 language=eng G:\Videos\ffmpeg\output.mp4

Last edited by tebasuna51; 31st October 2019 at 11:00. Reason: code -> quote
EmKayVe is offline   Reply With Quote
Old 30th October 2019, 20:41   #28  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
You added "-map 3?" which should map all tracks from the 4th input file yet provided only a single input file ("-i G:\Videos\ffmpeg\video.mkv").

https://trac.ffmpeg.org/wiki/Map


When you receive errors: post the (complete) log so we can read the error messages.
sneaker_ger is offline   Reply With Quote
Old 31st October 2019, 09:57   #29  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Code:
-map 3? -c:s copy
seems wrong, try:
Code:
-c:s:2 copy
this should select the subtitle track with index 2 and copy it to the output. Note that if the format of the subtitle track is not supported by your output container this will fail.
-> best read the wiki sneaker linked to,...

For 'burning in' subtitles instead of remuxing them you need to use a filter, see: https://trac.ffmpeg.org/wiki/HowToBu...itlesIntoVideo
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 31st October 2019 at 10:00.
Selur is offline   Reply With Quote
Old 31st October 2019, 12:08   #30  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by Selur View Post
Code:
-map 3? -c:s copy
seems wrong, try:
Code:
-c:s:2 copy
this should select the subtitle track with index 2 and copy it to the output.
No, that's not how it works. First you need to -map the track from the input to output. Then you need to tell ffmpeg to copy it (as opposed to convert/re-encode). The stream specifiers of -map are for the input, the specifiers for -c are for the output. So to copy (only) the 3rd subtitle track of the (first) input file:
Code:
-map 0:s:2 -c:s:0 copy
https://trac.ffmpeg.org/wiki/Map
https://ffmpeg.org/ffmpeg.html#Stream-specifiers-1

Last edited by sneaker_ger; 31st October 2019 at 12:10.
sneaker_ger is offline   Reply With Quote
Old 22nd November 2019, 19:44   #31  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
Ok I am encoding to mp4 so that is going to be more difficult. I suppose I could just encode to mkv then mux the subtitles back in via mkvtoolnix right?
EmKayVe is offline   Reply With Quote
Old 4th January 2020, 21:56   #32  |  Link
EmKayVe
Registered User
 
EmKayVe's Avatar
 
Join Date: Dec 2018
Posts: 21
Please help me with this code. Here is what I'm trying to do. I want an ouput file at H265, SDR, 1080p, mp4, with both a AC3 audio and AAC audio track to choose from. Since it is MP4, the 3rd subtitle track has to be "burned" in. The file is an MKV, UHD Blu Ray rip with HDR.

Code:
ffmpeg.exe -i E:\ffmpeg\input.mkv -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=2,zscale=t=bt709:m=bt709:r=tv,format=yuv420p,zscale=s=1920x1080 -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -c:a:1 aac -ac:a:1 2 -c:v libx265 -crf 20 -preset slow E:\ffmpeg\output.mp4
EDIT: Ok I realize I cannot encode to MP4 if I intend to copy over a subtitle track. So, changing code to mkv.

Last edited by EmKayVe; 4th January 2020 at 22:09. Reason: Mistake
EmKayVe is offline   Reply With Quote
Old 11th January 2020, 01:05   #33  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Can anyone give me a reason why I should not trust/rely on Frame types provided by ffprobe? I have no reason to doubt it but I just want to be sure before I invest more time into what I'm doing.

I'm currently working on a method to batch analyse/split a file into chunks to accelerate VP9 encoding and despite reading such nonsense as ffmpeg cutting to the nearest keyframe (when -codec copy is used) I've had instances where a segment begins with corrupted (i.e non keyframe) frames. I could probably try -ss / -to but that would still require knowing where to cut ahead of time so the cuts were accurate and didn't include waste/unneeded frames. So I figure either way I'm looking at dumping every source files frame types with ffprobe so I can get the needed timecodes.

Unless someone knows a better way.
Also I'm little unclear on how its cutting range works.. Let's say I've got an I frame dead on at timecode 600. Should I be targeting the non-I frame directly preceding it as the segment_time to cut at? I'm unsure if I'm just getting lucky and ffmpeg is compensating for something when I tell it to cut a given timecode and it happens to come out clean.


The primary goal here is to cut clean, with no corrupt or repeated frames between any of the segments, and without re-encoding anything. Personally I don't need to do this because my workflow involves exporting to MagicYUV lossless AVI files, and I could probably just split those after the fact (and without a problem) with minimal difference in time losses due to cutting operations.

But it would be nice to produce something I can share with others that might actually be helpful, and sometimes I might want to bypass my workflow and just work on a given source directly.

EDIT: 1/10/20 7:53pm
Well this is interesting.

Here is a given set of frames. a keyframe, with a frame proceeding and preceeding it.
The source is an MKV from a bluray I own, ripped to MKV with MakeMKV. It plays fine looks fine, etc.

Code:
[FRAME]
pkt_pts_time=825.283000
pkt_pos=3031059095
pict_type=B
coded_picture_number=19788
[/FRAME]
[FRAME]
pkt_pts_time=825.325000
pkt_pos=3030754047
pict_type=I
coded_picture_number=19786
[/FRAME]
[FRAME]
pkt_pts_time=825.366000
pkt_pos=3031301614
pict_type=B
coded_picture_number=19790
[/FRAME]
Now. If I specify this command

Code:
ffmpeg -i "input.mkv" -an -f segment -segment_times 825.283000 -reset_timestamps 1 -codec copy -map 0:0 "Input-test%03d.mkv"
I'll get two MKV files from the output. The second file opens fine in WMP playing from the start shows no corruption. It does in Vdub2 /VLC though.

If I change the output container to MP4, leaving everything else unchanged, the result changed slightly. Vdub2 and WMP preview it fine, but VLC shows corruption at the start of the file.


what in the lol is this ?
Is there something about file containers I am overlooking that would explain this? I can't tell if I've got a good cut or not. I know VLC can be a little finnicky too...

Even more puzzling is if I open both the MKV and MP4 with JRiver Media Center 26 (not sure what its using other than LAV) both play fine with no corruption.
I can convert the segment mkv to AVI (FMP4 and magicyuv) and it also shows no corruption in Vdub2, WMP, (VLC/FMP4 it won't play Magicyuv), etc even though the source MKV did... so I am guessing this is some weird decoding issue with players.

Last edited by osgZach; 11th January 2020 at 03:13. Reason: clarification of some things
osgZach is offline   Reply With Quote
Old 11th January 2020, 12:02   #34  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Looks like open GOP. The order in the text that ffprobe outputs is in display order (pts time). But notice how the coded_picture_number of the first B frame is higher than the one of the I frame. That means the B frame likely references said I frame (and/or a frame before that).

Bottom line is: not every I frame is a good split point. Not even every I frame that can be seeked to is a good one. Usually you want IDR frames for splitting.
sneaker_ger is offline   Reply With Quote
Old 11th January 2020, 20:44   #35  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
yeah funny that, I noticed that when I was trying to ascertain what actual frame I was viewing within Vdub, I assumed coded_picture_number meant something else and I was wrong.

I managed to find this discussion.. which didn't seem too promising in results for differentiating an IDR from other I Frames

https://video.stackexchange.com/ques...-frames-output

edit:

Did another stats dump to confirm it just lists every I frame as a keyframe. I also limited it to outputting I frames only. Which lead me to see this

Code:
[FRAME]
key_frame=1
pkt_pts_time=1149.565000
pkt_pos=4213181483
pict_type=I
coded_picture_number=4893
[/FRAME]
[FRAME]
key_frame=1
pkt_pts_time=1150.358000
pkt_pos=4216099860
pict_type=I
coded_picture_number=4894
[/FRAME]
This is the only time I've seen coded picture numbers follow sequentially in this source file (now that I've looked there are regular groupings like this), and also curious that two I frames are next to each other. Would it be correct to assume this would always be a safe cutting point?

Last edited by osgZach; 11th January 2020 at 22:54.
osgZach is offline   Reply With Quote
Old 11th January 2020, 23:26   #36  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by osgZach View Post
Would it be correct to assume this would always be a safe cutting point?
Good question. I think specifically for Blu-Ray sources: yes. Otherwise not. Not sure.
sneaker_ger is offline   Reply With Quote
Old 12th January 2020, 00:35   #37  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Alright, thanks for your feedback. I'll do some more testing with other blu ray sourced files, since that is the primary intended purpose. Hopefully this behavior will stay consistent across all kinds of stuff. I've got some VC-1 discs I should also test with too.

edit:

I'm going to go with the aforementioned strategy of looking for groups of 2 or more consecutive iframes to target for cutting, but as an addendum I am still seeing weird as hell behavior which I will now relate my frustrations about.
I found a group of 4 consecutive iframes and started making test chunks, moving backwards in an attempt to try and find out where ffmpeg is actually deciding to cut (is it inclusive of the target specified or not). So I got all the way back to the first iframe in the bunch, specified its timecode and cut it.

Got corruption in VLC, got corruption in Vdub... OK, that's really weird...because if it was cutting the frame before the target it should still be clean, and if its cutting the frame after, it should still be clean since its an I-Frame also and its coded picture number is sequential.....

I repeated the test and switched the container from MKV to MP4 like I did in an earlier post. Corruption in VLC - NO corruption in Vdub, no corruption in Vivaldi (chromium), Firefox, WMP; I even checked in Vegas Pro 15. so I took it further and I encoded that chunk to a VP9 webm.

It came out clean. vivaldi plays it fine. VLC plays it fine. (wth???) WMP plays it fine. firefox plays it fine.

OK so what about the original MKV which showed corruption?
VLC shows corruption may be a weird playback buffer issue idk.. Vdub corruption, WMP no corruption.
I also encoded this file to VP9 webm.

Vdub, Vivaldi, Firefox, VLC all show no corruption.

As a final test I took the same MKV that showed corrupt, and again encoded it to MagicYUV M8Y0. Vdub/WMP show no corruption. (again VLC won't play this codec)

The only conclusions I can come to is
A) all these applications have inconsistent decoder behavior, even the same decoder maybe using different revisions?
or
B) the first I-Frame in the bunch is coded picture number 14444, the frame before it is a B frame, coded picture number 14446
And this harkens back to the first problem about out of order references, so as a sanity check - the first iframe in a group of iframes should never be used as a target? Because behavior is just too unpredictable even if ffmpeg seems to handle it properly itself.

I wanna rip my hair out

Last edited by osgZach; 12th January 2020 at 01:46.
osgZach is offline   Reply With Quote
Old 12th January 2020, 09:20   #38  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by osgZach View Post
I'm going to go with the aforementioned strategy of looking for groups of 2 or more consecutive iframes to target for cutting, but as an addendum I am still seeing weird as hell behavior which I will now relate my frustrations about.
I found a group of 4 consecutive iframes and started making test chunks, moving backwards in an attempt to try and find out where ffmpeg is actually deciding to cut (is it inclusive of the target specified or not). So I got all the way back to the first iframe in the bunch, specified its timecode and cut it.
In my last answer I thought you wanted to cut on the 2nd (or later) I frame in a group of consecutive I frames of a Blu-Ray. The first I frame should not be safe.

(All in display order.)
sneaker_ger is offline   Reply With Quote
Old 12th January 2020, 16:56   #39  |  Link
mkver
Registered User
 
Join Date: May 2016
Posts: 197
I wonder whether the SPS and PPS in these tracks (we are talking about H.264 here, aren't we?) change in-band. In such instances, FFmpeg does not make sure that every frame that it flags as keyframe actually has the right parameter sets in front of it. Use mkvmerge (preferably the latest continuous build as there has been a commit pertaining to this feature) to remux the transport stream from the BluRay as it inserts the correct SPS and PPS in such scenarios. (Remuxing a file already in mkv (or mp4) won't change anything.)
mkver is offline   Reply With Quote
Old 12th January 2020, 20:33   #40  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
Quote:
Originally Posted by sneaker_ger View Post
In my last answer I thought you wanted to cut on the 2nd (or later) I frame in a group of consecutive I frames of a Blu-Ray. The first I frame should not be safe.

(All in display order.)
yeah I'm not always good at articulating things.




Quote:
Originally Posted by mkver View Post
I wonder whether the SPS and PPS in these tracks (we are talking about H.264 here, aren't we?) change in-band. In such instances, FFmpeg does not make sure that every frame that it flags as keyframe actually has the right parameter sets in front of it. Use mkvmerge (preferably the latest continuous build as there has been a commit pertaining to this feature) to remux the transport stream from the BluRay as it inserts the correct SPS and PPS in such scenarios. (Remuxing a file already in mkv (or mp4) won't change anything.)
I had considered mkvmerge before but I don't think I ever managed to find any really indepth examples on how cutting with it worked. In this case, yes I'd have to re-rip them (MakeMKV has two modes, one is full disc decryption/backup and the other lets you select what you want but only outputs decrypted streams to MKV)

But it'll be an interesting chore to get done and compare the results from. And yes they're H.264
At any rate, something more applicable to general files (a game recording or other unknown source), would still be nice to have as a tool I suspect.

I appreciate all the assistance thus far.

Last edited by osgZach; 12th January 2020 at 20:39.
osgZach is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.