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. |
|
|
Thread Tools | Search this Thread | Display Modes |
13th November 2018, 00:44 | #1 | Link |
Registered User
Join Date: Nov 2018
Posts: 34
|
Convert DTS to Dolby and any Lossless to Apple Lossless [BluRay]
Hello everybody,
I have a large BluRay collection and want it to get into my iTunes library to play on AppleTV. I have no idea of transcoding and stuff like that, but I read many threads here and on other forums and acquire some knowledge. First. Your program, madshi, is very great. Thank you for this awesome tool! I need to convert the DTS-audio-streams to Dolby. And I used eac3to for that. The Audio-Streams of the BluRay are the following and I need them to put into the mentioned codec: - DTS --> Dolby Digital (AC-3) - DTS-HD High Resolution --> Dolby Digital Plus (E-AC-3) - DTS-HD Master --> Apple Lossless (ALAC) - Dolby TrueHD --> Apple Lossless (ALAC) Here are the code snippets and their logs I used for some example BluRay-Rips. Code-Snippet for DTS-HD Master & Dolby Digital --> Apple Lossless & Dolby Digital: Code:
mkvmerge -i german_dd_to_ac3__english_dtshdma_to_alac.mkv mkvextract tracks german_dd_to_ac3__english_dtshdma_to_alac.mkv 0:video.h264 1:audio1.ac3 2:audio2.dtshdma 3:sub1.srt ffmpeg -i german_dd_to_ac3__english_dtshdma_to_alac.mkv -f ffmetadata chapters eac3to audio2.dtshdma audio2.flac eac3to audio2.dtshdma audio2_core.ac3 ffmpeg -i audio2.flac -acodec alac audio2.m4a ffmpeg^ -i video.h264 -i audio1.ac3 -i audio2.m4a -i audio2_core.ac3 -i sub1.srt -i chapters^ -map 0:0 -map 1:0 -map 2:0 -map 3:0 -map 4:0^ -metadata:s:a:0 language=ger -metadata:s:a:0 handler="Dolby Digital" -metadata:s:a:1 language=eng -metadata:s:a:1 handler="Apple Lossless" -metadata:s:a:2 language=eng -metadata:s:a:2 handler="Dolby Digital" -metadata:s:s:0 language=ger -metadata:s:s:0 handler="Deutsch"^ -disposition:a:0 default -disposition:a:1 0 -disposition:a:2 0^ -movflags disable_chpl^ -c:s mov_text -c:v copy -c:a copy^ german_dd_to_ac3__english_dtshdma_to_alac.m4v 2>> ffmpeg.log Code-Snippet for DTS-HD Master & DTS --> Apple Lossless & Dolby Digital: Code:
mkvmerge -i german_dts_to_ac3__english_dtshdma_to_alac.mkv mkvextract tracks german_dts_to_ac3__english_dtshdma_to_alac.mkv 0:video.h264 1:audio1.dts 2:audio2.dtshdma 3:sub1.srt ffmpeg -i german_dts_to_ac3__english_dtshdma_to_alac.mkv -f ffmetadata chapters eac3to audio1.dts audio1.ac3 eac3to audio2.dtshdma audio2.flac eac3to audio2.dtshdma audio2_core.ac3 ffmpeg -i audio2.flac -acodec alac audio2.m4a ffmpeg^ -i video.h264 -i audio1.ac3 -i audio2.m4a -i audio2_core.ac3 -i sub1.srt -i chapters^ -map 0:0 -map 1:0 -map 2:0 -map 3:0 -map 4:0^ -metadata:s:a:0 language=ger -metadata:s:a:0 handler="Dolby Digital" -metadata:s:a:1 language=eng -metadata:s:a:1 handler="Apple Lossless" -metadata:s:a:2 language=eng -metadata:s:a:2 handler="Dolby Digital" -metadata:s:s:0 language=ger -metadata:s:s:0 handler="Deutsch"^ -disposition:a:0 default -disposition:a:1 0 -disposition:a:2 0^ -movflags disable_chpl^ -c:s mov_text -c:v copy -c:a copy^ german_dts_to_ac3__english_dtshdma_to_alac.m4v 2>> ffmpeg.log Code-Snippet for Dolby TrueHD & Dolby Digital --> Apple Lossless & Dolby Digital: Code:
mkvmerge -i german_dd_to_ac3__english_truehd_to_alac.mkv mkvextract tracks german_dd_to_ac3__english_truehd_to_alac.mkv 0:video.h264 1:audio1.ac3 2:audio2.truehd 3:audio2_core.ac3 4:sub1.srt ffmpeg -i german_dd_to_ac3__english_truehd_to_alac.mkv -f ffmetadata chapters eac3to audio2.truehd audio2.flac ffmpeg -i audio2.flac -acodec alac -af "aformat=channel_layouts=7.1(wide)" audio2.m4a ffmpeg^ -i video.h264 -i audio1.ac3 -i audio2.m4a -i audio2_core.ac3 -i sub1.srt -i chapters^ -map 0:0 -map 1:0 -map 2:0 -map 3:0 -map 4:0^ -metadata:s:a:0 language=ger -metadata:s:a:0 handler="Dolby Digital" -metadata:s:a:1 language=eng -metadata:s:a:1 handler="Apple Lossless" -metadata:s:a:2 language=eng -metadata:s:a:2 handler="Dolby Digital" -metadata:s:s:0 language=ger -metadata:s:s:0 handler="Deutsch"^ -disposition:a:0 default -disposition:a:1 0 -disposition:a:2 0^ -movflags disable_chpl^ -c:s mov_text -c:v copy -c:a copy^ german_dd_to_ac3__english_truehd_to_alac.m4v 2>> ffmpeg.log Code-Snippet for DTS-HD Master & Dolby Digital Plus --> Apple Lossless & Dolby Digital Plus: Code:
mkvmerge -i german_dd+_to_eac3__english_dtshdma_to_alac.mkv mkvextract tracks german_dd+_to_eac3__english_dtshdma_to_alac.mkv 0:video.h264 1:audio1.eac3 2:audio2.dtshdma 3:sub1.srt 4:sub2.srt ffmpeg -i german_dd+_to_eac3__english_dtshdma_to_alac.mkv -f ffmetadata chapters eac3to audio2.dtshdma audio2.flac eac3to audio2.dtshdma audio2_core.ac3 ffmpeg -i audio2.flac -acodec alac -af "aformat=channel_layouts=7.1(wide)" audio2.m4a ffmpeg^ -i video.h264 -i audio1.eac3 -i audio2.m4a -i audio2_core.ac3 -i sub1.srt -i sub2.srt -i chapters^ -map 0:0 -map 1:0 -map 2:0 -map 3:0 -map 4:0 -map 5:0^ -metadata:s:a:0 language=ger -metadata:s:a:0 handler="Dolby Digital Plus" -metadata:s:a:1 language=eng -metadata:s:a:1 handler="Apple Lossless" -metadata:s:a:2 language=eng -metadata:s:a:2 handler="Dolby Digital" -metadata:s:s:0 language=ger -metadata:s:s:0 handler="Deutsch" -metadata:s:s:1 language=eng -metadata:s:s:1 handler="Englisch"^ -disposition:a:0 default -disposition:a:1 0 -disposition:a:2 0 -disposition:s:0 default^ -movflags disable_chpl^ -c:s mov_text -c:v copy -c:a copy^ german_dd+_to_eac3__english_dtshdma_to_alac.m4v 2>> ffmpeg.log ffmpeg5.log (also tried with mp4-container) Code-Snippet for DTS-HD Master & DTS-HD High Resolution --> Apple Lossless & Dolby Digital Plus: Code:
mkvmerge -i german_dtshr_to_eac3__english_dtshdma_to_alac.mkv mkvextract tracks german_dtshr_to_eac3__english_dtshdma_to_alac.mkv 0:video.h264 1:audio1.dtshr 2:audio2.dtshdma ffmpeg -i german_dtshr_to_eac3__english_dtshdma_to_alac.mkv -f ffmetadata chapters eac3to audio1.dtshr audio1.eac3 eac3to audio2.dtshdma audio2.flac eac3to audio2.dtshdma audio2_core.ac3 ffmpeg -i audio2.flac -acodec alac -af "aformat=channel_layouts=7.1(wide)" audio2.m4a ffmpeg^ -i video.h264 -i audio1.eac3 -i audio2.m4a -i audio2_core.ac3 -i chapters^ -map 0:0 -map 1:0 -map 2:0 -map 3:0^ -metadata:s:a:0 language=ger -metadata:s:a:0 handler="Dolby Digital Plus" -metadata:s:a:1 language=eng -metadata:s:a:1 handler="Apple Lossless" -metadata:s:a:2 language=eng -metadata:s:a:2 handler="Dolby Digital"^ -disposition:a:0 default -disposition:a:1 0 -disposition:a:2 0^ -movflags disable_chpl^ -c:v copy -c:a copy^ german_dtshr_to_eac3__english_dtshdma_to_alac.m4v 2>> ffmpeg.log First of all. The procedure is always the same (make mkv from BD --> extract mkv --> convert audiostreams --> put them into m4v container). Is this a proper way to do that? The first three are working very well and the last two have problems with E-AC-3. So here are the questions I have: 1. My chapters from the mkv I extract with ffmpeg (ffmpeg -i input.mkv -f ffmetadata chapters) are in text-format. How can I convert them to tx3g (or extract tx3g from mkv). 2. I can set a subtitle to default (-disposition:s:0 default), I need it to be default and forced. Trying it the same way (-disposition:s:0 forced) did not work. How can I do that? 3. When I have to transcode an audio stream with eac3to (so except lossless -> lossless convert), there is always a difference of 0.03 sec to source audio stream (transcode: 01:40:05.79; source: 01:40:05.76). How can I avoid this? 4. I have some warnings about timestamps and durations in my log: [ac3 @ 00000000005989c0] Estimating duration from bitrate, this may be inaccurate [ipod @ 0000000002ca4940] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [ipod @ 0000000002ca4940] pts has no value Will they disappear when I put timestamps into pts-format in the container? I can extract them from mkv (mkvextract timecodes_v2 input.mkv 0:video.timecodes.txt 1:audio1.timecodes.txt 2:audio2.timecodes.txt 3:sub1.timecodes.txt 4:sub2.timecodes.txt 5:sub3.timecodes.txt 6:sub4.timecodes.txt) but only in timecodes_v2-format. So how can I convert timecodes_v2 in pts and put them into the container? 4. How to find out the frame size and tell it to ffmpeg (because of this warning: [ipod @ 0000000002ca4940] track 1: codec frame size is not set)? 5. What does this warning message mean: [h264 @ 0000000000444240] Stream #0: not enough frames to estimate rate; consider increasing probesize. And how to avoid it? 6. I will buy the necessary software to get the best results from eac3to (Nero, ArcSoft, Sonic, SurCode, ...). In theoretic, will I get better quality results when I use DTS:X Content Creator Suite and Dolby Media Producer Suite? 7. The conversion of DTS-HD Master and Dolby TrueHD to Apple Lossless takes very long time and CPU usage compared to FLAC to ALAC. Why, when it should be only a lossless to lossess "copy"? Now the conversions I could not handle. DTS-HD Master & Dolby Digital Plus --> Apple Lossless & Dolby Digital Plus: I could not put the E-AC-3 stream into the m4v-Container ([ipod @ 000000000328e140] Could not find tag for codec eac3 in stream #1, codec not currently supported in container; Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument). So I tried the mp4-container. The conversion is almost finished, than ffmpeg crashes with the following error message: Assertion s->buf_ptr < s->buf_end failed at src/libavcodec/put_bits.h:108. How can I put E-AC-3 into the m4v-Container? DTS-HD Master & DTS-HD High Resolution --> Apple Lossless & Dolby Digital Plus: Eac3to was not able to convert DTS-HD High Resolution to Dolby Digital Plus (eac3to audio1.dtshr audio1.eac3 --> This audio conversion is not supported.). How can I handle this? It would be really nice if you can help me with my questions. Thank you very much! Best regards, Felix Last edited by FLX90; 13th November 2018 at 07:18. |
14th November 2018, 13:19 | #2 | Link | |
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,379
|
Welcome to Doom9.
Quote:
Last edited by hubblec4; 14th November 2018 at 17:10. |
|
14th November 2018, 14:57 | #3 | Link | |||
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Many questions, I can write some answers but we need a ffmpeg expert (I'm not) to others.
Quote:
Quote:
Quote:
Please use the preferred mp4 audio codec AAC for lossy audio, the size/quality is comparable to EAC3 and better than AC3.
__________________
BeHappy, AviSynth audio transcoder. |
|||
14th November 2018, 19:46 | #4 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
|
Hi @FLX90,
Out of interest... What playback device(s) are you using?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
17th November 2018, 11:54 | #5 | Link | |
Registered User
Join Date: Nov 2018
Posts: 34
|
Thank you for the answers so far.
I can only present you the meta information I get from a m4v-File. It is DRM-protected so I cannot extract the chapters: Code:
Menu ID : 34 Codec ID : tx3g Duration : 2 h 48 min Title : Core Media Text Language : German Encoded date : UTC 2017-06-10 01:38:06 Tagged date : UTC 2017-06-10 01:39:07 Menu For : 2,36,37,38,39 00:00:00.000 : 2 00:09:33.000 : 3 00:17:09.000 : 4 00:24:58.000 : 5 00:35:43.000 : 6 00:42:15.000 : 7 00:50:18.000 : 8 00:54:46.000 : 9 00:58:57.000 : 10 01:06:12.000 : 11 01:17:26.000 : 12 01:25:30.000 : 13 01:34:30.000 : 14 01:46:13.000 : 15 01:55:32.000 : 16 02:02:12.000 : 17 02:12:55.000 : 18 02:20:52.000 : 19 02:35:10.000 : 20 Bit rate mode : VBR Can be done, yes, but not with best quality results. According to this https://en.wikibooks.org/wiki/Eac3to...Audio_Decoders I would need Nero, ArcSoft and SurCode at least to get the best sound quality. Quote:
But the container should support it, because there is no error message like I get when I try it with m4v-container, only a total crash of ffmpeg at the end of the conversion. I would prefer to put DD+ back in the container without transcoding (losing information). For lossy transcoding that have to be done (DTS) I will use AAC. I will use Apple TV 4K. |
|
17th November 2018, 12:10 | #6 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
If ffmpeg crashes:
https://ffmpeg.org/bugreports.html In general I find your solutions to be overly complicated. ffmpeg can read from mkv, convert the audio and then output mp4 in a single step. It's not necessary to split it into several steps with demuxing, converting, remuxing. Note that eac3to's encoders and decoders are outdated or sometimes non-existant compared to ffmpeg. |
17th November 2018, 14:22 | #7 | Link | |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
You need Nero7+plugins only to decode AAC with eac3to, and AAC don't be recoded to preserve the max quality. But you can use ffmpeg to decode AAC, AC3, EAC3 (also 7.1), TrueHD, DTS (also DTS-HD) and don't need Nero or ArcSoft at all. Surcode is a DTS standard (lossy) encoder not recomended at all, use AAC or even AC3 to lossy encode.
__________________
BeHappy, AviSynth audio transcoder. |
|
17th November 2018, 17:36 | #8 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
|
Does the Apple TV 4K support playback of multi-channel ALAC in .mp4?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
24th November 2018, 22:44 | #9 | Link | |
Registered User
Join Date: Nov 2018
Posts: 34
|
After careful thought I will convert all Audio-Streams to ALAC.
Space is no problem and so I can preserve the best quality. Lossy --> lossless: No transcode and so no lose of information. Am I right? I solved question #2 with a program called subler (only for mac). It is doing the whole tagging very well. Question #1, #4, #4 (my fault ...) and #5 are still present. Quote:
I tested with Apple TV 4 and the audio playback was fine. (Video playback was choppy, but I think the 4K ATV will solve this problem.) |
|
25th November 2018, 12:02 | #10 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
|
Hi again FLX90,
What make and model of 4K display do you have?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
27th November 2018, 17:11 | #12 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
|
So why bother buying an Apple 4K TV STB?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
3rd January 2019, 08:40 | #14 | Link |
Registered User
Join Date: Nov 2018
Posts: 34
|
Solved #4, #4 and #5.
#4a & #5: Warning had something to do with variable frame rate and timecodes. Timecodes get lost during extract h264 from mkv. Avoid this problem by directly converting from one container to another: ffmpeg -i german_dd_to_alac__english_dtshdma_to_alac.mkv -map 0:0 -c copy temp.m4v Choppy video playback mentioned here had also something to do with converting VFR to CFR (MPC-HC handled that anyway, ATV doesn't). With this, probesize error also disappeared. #4b: Solved this by specifying audio codec -c:a alac. Don't know why but worked. Another question: Like I said I'll convert everything to ALAC. But I don't know which bit depth for the lossy audio streams. To lose as less information as possible I do the following: Convert lossy audio to 24 bit flac. Check if last 8 bits are used. If so I convert to 24 bit ALAC. If not I convert to 16 bit ALAC. Is this the best way to do? I asked in another forum and they said I should convert to 16 bit and don't waste much thought on the 8 bits. But couldn't explain me why. My thinking was that 48 dB possible difference in dynamic range (144 db <-> 96 dB) is essential to preserve, especially for movie audio. What would you say? |
3rd January 2019, 11:46 | #15 | Link | ||
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
Quote:
Always the last 8 bits are used (or they are truncated/rounded before). Even if source was 16 bits, for instance audio CD, a lossy encoder can't preserve the 16 bits exact, for that is lossy. Quote:
But with lossy sources these 8 bits are always unexact, the precision is always less than 16 bits, that is lossy encoders.
__________________
BeHappy, AviSynth audio transcoder. Last edited by tebasuna51; 3rd January 2019 at 11:50. |
||
3rd January 2019, 12:09 | #16 | Link | |
Registered User
Join Date: Nov 2018
Posts: 34
|
Quote:
So my understanding: 16 bit lossless --> lossy (24 bit) --> last 8 bits are guessed/interpolated (?) 24 bit lossless --> lossy (24 bit) --> last 8 bits are taken approximated from the lossless conclusion: (1) 24 bit lossless --> 24 bit lossy (2) 24 bit lossless --> 16 bit lossless --> 24 bit lossy (1) is closer to the originally source and so a 24 bit lossless from a lossy is closer to the originally source (if source was 24 bit). Is that right? |
|
3rd January 2019, 12:14 | #17 | Link |
Registered Developer
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,346
|
No, thats not right.
When dealing with lossy audio formats, stop thinking about bitdepth entirely, because its not a concept it tries to maintain at all. You can write a lossy decoder that decodes to 16-bit integer, or you can write one that decodes to 32-bit floating point. Or any other data format if you're so inclined. There are no guarantees that any amount of bits from the source are maintained accurately, and there is no way to generally tell how many bits of actual "precision" a lossy decoder outputs. This can and will vary between different formats, decoder implementations, and even the material in question.
__________________
LAV Filters - open source ffmpeg based media splitter and decoders |
3rd January 2019, 12:44 | #18 | Link | |
Registered User
Join Date: Nov 2018
Posts: 34
|
Sorry guys.
I really don't understand this. The lossy formts are: name depth u8 8 s16 16 s32 32 flt 32 dbl 64 u8p 8 s16p 16 s32p 32 >>>fltp 32 dblp 64 s64 64 s64p 64 Why wouldn't the most exact image be the s32p? Or I asked the other way round: What would be the most exact way to image something stored in fltp? EDIT: Tebasuna51, almost ten years ago you wrote that: Quote:
Last edited by FLX90; 3rd January 2019 at 12:59. |
|
3rd January 2019, 13:54 | #19 | Link |
Registered Developer
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,346
|
Plain and simple: Stop thinking about bitdepth with lossy codecs! It makes no sense, its merely a property of how a decoder works, not the format itself.
__________________
LAV Filters - open source ffmpeg based media splitter and decoders |
3rd January 2019, 15:31 | #20 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
|
Out of interest...
Doesn't the Apple TV 4 transcode all audio formats muxed within the .mp4 container, such as: AAC, AC-3, E-AC-3, etc, to a (multi-channel) PCM stream?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
|
|