Converting videos for portable devices (including softsubs)

This forum is for questions and discussion of all the aspects of handling your footage. If you have questions about capturing/ripping footage, AviSynth, or compression/encoding/converting, look here.

Converting videos for portable devices (including softsubs)

Postby Corran » Mon Jul 20, 2009 11:14 pm

Actually, the encodes follow the baseline profile so they should work on anything that that can play h.264 content such as the PS3, etc.

Before I say anything else, this particular process requires a Windows pc. Sorry linux/mac users. If you examine my script you might be able to recreate what it is doing and make something even better than I have. MSDOS is very limited...

Anyways, a week or so ago I wanted to load a softsubbed file onto my T-Mobile G1 to watch while riding in someone's car. I quickly discovered that softsub support on the plethora of video conversion apps is lacking for matroska files. Some apps can do it, but they require the subtitle file to first be extracted from the MKV. Annoying.

I was also kind of annoyed at the fact that pretty much all of the converters felt bloated and slow. Some of them were chalk full of ads, even the one I found on sourceforge... I just wanted something quick and simple without any other crap. So I created a batch file that will encode any video file I drag on top of it and packaged it into a self-contained zip archive.

Convert MP4 Portable 1.1.2

Before you begin you must obtain a copy of neroAacEnc.exe and MP4Box.exe and plug them into their respective folders in the "tools" directory. It is a pain in the ass, but distributing binary versions of these files is legally dubious so I'm covering myself by keeping them out of the zip. NeroAacEnc can be found at the Nero website which is linked below. If you have ZarxGUI then you probably already have MP4Box somewhere on your computer... if not search the internet for mp4box builds. Aside from GPAC source code, I will not be linking to mp4box binaries here.

neroAacEnc download link
MP4Box source code

To convert files you have two options:
  1. You can drag a single video onto the batch file or...
  2. You can fill the "files_to_process" folder with videos and then double click on the batch file. In this case, once the original video files are processed they will be moved to the "processed_files" folder.

In either case, once encodes are complete, they can be found in the "converted_files" folder.

There are some pros and cons to this approach, most of the cons are a result of MS DOS limitations.

PROS
  • Simple (drag file onto batch, wait for process to finish, load file onto your ipod/android device)
  • Batch processing
  • Can handle softsubs
  • Supports a lot of files types and codecs. (Will encode pretty much anything mplayer can play. I've tested it with avi, mp4, mkv, mov, asx, wmv, mpeg, divx, and ogm files as well.)

CONS
  • I can't detect fps so I'm converting every video to 29.97 fps. However, I have not noticed any audio sync issues in my testing...

Settings:
You can change the bitrate of the audio and video, width of the resulting encodes, which language subtitle to use, and whether or not to run 2 pass encoding by editing some variables in the batch file. Just right click the file and choose edit.

I might be forgetting some things but that is pretty much it. Hope people find this useful.
User avatar
Corran
 
Joined: 14 Oct 2002

Re: Converting videos for portable devices (including softsubs)

Postby AaronAMV » Mon Jul 20, 2009 11:25 pm

So you can drag a softsub into the .bat, and the result will be an mp4 (for iTouch as an example) with subs? That's awesome! Good job sir.
Image
User avatar
AaronAMV
eating that e. coli spinach
 
Joined: 22 Jan 2008
Location: (◔ ◡ ◔ )
Status: (◔ ◡ ◔ )

Re: Converting videos for portable devices (including softsubs)

Postby Pwolf » Tue Jul 21, 2009 1:30 am

i run a bat file to encode stuff for my xbox. to handle multiple files, I copy them all to a folder then run another bat file called "run.bat" which takes each file (mkv files specifically) in the folder and runs the "encode.bat" file on it.

run.bat
Code: Select all
for /f "tokens=*" %%a in ('dir /s /a /one /b *.mkv') do convert.bat "%%a"


Hope that helps.


Pwolf
ImageImage
ImageImage
Like the AMV .Org App? Think about donating to help me make it better.
User avatar
Pwolf
Friendly Neighborhood Pwaffle
 
Joined: 03 May 2001
Location: Some where in California, I forgot :\

Re: Converting videos for portable devices (including softsubs)

Postby Pwolf » Tue Jul 21, 2009 1:33 am

i guess it's "convert.bat", not "encode.bat" >.> i'm sure you got the point :P


Pwolf
ImageImage
ImageImage
Like the AMV .Org App? Think about donating to help me make it better.
User avatar
Pwolf
Friendly Neighborhood Pwaffle
 
Joined: 03 May 2001
Location: Some where in California, I forgot :\

Re: Converting videos for portable devices (including softsubs)

Postby hasteroth » Tue Jul 21, 2009 1:35 am

Fucking awesome.

I need this for my iPod.

Thank you!
<Hacchinya> Stirspeare: ambassador of gaysex
<Stirspeare> Hacchinya: God's own ambassador.
User avatar
hasteroth
lost the bet
 
Joined: 25 Feb 2008
Location: Around
Status: Neither here nor there

Re: Converting videos for portable devices (including softsubs)

Postby Qyot27 » Tue Jul 21, 2009 2:11 pm

Couldn't MediaInfo be accessed to provide the fps detection? The operation could be called against the library or the CLI interface, although I have no idea how difficult that would be. I don't write complex BAT scripts like that, and most of what I use MediaInfo for is to quickly get timestamp readouts, although I have snagged FPS and resolution information for non-MP4/MOV files from it before (for MP4 and MOV I use mp4info, which is part of the MPEG4IP package, in conjunction with mp4box -info).
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: Converting videos for portable devices (including softsubs)

Postby Corran » Tue Jul 21, 2009 2:36 pm

Qyot27 wrote:Couldn't MediaInfo be accessed to provide the fps detection? The operation could be called against the library or the CLI interface, although I have no idea how difficult that would be. I don't write complex BAT scripts like that, and most of what I use MediaInfo for is to quickly get timestamp readouts, although I have snagged FPS and resolution information for non-MP4/MOV files from it before (for MP4 and MOV I use mp4info, which is part of the MPEG4IP package, in conjunction with mp4box -info).


I could use mplayer's own -identify switch to get the fps but the difficulty lies in parsing the output. I'm not sure how to do it in MS-DOS.
User avatar
Corran
 
Joined: 14 Oct 2002

Re: Converting videos for portable devices (including softsubs)

Postby Corran » Tue Jul 21, 2009 4:11 pm

Added ability to batch process files. Thanks pwolf. Also added a few more variables to for greater control over encoding.

On the downside, I've removed some of the third-party executables from the zip file. You will need to download them yourself before the batch file will work. I'm not going to help you find them, use a search engine.

Unless there are bugs, this is the final version. I've GPL'ed the batch files so if you want to improve upon it and distribute a modified version, you are more than free to do so.

EDIT: Replaced aacplusenc with nero's aac encoder, as it is a better encoder and easier for everyone else to get a hold of legally. You will need to get neroAacEnc from the nero website.

EDIT: Silent update to fix problems with filenames using exclamation marks.
User avatar
Corran
 
Joined: 14 Oct 2002

Re: Converting videos for portable devices (including softsubs)

Postby fobboy » Wed Aug 05, 2009 9:51 pm

I tried running the program, but it doesn't seem to work for me. I've downloaded both the neroAacEnc.exe and the mp4box.exe (from zarx264gui) and placed them in their respective folders within the "Tools" directory. But when I go to run encode.bat it keeps saying "Error mp4box.exe does not exist...". I've tried multiple versions of mp4box.exe (found through google), but none of them work. Can anyone advise me?
fobboy
 
Joined: 26 Dec 2006

Re: Converting videos for portable devices (including softsubs)

Postby Corran » Thu Aug 06, 2009 8:27 am

I noticed that you tried sending me a PM, but when I went to my PM box, the private messages panel says: "This message has been removed by its author before it was delivered."

Were you able to solve your problem?

When the "Error mp4box.exe does not exist." message appears, that simply means that the batch file was unable to find MP4Box where it expected to. It has nothing to do with the version of MP4Box you are using.

Please let me know your answers to the following questions:

  • Did you completely copy the folder "ConvertMP4Portable-1.1-Final" from the downloadable zip to some location on the hard drive? The batch file won't be able to run properly if it and the other files and folders are still in the zip.
  • What is the name of your mp4box executable? The batch file expects it to be named "mp4box.exe" and located at ".\tools\mp4box\mp4box.exe". If the file is named differently (i.e. "mp4box-v0.4.5.exe") then the batch won't find the file. The check the batch file performs is case insensitive, meaning both "mp4box.exe" and "MP4Box.exe" are suitable names. The copy of mp4box in Zarxgui is spelled as the batch file expects so this probably isn't your problem since you mentioned using it... (At least if you are using the version currently in the amvapp.)
  • What version of Windows are you using? I've only been testing on Vista up to this point. I have an XP machine I can test on too if necessary.
User avatar
Corran
 
Joined: 14 Oct 2002

Re: Converting videos for portable devices (including softsubs)

Postby Bakadeshi » Thu Aug 06, 2009 6:00 pm

oh I see i'm not the only person around here who thought of writing a tool to batch process files for webstreaming and portable devices :up:

except my tool is written in vb.net, but uses mencoder, ffmpeg, neroacc, and some various other cmdline tools to do the actual processing work.
I first wrote it to batch encode all the amvs on aunstudios for streaming, and ended up just adding other formats (such as nintendo DS and PSP formats)

if your curious, I have a earlier copy here but should be treated as alpha software, some things don't work yet. mp4, mp4 for streaming, flv for streaming, mpeg for conventions, and mp4 for psp formats should work 100%, but all settings are optimized for anime and amvs, so may not produce best quality for live action.
User avatar
Bakadeshi
Abuses Spellcheck
 
Joined: 29 Sep 2003
Location: Atlanta, GA

Re: Converting videos for portable devices (including softsubs)

Postby fobboy » Thu Aug 06, 2009 7:14 pm

I did you send you a pm about the problem in case you were no longer looking at your post. But I thought it worked like e-mail in that once I send the message off it'll be in your inbox regardless of whether I deleted the message from my outbox. Apparently not. But it's in regards to the same thing anyways.

1) I have completely extracted the ConvertMP4Portable-1.1-Final zip file to my desktop.

2) The name of my exe file is MP4Box.exe (the same file name as the one provided by Zarx264gui and downloaded from the same link you posted). I have turned off hiding extensions of known file types.

3) I am using XP. This might be the problem. I don't have a Vista machine, so if you would be so kind as to test it out on your XP machine.

Thank You
fobboy
 
Joined: 26 Dec 2006

Re: Converting videos for portable devices (including softsubs)

Postby Corran » Thu Aug 06, 2009 7:55 pm

Looks like version of OS doesn't really matter in this case. The reason you are having problems is that you are running it from the desktop. On XP the user's desktop path is "C:\Documents and Settings\<username>\Desktop\". The spaces in "Documents and Settings" is causing problems. If I create a folder with spaces on Vista and then run the batch from within that, I get the same problems.


Move the folder to a directory that does not have spaces in its path for now I will work on fixing the code and upload a fixed version later.


Edit: New version uploaded. Link is in first post.
User avatar
Corran
 
Joined: 14 Oct 2002

Re: Converting videos for portable devices (including softsubs)

Postby fobboy » Fri Aug 07, 2009 1:10 am

Brilliant! You've hit the nail on the head.

Now I have errors while running the batch...I think the program hates my computer.

While running the batch, the following errors were experienced:
1) Matroska file format detected.
Video [avc1] 1280x780...............
=============================================
Forced video codec: dummy
Cannot find codec matching selected -vo and video format 0x31637661.
==============================================
==============================================
Trying to force audio codec driver family libmad...
Opening audio decoder: [faad] AAC
FAAD: compressed input bitrate missing, assuming 128kbit/s!

2) Processed 1379 seconds...
"Muxing files for "[SZN_&_I-O]_Hajime_no_Ippo_New_Challenger_-_01[720p][1B50A5AA]_v2.mkv"

After this step, a popup shows up saying "MP4Box.exe has encountered a problem and needs to close. We are sorry for the inconvenience.

I click on "Don't Send", then batch file says everything has been completed. I go to converted files, and all I see is an xml and a txt file.


Note: I have no idea what these problems are but I assume it has something to do with a missing codec. I believe the only codec I installed were the ones batched with CCCP (Combined Community Codec Pack).


One other question though: Are there any options available when converting the videos (Output resolution in particular)?
fobboy
 
Joined: 26 Dec 2006

Re: Converting videos for portable devices (including softsubs)

Postby Corran » Fri Aug 07, 2009 3:05 am

I think I know what I can do to prevent the first error but it is safe to ignore, it won't mess up the encode. The second error might be related to the version of mp4box that you are using. Are you trying the version found in Zarxgui? I remember you saying that you had used it but that you also tried using other versions. The one in Zarxgui I think doesn't output text and xml files though, afaik.
http://amvhell.com/stuff/zarx264gui/


To change some output settings, right click the encode.bat file, select edit, and at the top of the file there will be some variables. The one that controls resolution is targetwidth. Height automatically scales depending on this value in order to maintain the video's aspect ratio.
User avatar
Corran
 
Joined: 14 Oct 2002

Next

Return to Footage Help

Who is online

Users browsing this forum: No registered users and 2 guests