mkv2tivomp4.bat

Discussion in 'TiVo Home Media Features & TiVoToGo' started by orangeboy, May 8, 2010.

  1. zabolots

    zabolots Member

    87
    1
    May 24, 2007
    NW Chicago...

    Advertisements

    I don't think it's a permissions issue for me since every MKV I've tried to convert with this batch file (both successfully and unsuccessfully) were all in the same folder. Plus, it does briefly create the .tmp file I mentioned so I know that it is not being preventing from creating files in the folder where the MKV file is located.
     
  2. zabolots

    zabolots Member

    87
    1
    May 24, 2007
    NW Chicago...
    I tried to rewrite the MKV into an MP4 container with ffmpeg. It doesn't help me one bit, but perhaps somebody will see something here to figure out a way to fix these files so they'll work with the mkv2tivomp4 process:

    Code:
    c:\Temp\DVD>ffmpeg -i Boardwalk.Empire.S01E01.mkv -vcodec copy -acodec copy -ac
    2 Boardwalk.Empire.S01E01.mp4
    FFmpeg version SVN-r21085, Copyright (c) 2000-2010 Fabrice Bellard, et al.
      built on Jan  8 2010 06:05:02 with gcc 4.2.4
      configuration: --enable-memalign-hack --prefix=/mingw --cross-prefix=i686-ming
    w32- --cc=ccache-i686-mingw32-gcc --target-os=mingw32 --arch=i686 --cpu=i686 --e
    nable-avisynth --enable-gpl --enable-version3 --enable-zlib --enable-bzlib --ena
    ble-libgsm --enable-libfaad --enable-pthreads --enable-libvorbis --enable-libthe
    ora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg --enable-libxvid
    --enable-libschroedinger --enable-libx264 --enable-libopencore_amrwb --enable-li
    bopencore_amrnb
      libavutil     50. 7. 0 / 50. 7. 0
      libavcodec    52.45. 0 / 52.45. 0
      libavformat   52.46. 0 / 52.46. 0
      libavdevice   52. 2. 0 / 52. 2. 0
      libswscale     0. 8. 0 /  0. 8. 0
    [matroska @ 0x13abc40]MAX_READ_SIZE:5000000 reached
    [matroska @ 0x13abc40]Estimating duration from bitrate, this may be inaccurate
    
    Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/
    1001) -> 23.98 (24000/1001)
    Input #0, matroska, from 'Boardwalk.Empire.S01E01.mkv':
      Duration: 01:12:19.00, start: 0.000000, bitrate: N/A
        Stream #0.0(eng): Video: h264, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 47.62 fp
    s, 23.98 tbr, 1k tbn, 47.95 tbc
        Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels, s16
        Metadata:
          description     : English
        Stream #0.2(eng): Subtitle: 0x0000
        Metadata:
          description     : English
    [mp4 @ 0x2d80050]track 1: codec frame size is not set
    Output #0, mp4, to 'Boardwalk.Empire.S01E01.mp4':
        Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-
    31, 48k tbn, 23.98 tbc
        Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.1 -> #0.1
    Could not write header for output file #0 (incorrect codec parameters ?)
    
     
  3. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    I think the problem is this:

    Code:
    Video #0
    Codec                : MPEG-4 AVC
    Codec/Info           : MPEG4 ISO advanced profile
    PlayTime             : 1h 12mn
    Width                : 1280 pixels
    Height               : 720 pixels
    Aspect ratio         : 16/9
    Frame rate           : 23.976 fps
    
    This looks like an mpeg4 video codec, and the mkv2mp4 bat only looks for compatible h264 video codecs.
     
  4. sirfergy

    sirfergy Member

    291
    1
    May 18, 2002
    If you have an mkv with h264 and AC3 you can use the copy flags on ffmpeg.
     
  5. zabolots

    zabolots Member

    87
    1
    May 24, 2007
    NW Chicago...

    Advertisements

    I tried that as noted in post #22 above, but as mentioned by orangeboy, the file is not h264 but rather some MPEG4 codec.

    It's strange that even the ffmpeg encoding profile used by kmttg won't work with these files. I don't understand why the MPEG4 codec in this file is so unfriendly. :(
     
  6. tjtv

    tjtv Member

    43
    2
    Jul 3, 2007
    Hi,

    I've been using this script successfully for a few weeks, but I've run into this problem on several files lately. It seems to crash, regardless of whether I use mp4box or mp4creator. Thanks for your help!

    Script Output
    :
    eac3to v3.24
    command line: "C:\Users\Tom\Downloads\mkv2mp4tivo\eac3to.exe" "Inception.2010.1080p.BluRay.DTS.x264.mkv" 1: "Inception.2010.1080p.BluRay.DTS.x264.h264" 2: "Inception.2010.1080p.BluRay.DTS.x264.ac3" -448
    ------------------------------------------------------------------------------
    MKV, 1 video track, 1 audio track, 2:28:08, 24p /1.001
    1: h264/AVC, 1920x800 24p /1.001
    2: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz
    [a02] The ArcSoft and Sonic decoders don't seem to work, will use libav instead.
    [v01] Extracting video track number 1...
    [a02] Extracting audio track number 2...
    [a02] Decoding with libav/ffmpeg...
    [a02] Encoding AC3 <448kbps> with libAften...
    [v01] Creating file "Inception.2010.1080p.BluRay.DTS.x264.h264"...
    [a02] Creating file "Inception.2010.1080p.BluRay.DTS.x264.ac3"...
    [a02] Clipping detected, a 2nd pass will be necessary. <WARNING>
    [a02] Starting 2nd pass...
    [a02] Extracting audio track number 2...
    [a02] Decoding with libav/ffmpeg...
    [a02] Encoding AC3 <448kbps> with libAften...
    [a02] Applying -2.59dB gain...
    [a02] Creating file "Inception.2010.1080p.BluRay.DTS.x264.ac3"...
    Video track 1 contains 213097 frames.
    eac3to processing took exactly 16 minutes.
    Done.

    Extracted audio and video tracks found.
    Combining to create MP4 file...

    AC3 import - sample rate 48000 - 5.1 channels
    Assertion failed: nal_start, file media_tools/media_import.c, line 4244

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.


    Here is the mediainfo for this file:
    General
    UniqueID : 204683534229430445538714122649473598499 (0x99FC9D61897AE224A2A3F1F55A374423)
    Complete name : K:\Movies\Inception (2010)\Inception.2010.1080p.BluRay.DTS.x264.mkv
    Format : Matroska
    File size : 14.2 GiB
    Duration : 2h 28mn
    Overall bit rate : 13.7 Mbps
    Encoded date : UTC 2010-11-22 20:33:05
    Writing application : mkvmerge v4.4.0 ('Die Wiederkehr') built on Oct 31 2010 21:52:48
    Writing library : libebml v1.0.0 + libmatroska v1.0.0

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.0
    Format settings, CABAC : Yes
    Format settings, ReFrames : 5 frames
    Muxing mode : Header stripping
    Codec ID : V_MPEG4/ISO/AVC
    Duration : 2h 28mn
    Bit rate : 13.4 Mbps
    Width : 1 920 pixels
    Height : 800 pixels
    Display aspect ratio : 2.40:1
    Frame rate : 23.976 fps
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.364
    Stream size : 13.9 GiB (98%)
    Language : English

    Audio
    ID : 2
    Format : DTS
    Format/Info : Digital Theater Systems
    Muxing mode : Header stripping
    Codec ID : A_DTS
    Bit rate mode : Constant
    Bit rate : 32.0 Kbps
    Channel(s) : 1 channel
    Channel positions : Mono
    Sampling rate : 0
    Bit depth : 16 bits
    Compression mode : Lossy
    Language : English
     
  7. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    You may want to try upgrading mp4box. I found this post where other users encountered the same (or similar) error, and this post with an apparent change to resolve the problem:

    Just curious: What happens when mp4creator is used?
     
  8. tjtv

    tjtv Member

    43
    2
    Jul 3, 2007
    This is the error log when mp4creator is used:
    eac3to v3.24
    command line: "C:\Users\Tom\Downloads\mkv2mp4tivo\eac3to.exe" "Inception.2010.1080p.BluRay.DTS.x264.mkv" 1:

    "Inception.2010.1080p.BluRay.DTS.x264.h264" 2: "Inception.2010.1080p.BluRay.DTS.x264.ac3" -448
    ------------------------------------------------------------------------------
    MKV, 1 video track, 1 audio track, 2:28:08, 24p /1.001
    1: h264/AVC, 1920x800 24p /1.001
    2: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz
    [a02] The ArcSoft and Sonic decoders don't seem to work, will use libav instead.
    [v01] Extracting video track number 1...
    [a02] Extracting audio track number 2...
    [a02] Decoding with libav/ffmpeg...
    [a02] Encoding AC3 <448kbps> with libAften...
    [v01] Creating file "Inception.2010.1080p.BluRay.DTS.x264.h264"...
    [a02] Creating file "Inception.2010.1080p.BluRay.DTS.x264.ac3"...
    [a02] Clipping detected, a 2nd pass will be necessary. <WARNING>
    [a02] Starting 2nd pass...
    [a02] Extracting audio track number 2...
    [a02] Decoding with libav/ffmpeg...
    [a02] Encoding AC3 <448kbps> with libAften...
    [a02] Applying -2.59dB gain...
    [a02] Creating file "Inception.2010.1080p.BluRay.DTS.x264.ac3"...
    Video track 1 contains 213097 frames.
    eac3to processing took exactly 16 minutes.
    Done.

    Extracted audio and video tracks found.
    Combining to create MP4 file...

    AC3 import - sample rate 48000 - 5.1 channels
    AVC-H264 import - frame size 1920 x 800 at 23.976 FPS
    Import results: 213097 samples - Slices: 1836 I 45216 P 166045 B - 1 SEI - 1734 IDR
    Stream uses B-slice references - max frame delay 2
    Converting to ISMA Audio-Video MP4 file...
    Saving to Inception.2010.1080p.BluRay.DTS.x264.mp4: 0.500 secs Interleaving
    Error: I/O Error

    Comparing source filesize: 15215333482 with output filesize: 8997294080

    Generated mp4 file is within acceptable file size.
    Deleting any workfil
     
  9. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    Do you have ~42.6 GiB available on your harddrive?

    14.2 GiB for original .mkv file,
    14.2 GiB for extracted .h264 and .ac3 files, and
    14.2 GiB for new .mp4 file
    42.6 GiB free space needed.
     
  10. tjtv

    tjtv Member

    43
    2
    Jul 3, 2007
    Thanks for your help. I cleared up some disk space, and updated to a newer version of mp4box and the script now works again!
     
  11. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    Good deal!

    I considered having the script delete the original .mkv file after audio and video track extraction in an effort to conserve disk space, but thought better of it. I've used up all the free disk space in the past, when doing a batch of 5-10 files at once. I now only do 2-3 at a time if I'm running relatively low on space.
     
  12. thekayman

    thekayman New Member

    5
    0
    Jun 20, 2009
    Great script orangeboy... I had a few problems with mp4box crashing but went to a older ver (MP4Box-0.4.5) and it seems to be working now.. altho its stuck on Saving to blahblah.mp4: 0.500 secs Interleaving for the past 1.5 hours with a cursur flashing I'm going to wait it out to see if it moves on does this process normally take long on a 14gb mkv file?

    just fyi when mp4box was crashing I tried mp4creator but it converted the 5.1 dts into 2 chan stereo, dont know if that is what its meant to do or not.

    Thanks again.
     
  13. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    Thank you!

    I've never had any luck with mp4box, and have used mp4creator. I just did an 8GB file that took about 45 minutes, start to finish, using mp4creator. eac3to extraction took about 13 minutes, so muxing took about 32 minutes. This was on a machine with two Pentium 4 processors running at 3GHz, and 2GB of RAM. 1.5 hours for 14GB would be a tad bit longer than expected, but not out of the question in my environment.

    Does the file have multiple audio tracks? If so, it's possible that a 2 channel AC3 track is "scored" higher than the DTS track, if the DTS track had a lot of extra conversion to perform. 5.1 channels is scored pretty high, but bitrates or frequencies that are too high can offset that high score. That's the only possible reason I can going from 5.1 to 2.0 channels.

    Also, the scoring only effects which audio track eac3to extracts. I would think that choice of muxer would make no difference in the audio channels. At least I didn't specify anything special to reduce the number of channels with either muxer's command line options. I do have eac3to reduce the number of channels to 5.1 if they are 6.1 or greater.
     
  14. thekayman

    thekayman New Member

    5
    0
    Jun 20, 2009
    mp4box was still going this morning so I killed it and am trying again.

    The extracted audio is showing 6 channels (5.1) but the output file after mp4creator only shows 2 channels.. any ideas or what I could try?

    I'll also see how mp4box goes a second time round... I have a C2D E6600 (2.4Ghz) so it should in theory be quicker then on your setup you would think.
     
  15. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    I haven't touched the script in months, but I do have a version that I could implement some rudimentary logging to provide a synopsis of what's going on. The problem with Windows batch is that commands cannot be piped to two destinations at the same time; it's either to the console (command window) or a file. I could capture everything to a file initially and then "type" the file to the console, but then you'd be looking at nothing until the command actually finished. So in your case, you wouldn't even be able to see if mp4box was actually executing! I had contemplated porting the script to python, but that would not be done quickly.

    In the meantime, can you execute eac3to on just the .mkv file by issuing the command:

    "\your\path\to\eac3to.exe" "\your\path\to\the.mkv.file"

    in a command prompt, where both "\your\path\to\" and "the.mkv.file" are filled in appropriately, and post the results?
     
  16. tjtv

    tjtv Member

    43
    2
    Jul 3, 2007
    I have one other question, now that I've been using this script successfully.

    The created mp4 file plays perfectly on the tivo, but when I play it on the computer(using windows media player), I don't get any sound. Any idea why this is happening?

    Thanks again for all your help, and for providing this incredibly useful script!
     
  17. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    I would guess that WMP doesn't know about the AC3 codec. Downloading a codec pack would probably fix the issue, but I'm personally concerned with security with some of the installers, having received a virus or two in the past.

    That being said, I highly recommend using VideoLan's VLC media player. It comes with it's own codecs, and plays nearly everything thrown at it.
     
  18. thekayman

    thekayman New Member

    5
    0
    Jun 20, 2009
    Hi Orangeboy,
    I ran eac3to.exe on the mkv file and here are the results
    MKV, 1 video track, 1 audio track, 2:08:45, 24p /1.001
    1: h264/AVC, English, 1920x800 24p /1.001
    2: DTS, English, 5.1 channels, 24 bits, 1509kbps, 48kHz
    "DTS 5.1 @ 1.5 Mbps"

    During the process of your script as it separates the files i can see the ac3 Audio file and it does contain the 5.1 audio but once mp4creator finishes the resulting mp4 file only has 2 channel which is strange.
    mp4box just keeps crashing on me so I cannot use that even to test unfortunately.

    I suppose if we can output results to screen and put a pause at the end so I can copy paste results that might work?
     
  19. orangeboy

    orangeboy yes, I AM orangeboy!

    4,089
    0
    Apr 19, 2004
    East Moline, IL
    At line 287 (about 1/3 of the way down) is a statement:

    Code:
    :Cleanup
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: In this section, file existence logic is used to determine if an output   ::
    :: file has been successfully created. If it has, the output file's size is  ::
    ...
    
    Adding a pause after that will stop the script immediately after muxing the files, and before deleting any of the "work" files:

    Code:
    :Cleanup
    PAUSE
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: In this section, file existence logic is used to determine if an output   ::
    :: file has been successfully created. If it has, the output file's size is  ::
    ...
    
     
  20. thekayman

    thekayman New Member

    5
    0
    Jun 20, 2009
    Hi Orangeboy, thanks for the assistance... below is the info that was in the screen before the pause

    Opening the files in KMplayer and selecting media info...
    the .MKV shows DTS 6 Channels with the right channel positions
    the extracted .AC3 shows AC-3 6 channels with the right channel positions
    the .mp4 shows AC-3 Channel0 (and is only stereo) and doesnt show any channel positions

    Code:
    Gathering file information. Please wait...
    
    Input file information:
    -----------------------
    1: h264/AVC, English, 1920x800 24p /1.001
    
    2: DTS, English, 5.1 channels, 24 bits, 1509kbps, 48kHz
    
    
    
    Video and audio codecs are compatible.
    Starting extraction process...
    
    MKV, 1 video track, 1 audio track, 2:08:45, 24p /1.001
    1: h264/AVC, English, 1920x800 24p /1.001
    2: DTS, English, 5.1 channels, 24 bits, 1509kbps, 48kHz
       "DTS 5.1 @ 1.5 Mbps"
    a02 The ArcSoft and Sonic decoders don't seem to work, will use libav instead.
    v01 Extracting video track number 1...
    a02 Extracting audio track number 2...
    a02 Decoding with libav/ffmpeg...
    a02 Encoding AC3 <448kbps> with libAften...
    v01 Creating file "videoname.h264"...
    a02 Creating file "videoname.ac3"...
    a02 Clipping detected, a 2nd pass will be necessary.
    a02 Starting 2nd pass...
    a02 Extracting audio track number 2...
    a02 Decoding with libav/ffmpeg...
    a02 Encoding AC3 <448kbps> with libAften...
    a02 Applying -1.32dB gain...
    a02 Creating file "videoname.ac3"...
    Video track 1 contains 185206 frames.
    eac3to processing took 14 minutes, 11 seconds.
    Done.
    
    Extracted audio and video tracks found.
    Combining to create MP4 file...
    
    Error decoding sei message
    Press any key to continue . . .
     

Share This Page

spam firewall

Advertisements