VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. I am about to encode a movie from DVD to MKV with ffmpeg through an Avisynth script. In this thread I've been told that it was preferable to encode the audio directly from the source, rather than through Avisynth with AudioDub(). What is the rationale for this ? Isn't Avisynth supposed to simply feed the uncompressed audio to the encoder, with no processing whatsoever (unless requested) ?
    For the movie itself, I can proceed that way, since the frame count is the same and the whole audio is to be included (in fact I'll probably keep the native 384kbps AC3 track as-is). But then there's a bunch of scenes with audio commentary as extra features, each scene being a separate VOB, and I would like to convert them all as a single ~15min video. At first I appended all scenes together with DGIndex, which extracted an AC3 track corresponding to the total length. Problem : when I made a basic Avisynth script merging the video (through the .d2v index file) and that audio track, I noticed that it was progressively out of sync when played in VirtualDub2. So I started over, indexed each scene individually, then appended them through the Avisynth script, with the audio ; that way, it stays synchronized all the way. Is this the best method in that case ?

    Code:
    V1 = MPEG2Source("VIDEO_TS\VTS_02_1.d2v")
    A1 = NicAC3Source("VIDEO_TS\VTS_02_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V2 = MPEG2Source("VIDEO_TS\VTS_03_1.d2v")
    A2 = NicAC3Source("VIDEO_TS\VTS_03_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V3 = MPEG2Source("VIDEO_TS\VTS_04_1.d2v")
    A3 = NicAC3Source("VIDEO_TS\VTS_04_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V4 = MPEG2Source("VIDEO_TS\VTS_05_1.d2v")
    A4 = NicAC3Source("VIDEO_TS\VTS_05_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V5 = MPEG2Source("VIDEO_TS\VTS_06_1.d2v")
    A5 = NicAC3Source("VIDEO_TS\VTS_06_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V6 = MPEG2Source("VIDEO_TS\VTS_07_1.d2v")
    A6 = NicAC3Source("VIDEO_TS\VTS_07_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V7 = MPEG2Source("VIDEO_TS\VTS_08_1.d2v")
    A7 = NicAC3Source("VIDEO_TS\VTS_08_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V8 = MPEG2Source("VIDEO_TS\VTS_09_1.d2v")
    A8 = NicAC3Source("VIDEO_TS\VTS_09_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    V9 = MPEG2Source("VIDEO_TS\VTS_10_1.d2v")
    A9 = NicAC3Source("VIDEO_TS\VTS_10_1 T80 2_0ch 384Kbps DELAY 0ms.ac3")
    VA1 = AudioDub(V1, A1)
    VA2 = AudioDub(V2, A2)
    VA3 = AudioDub(V3, A3)
    VA4 = AudioDub(V4, A4)
    VA5 = AudioDub(V5, A5)
    VA6 = AudioDub(V6, A6)
    VA7 = AudioDub(V7, A7)
    VA8 = AudioDub(V8, A8)
    VA9 = AudioDub(V9, A9)
    VA1 ++ VA2 ++ VA3 ++ VA4 ++ VA5 ++ VA6 ++ VA7 ++ VA8 ++ VA9
    Then, I encoded those commented scenes, as it's shorter and it would allow me to see if there was any issue before running a longer encode for the movie itself. The script was :
    Code:
    chcp 1252
    ffmpeg32 -i "[Avisynth script].avs" -vn -c:a pcm_s16le -f wav - | qaac - -o "M:\[audio].m4a"
    ffmpeg32 -i "[Avisynth script].avs" -i "M:\[audio].m4a" -i "[subtitles].srt" -i "Chapter Information -- ffmpeg metadata.txt" -map_metadata 1 -aspect 16:9 -c:v libx264 -crf 18 -preset veryslow -c:a copy "M:\Des fleurs pour Algernon - scènes commentées.mkv" >"Des fleurs pour Algernon - scènes commentées -- ffmpeg.txt" 2>&1
    pause
    First, the documentation isn't quite clear regarding the option "-map_metadata" : should it always be followed by a “1”, or is that number representing the order of the input file containing the relevant metadata ? (Which would be “3” here if I'm not mistaken, starting from 0.)
    Anyway, it worked, but there's a problem with the layout of the chapters, both in MediaInfo and in VLC Media Player ; it would seem like accentuated characters were not recognized correctly.

    In MediaInfo, titles containing accentuated characters do not appear at all :
    Code:
    General
    Unique ID                                : 138163081340327188520959396353765409417 (0x67F13DD6A0C9A1B798D141AB189E0289)
    Complete name                            : M:\Des fleurs pour Algernon - scènes commentées.mkv
    Format                                   : Matroska
    Format version                           : Version 4
    File size                                : 256 MiB
    Duration                                 : 14 min 39 s
    Overall bit rate                         : 2 438 kb/s
    Encoded date                             : UTC 2021-11-03 15:59:34
    Writing application                      : Lavf58.35.101
    Writing library                          : Lavf58.35.101
    ErrorDetectionType                       : Per level 1
    ENCODING_PARAMS                          : vers
    ITUNSMPB                                 :  00000000 00000840 000003C0 0000000002841C00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 16 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 16 frames
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 14 min 39 s
    Width                                    : 720 pixels
    Height                                   : 576 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 FPS
    Standard                                 : PAL
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Writing library                          : x264 core 158
    Encoding settings                        : cabac=1 / ref=16 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Default                                  : No
    Forced                                   : No
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : A_AAC-2
    Duration                                 : 14 min 39 s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Default                                  : Yes
    Forced                                   : No
    
    Text
    ID                                       : 3
    Format                                   : ASS
    Codec ID                                 : S_TEXT/ASS
    Codec ID/Info                            : Advanced Sub Station Alpha
    Duration                                 : 14 min 35 s
    Compression mode                         : Lossless
    Writing library                          : Lavc58.65.100 ssa
    Default                                  : No
    Forced                                   : No
    
    Menu
    00:00:00.000                             : :Le restaurant
    00:01:58.040                             : :
    00:04:08.240                             : :
    00:05:11.560                             : :Vol de la souris
    00:08:07.840                             : :Mort de la souris
    00:09:39.440                             : :Charles est amoureux
    00:10:52.320                             : :"Il faudra bien vous lancer"
    00:11:50.160                             : :
    00:13:21.560                             : :
    In VLC Media Player, the titles get truncated at the first accentuated character :

    Image
    [Attachment 61591 - Click to enlarge]


    The chapters file contained this :
    Code:
    ;FFMETADATA1
    [CHAPTER]
    TIMEBASE=1/1000
    START=0
    END=118040
    title=Le restaurant
    [CHAPTER]
    TIMEBASE=1/1000
    START=118040
    END=248240
    title="C'est bien d'être intelligent"
    [CHAPTER]
    TIMEBASE=1/1000
    START=248240
    END=311560
    title=Première piqûre
    [CHAPTER]
    TIMEBASE=1/1000
    START=311560
    END=487840
    title=Vol de la souris
    [CHAPTER]
    TIMEBASE=1/1000
    START=487840
    END=579440
    title=Mort de la souris
    [CHAPTER]
    TIMEBASE=1/1000
    START=579440
    END=652320
    title=Charles est amoureux
    [CHAPTER]
    TIMEBASE=1/1000
    START=652320
    END=710160
    title="Il faudra bien vous lancer"
    [CHAPTER]
    TIMEBASE=1/1000
    START=710160
    END=801560
    title="J'arrête le piano"
    [CHAPTER]
    TIMEBASE=1/1000
    START=801560
    END=879440
    title=Scène de fin
    Yet the names of the chapters appear correctly in the ffmpeg's log, and once I used the same method, with a chapter file that also contained accentuated characters, and the result was flawless (an older version of ffmpeg was used then).

    Code:
    General
    Unique ID                                : 256348055261964837387888256270905866037 (0xC0DAD6EECF4176A61F516DBCC2277735)
    Complete name                            : Entretien Michel Houellebecq 2005 (DVD hors-série Les Inrockuptibles) [x264 + FLAC].mkv
    Format                                   : Matroska
    Format version                           : Version 4
    File size                                : 1.89 GiB
    Duration                                 : 1 h 40 min
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 2 685 kb/s
    Writing application                      : Lavf58.21.100
    Writing library                          : Lavf58.21.100
    ErrorDetectionType                       : Per level 1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L3.1
    Format settings                          : CABAC / 8 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 8 frames
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 1 h 40 min
    Width                                    : 720 pixels
    Height                                   : 432 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 50.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Writing library                          : x264 core 157 r2935 545de2f
    Encoding settings                        : cabac=1 / ref=8 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Default                                  : Yes
    Forced                                   : No
    
    Audio
    ID                                       : 2
    Format                                   : FLAC
    Format/Info                              : Free Lossless Audio Codec
    Codec ID                                 : A_FLAC
    Duration                                 : 1 h 40 min
    Bit rate mode                            : Variable
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossless
    Default                                  : Yes
    Forced                                   : No
    
    Menu
    00:00:00.000                             : :Introduction
    00:02:48.480                             : :H.P. Lovecraft, contre le monde, contre la vie (1991)
    00:08:41.120                             : :Rester vivant, méthode (1991)
    00:18:24.240                             : :La poursuite du bonheur (1992)
    00:25:00.560                             : :Extension du domaine de la lutte (1994)
    00:35:57.200                             : :Le sens du combat (1996)
    00:46:02.240                             : :Les particules élémentaires (1998)
    01:02:28.080                             : :Renaissance (1999)
    01:08:01.440                             : :Lanzarote (2000)
    01:10:43.000                             : :Plateforme (2001)
    01:23:07.720                             : :La possibilité d'une île (2005)
    So what's wrong here ?

    Also, why is ffmpeg converting the SRT subtitles to ASS ?
    Is it possible to get the subtitles activated by default with ffmpeg ?

    And what is that long “ITUNSMBP” line in the MediaInfo report ? Is it possible to get rid of it ?

    Attached is the complete ffmpeg log for the conversion of the commented scenes.
    Last edited by abolibibelot; 3rd Nov 2021 at 12:30.
    Quote Quote  
  2. Use makemkv instead
    How is this remotely related with the questions above ?
    Unless I'm mistaken, MakeMKV is meant to remux a DVD with no transcoding at all, which is not at all what I want to do here.
    Quote Quote  
  3. Originally Posted by abolibibelot View Post
    How is this remotely related with the questions above ?
    Unless I'm mistaken, MakeMKV is meant to remux a DVD with no transcoding at all, which is not at all what I want to do here.
    Was just a suggestion, sorry...
    Quote Quote  
  4. I solved the issue with the chapters / accentuated characters by myself : the metadata file has to be encoded in UTF-8 rather than ANSI.

    But I'd still be interested in getting answers to the other questions :
    – Is it indeed always best to encode the audio directly from the source rather than through an Avisynth script, if so, why ?
    I have noticed very subtle audio glitches in the previous encode I had made of that same movie, for which the audio was passed through the Avisynth script ; those glitches seemingly occur at the exact location of chapter points (although not all of them), and are not present in the source. I have no idea if they were caused by Avisynth's processing, or by MeGUI which I used at the time for the encoding, or a combination of both.
    – Is it reliable / practical to do a quite complex conversion like this (video encoding + subtitles + chapters) in a single step with ffmpeg, or is it preferred to do the video encoding only, and then remux it with mkvmerge to add the extra elements (subtitles + chapters) ? Also, is it possible with ffmpeg to set subtitles as activated by default ?
    – With ffmpeg, is it possible, in a single command, to remove the unwanted metadata from either or all input file(s), and add specific metadata from a specified text file (chapters in this particular case) ? I read a few articles / threads mentioning the options -map_metadata / -map_chapters, and tried various combinations but couldn't get the expected outcome, and don't quite understand how they're supposed to interact.
    Also, is there an automated method to convert the chapters list from the timecodes based format used by mkvmerge to the frame number based format used by ffmpeg ? Perhaps I reinvented the wheel, doing as follows : 1) loaded the chapters file into Calc, with “:” as separator ; 2) then converted timecodes with this formula : “=E3+D3*1000+C3*60000+B3*3600000” (where Bx = hours, Cx = minutes, Dx = seconds).
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!