1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mkv2tivomp4.bat

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

  1. May 8, 2010 #1 of 74
    orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Ok, I got a request to post some instructions on how to setup and use the mkv2tivomp4.bat file I posted in another thread. The following instructions are based on Windows XP, what I am running at home. Here it goes:

    1. Create a folder on your computer named mkv2mp4.
    2. Download and install/extract to the mkv2mp4 folder you created the programs that do the actual work:
      • eac3to.exe - Is required to demux (separate) the audio and video streams from the .mkv file.
        and either:
      • mp4creator.exe - Can be used to mux (join) the audio and video streams into a .mp4 file.
        or
      • mp4box.exe - An alternative to mp4creator that may reduce audio/video synchronization errors.
    3. Download and save to the mkv2mp4 folder you created the mkv2tivomp4.v6.txt file attached in this post, and rename that file to mkv2tivomp4.bat.
    4. Create a Shortcut to mkv2tivomp4.bat:
      • Open Windows Explorer and go to the SendTo folder:
        • In Windows NT, 200x, XP: %UserProfile%\Sendto
        • In Vista and Windows 7: %AppData%\Microsoft\Windows\SendTo
      • Right-click on the whitespace in the folder, and select New > Shortcut
      • The dialog will ask for a location. Use Browse... to navigate to the \mkv2mp4 folder you created, and select mkv2tivomp4.bat
      • Give the shortcut a new name if you wish (I usually just leave off the ".bat" part of the name).
      • Click Finish.
    5. Find an .mkv file.
    6. Right-click on it, and SendTo > mkv2tivomp4 (or whatever name you gave it)
    7. A Windows command window will open, with a short narrative concerning "First Run Setup". Read this, and then press any key.
    8. Follow the dialog, answering the questions as you go.
      • Some affirmative answers will lead to more questions, but all in all, it doesn't take too long to finish.
      • You may be prompted for program locations. Typically you will specify the \mkv2mp4 folder you created.
      • If you choose so, and you already have the following installed, there are options for:
      • You can specify an additional user defined post process to occur. Perhaps deleting or moving the original .mkv file? It's up to you...
      • You will be prompted to press any key when the dialog completes, indicating the batch file has been configured.
    9. The .mkv file you initially selected will now be "converted" to a .mp4 file.
    10. Any additional .mkv files you "SendTo" mkv2tivomp4.bat will not require you to perform the setup again.
    11. Multiple files can be sent to the batch file using the SendTo method, and it will process them one at a time. An example would be using Search to find all .mkv files in a folder or on a drive, and then Sending them To the mkv2tivomp4.bat shortcut

    Advanced setup: If you add the mkv2mp4 folder to your %path% environment variable, the batch will not prompt you at setup time for the programs that reside in that folder (or any program or command that can be found in %path%).

    Any questions you may have, or any bugs you encounter, let me know!
    I'm working (not too quickly) on version 7 that will support UNC paths for those files on remote drives, and will better detect filenames that don't play well with batch files...
     

    Attached Files:

  2. superflysocal

    superflysocal Member

    70
    0
    Nov 26, 2009
    Awesome thanks.

    Any chance to create a mp4 with multichannel aac to mp4 with 2 channel aac script?
     
  3. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Hmm... It appears that eac3to does support aac:

    Code:
    Supported source formats:
    (1) RAW, (L)PCM
    (2) WAV (PCM, DTS and AC3), W64, RF64
    (3) AC3, E-AC3
    (4) DTS, DTS-ES, DTS-96/24, DTS-HD Hi-Res, DTS-HD Master Audio
    (5) MP1, MP2, MP3 audio
    (6) AAC audio
    (7) MLP, TrueHD, TrueHD/AC3
    (8) FLAC
    (9) EVO/VOB/(M2)TS and MKV
    
    Decoded audio data can be stored as / encoded to:
    (1) RAW, (L)PCM
    (2) WAV (PCM only), W64, RF64, AGM
    (3) WAVs (multiple mono WAV files, PCM only)
    (4) AC3
    (5) DTS
    (6) AAC
    (7) FLAC
    
    I'll see what I can do to work in an aac section. There's certainly the option to go stereo with "-down2", but would 5.1 aac > 5.1 ac3 be better?
    Whoops! Spoke too soon. eac3to doesn't support aac natively. I got this error just now:
    Code:
    MKV, 1 video track, 3 audio tracks, 0:01:40, 24p /1.001
    1: h264/AVC, Japanese, 720p23.975
       "AVC (720p)"
    2: AAC, Japanese, 2.0 channels, 48khz
       "AAC (Original/Instrumental)"
    3: AAC, Japanese, 2.0 channels, 48khz
       "AAC (Miku Hatsune voice)"
    4: AAC, Japanese, 2.0 channels, 48khz
       "AAC (Instrumental)"
    v01 The video bitstream is encoded in a non-standard framerate.
    v01 The video bitstream framerate field doesn't match the container framerate.
    a02 Extracting audio track number 2...
    a02 Decoding with DirectShow (Nero Audio Decoder 2)...
    a02 Getting "Nero Audio Decoder 2" instance failed.
    Aborted at file position 1310720.
    
    If there's a CLI program that does aac processing, I'll gladly add it in! :up:
     
  4. superflysocal

    superflysocal Member

    70
    0
    Nov 26, 2009
  5. txporter

    txporter One sec, almost done

    666
    0
    Sep 17, 2006
    Austin, TX
    If you read down at the end of the instruction screen for eac3to, it says you need Nero AAC Encoder for eac3to to encode to AAC. I think you can get it here. I really haven't messed around with it much, but have done 1 or 2 encodes with it just to experiment.
     
  6. KevinSartori

    KevinSartori New Member

    11
    0
    Jul 1, 2004
    Connecticut,...
    If you're running Windows Vista or 7 the SendTo folder is in a different place. So, for Step 4, Open Windows Explorer and go to this folder instead:

    %UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo

    BTW, nice work on this orangeboy! Thanks!
     
  7. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Thanks Kevin - Instructions updated!
     
  8. nickels

    nickels opinionated dope

    6,458
    142
    Jan 11, 2010
    Warrington, PA
    I tried this yesterday and something went wrong. My video framerate is too fast and the audio doesn't sync due to this video issue. I am using Windows 7 and I tried both options (mp4creator and mp4box). HELP PLEASE!
     
  9. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Does it happen consistently, or just one file? Does the .mkv playback ok before being "converted" to .mp4?

    If it's consistent, about halfway down the script (line 395), you'll see a section that looks like this:
    Code:
    :Done
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This section ends the processing of this batch file.                      ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    EXIT /B
    
    If you would, make a small modification:
    Code:
    :Done
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This section ends the processing of this batch file.                      ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    SET
    PAUSE
    EXIT /B
    
    That will show all the variables (unfortunately, even System variables, but I can weed through those), and PAUSE. Copy what's on the screen (right click on the script's Title bar > Edit > Select All > Press <ENTER>) and PM me that information. A copy of the script's .ini file may be handy for me, too...
     
  10. ajayabb

    ajayabb Member

    429
    0
    Jan 11, 2007
    Moorestown NJ
  11. Spenner

    Spenner Member

    89
    2
    Mar 28, 2006
    Your batch is awesome. Can I put in a little request for it to include a Preferred Language setting? That way if your preferred language is Eng, and a video has two audio tracks Eng and something else, it will use the highest-scoring English track even if another track has a higher score.
     
  12. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Cool! :up:
    I downloaded the zip (after entering nothankyou@domain.com :D), and will take a look at the exes inside. I imagine this will add additional processing time if invoked, but the benefits could outweigh that...
     
  13. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    Uh-oh. Is the following falling through?
    Code:
    FOR /F "tokens=1,2 delims=,/ " %%A IN ('FINDSTR "%aLang% %sLang%" %SourceInfoName%') DO (
    	SET track_ID=%%A
    	SET track_type=%%B
    	IF DEFINED track_type CALL :!track_type! !track_ID! !track_type! %aLang% %sLang%
    )
    
    The above should select the audio/subtitle language set during the "First Run Setup" dialog:
    Code:
    :Audio_Language
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This section prompts the user for the preferred audio language.           ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    CLS
    ECHO.
    ECHO * Audio language 
    SET /P aLang=Enter your preferred audio track language: 
    SET aLang= %aLang%
    CALL :TitleCase aLang
    SET aLang=%aLang: =%
    IF NOT DEFINED aLang GOTO Audio_Language
    
    Unless the the language reported is literally "Eng", and not "English"? I may be able to substring the language variable to the first the characters, but I'm not sure that would work for all language abbreviations...
     
  14. nickels

    nickels opinionated dope

    6,458
    142
    Jan 11, 2010
    Warrington, PA
    I just installed a newer version of pyTivo and the MKV files are now transferring normally without the need for conversion. So, I am done troubleshooting and thanks!
     
  15. jcthorne

    jcthorne Active Member

    2,786
    18
    Jan 28, 2002
    Houston
    pyTivo cannot push an mkv to tivo without conversion to mpeg2. Only an mp4 can be pushed to tivo containing an h.264 video stream.....So far.
     
  16. KevinG

    KevinG Member

    305
    1
    Sep 3, 2003
    Mt. Laurel, NJ.
    I've just started using this wonderful tool...thank you for providing it!

    Now, a question.

    I've currently got sabnzbd listening to RSS feeds, grabbing files, and calling a batch file which pushes said files automatically to one of my tivos.

    What I'd like to do is insert this process before the push.

    Has anyone successfully automated that entire process? Interesting tidbits that I'm thinking about...how to only run the process on MKVs. How to delete the MKVs only upon successful conversion to MP4?

    Thanks again.
    -Kevin
     
  17. orangeboy

    orangeboy yes, I AM orangeboy!

    4,087
    0
    Apr 19, 2004
    East Moline, IL
    I had a reply drafted, but ended up dropping it all and starting over. I think the toughest thing to overcome with the RSS feeds is determining the filename of the extracted result of the feed. According to the SABnzbd User-Script Wiki, the only filename that is passed is the original .nzb. However, in your "push" bat, you may still be able to use the passed SABnzbd arguments, similar to this:

    Code:
    FOR /F "delims=" %%a IN ('DIR /B /S /A-D "%~1\*.mkv"') DO mkv2tivomp4.bat "%%a"
    
    That should search all the directories and sub-directories for mkv files, rooted in the "The final directory of the job (full path)", or %1.

    Yep, that's a logic fail on my part. :(
    I "post-process" regardless of whether a valid .mp4 file is created or not, instead of just jumping to the next mkv file (if there is one). That should be an easy thing to fix though, and I'm VERY glad you brought it up! I don't like code that executes when it shouldn't.

    In the meantime, around line 294 begins a "cleanup" section. You could add a line in the group of "IF EXIST"s that would delete the original .mkv file:

    Code:
    IF EXIST "%SourceFullPath%" DEL "%SourceFullPath%"
    
    Although I thought about adding that as the default action, I've found some mkv source files that didn't play on my TiVos after being remuxed into the mp4 container. Having the original mkv file around to run mediainfo on made it helpful to figure out "why".
     
  18. KevinG

    KevinG Member

    305
    1
    Sep 3, 2003
    Mt. Laurel, NJ.
    Yes, this is tough, but I've already solve that part. I run a batch program which calls a perl program which does a "glob" on the directory and finds the "newest" mkv file. Then I use curl to push it to the tivo. This only fails when I grab an "older" nzb and the resulting mkv isn't the "newest" one in the folder. I've tried getting perl to recognize the "write" datestamp, instead of the "creation" datestamp, but it doesn't seem to work on Windows (but works fine on linux).

    Anyway, I'll have to look into your other suggestions...maybe I'll just call mkv2tivo inside my perl script...

    Thanks again!
     
  19. zabolots

    zabolots Member

    79
    0
    May 24, 2007
    NW Chicago...
    Great batch file. I've used it on a few MKV's and it worked great, but I've got a couple of others that are giving me issues. Here's the output:
    Code:
    The format of the source file could not be detected.FINDSTR: Cannot open Boardwa
    lk.Empire.S01E01.mkv.info.txt
    FINDSTR: Cannot open Boardwalk.Empire.S01E01.mkv.info.txt
    FINDSTR: Cannot open Boardwalk.Empire.S01E01.mkv.info.txt
    FINDSTR: Cannot open Boardwalk.Empire.S01E01.mkv.info.txt
    Valid video stream not found. Please review the information in "Boardwalk.Empire
    .S01E01.mkv.info.txt".
    
    Unfortunately there is no .txt file to get add'l info. There is briefly a .tmp file but it is deleted when the batch file ends so I have no idea what it contains.

    Here's the mediainfo output for the file:

    Code:
    General #0
    Complete name        : \temp\DVD\Boardwalk.Empire.S01E01.mkv
    Format               : Matroska
    File size            : 2.19 GiB
    PlayTime             : 1h 12mn
    Bit rate             : 4330 Kbps
    Writing application  : x264.exe
    Writing library      : mkv2rls x264-tv version built on 2010 jul 11
    
    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
    
    Audio #0
    Codec                : AC3
    Codec/Info           : Dolby AC3
    Channel(s)           : 6 channels
    Sampling rate        : 48 KHz
    Title                : English
    Language             : English
    
    Text #0
    Codec                : UTF-8
    Codec/Info           : UTF-8 Plain Text
    Title                : English
    Language             : English
    
     
  20. Spenner

    Spenner Member

    89
    2
    Mar 28, 2006
    I've gotten that sometimes too. It's some kind of file or folder permission issue on the source. Just copy the mkv file to another folder and try it again, and that usually works for me.
     

Share This Page