View Full Version : Another tiny drag'n'drop D2 video converter
Hi.
I've wrote a script to automatically convert videos using mencoder (http://www3.mplayerhq.hu/MPlayer/releases/win32/MPlayer-mingw32-1.0rc1.zip) and ffmpeg (http://ffdshow.faireal.net/mirror/ffmpeg/) (attached to this post, also on my site (http://not.textual.ru/zverik/any-to-d2-12.zip)). If you drag'n'drop a video file onto it, you'll get .avi encoded with 2 passes, bitrate 400, mp3 ~192 kbps and audio remuxed with ffmpeg.
As for .avi/.mkv/.mpg, a/v sync and quality is good. If you're quality freak, you may try to use d2_hq.bat in the archive, it encodes with "-preset extreme" and fixed quantizer of 2. If you want to process multiple files with default settings, drop them onto d2_multi.bat.
There are some other options you can know by running d2.bat from command line. The most useful are -4 and -2 for frame dimensions of 4:3 and 2.35:1, -1 for one-pass encoding using quantizer (-q N, default is 3), -b N for setting bitrate to N, -ac for copying source audio stream without reencoding and so on.
Subtitles are included automatically if they have the same name as video file.
Today I was preparing a lot of different video files for D2, and it turned out that default settings are perfect (for me :) , so I've decided to share this script with you. It works only under Windows, sorry.
I'd like to thank you for all your hard work and effort! GREAT JOB!
elviselvis
10-13-2007, 15:49
wow it looks that now there are 3 specialized converters for Cowon D2
"D2 Video" by MaxSt
your "Any To D2"
my "iLove"
Which player have (its own [biggrin]) outragerous customer support like the Cowon D2? ANYONE !!!! hehe
[thumbsup][thumbsup][thumbsup]
btw can anybody make this thread [B]sticky?
Dalmane98
10-13-2007, 18:54
PM DonIago and ask him if he will make it a stickey. He is a Moderator.
That is the way it is done.
I would think that you would want your thread about iLove being made a sticky before this short one.
elviselvis
10-14-2007, 01:32
PM DonIago and ask him if he will make it a stickey. He is a Moderator.
That is the way it is done.
I would think that you would want your thread about iLove being made a sticky before this short one.
Since yesteday it is sticky http://iaudiophile.net/forums/forumdisplay.php?f=59
the first one
Hi again.
If anyone uses my script, version 1.1 (http://not.textual.ru/zverik/any-to-d2-11.zip) is out. It features d2r.bat, which determines source video parameters using mplayer.exe and chooses right frame dimension, audio and subtitle switches for d2.bat. Now you can drop the whole ton of videos onto d2_multi.bat and be sure that they will encode correctly.
Now I don't see any ways to improve the script :)
The reason why this script appeared is that I didn't like the configuration method of d2video and over-complicativeness of iLove (though those must be great for most people). And I also like using command-line tools. And I don't usually encode flash videos or DVDs straight to D2. But in process it became unnecessary to specify any switches for this script except bitrate setting (and default bitrate is ok for me), so d2_multi.bat+d2r.bat+d2.bat can be considered as another simple drag'n'drop converting tool :)
It needs mencoder.exe and ffmpeg with its dll. Also, d2r.bat needs mplayer.exe.
elviselvis
10-16-2007, 11:40
... and over-complicativeness of iLove (though those must be great for most people) ...
love is always complicated ... , i don`t understant to it [biggrin][laugh]
my D2video gets source video parameters from mencoder.exe itself... :)
elviselvis
10-16-2007, 15:07
my D2video gets source video parameters from mencoder.exe itself... :)
me too, text output from mencoder and mplayer are the same, i dont see any reason why to use mplayer in this case ...
by the way - do you anybody knows if exists something like GSPOT but with command line?
by the way - do you anybody knows if exists something like GSPOT but with command line?
That would be cool. [rolleyes]
elviselvis
10-16-2007, 16:14
That would be cool. [rolleyes]
i have found "media info" http://mediainfo.sourceforge.net/en/Download , but it don`t support framerate parameter for flv file, so it is unusable
i have also found a way how to get this value from GSPOT throught command line, but it works only if is gspot right installed in Windows`s register (with some exact special settings), so it is not good idea to always when you want for example to get fps information to hack a Windows`s register, because somebody can have installed more than one gspot in computer and it can cause problems
i also found AviMaster, but it dont support flv files
love is always complicated ... , i don`t understant to it
Heh, I've got one that's not :P
my D2video gets source video parameters from mencoder.exe itself... :)
How? Is there something like -identify? Alas it's very hard to parse strings in Windows batch files, "KEY=VALUE" format that mplayer uses came very handy...
mplayer.exe and mencoder.exe are distributed in a single archive, so that wouldn't be a problem, I think..
elviselvis
10-17-2007, 05:09
Heh, I've got one that's not :P
How? Is there something like -identify? Alas it's very hard to parse strings in Windows batch files, "KEY=VALUE" format that mplayer uses came very handy...
mplayer.exe and mencoder.exe are distributed in a single archive, so that wouldn't be a problem, I think..
Heh, I've got one that's not :P
How? Is there something like -identify? Alas it's very hard to parse strings in Windows batch files, "KEY=VALUE" format that mplayer uses came very handy...
mplayer.exe and mencoder.exe are distributed in a single archive, so that wouldn't be a problem, I think..
You know, if that woman is a girlfriend of your best friend, then it is REALY complicated ...
I have never programmed in Bash (only things like delete file), but this is universal guide how to do that:
For parsing of Mencoder`s output is relatively good prepared for parsing, so you only seek to the beginning of whan you want to know, from this position you will find first unique character(s) which is on the end of whan you want to know, then copy the length which is equal to the difference between first and last character, and in this copied string you will seek at the position of the first space character, and it is all, you only copy "value" part
here is the exaple code (written in Delphi 2007) which shows parsing of framerate:
findedsourcefps :=
Copy(
mencodertextoutput,
Pos('fps',mencodertextoutput)-9, 8);
findedsourcefps :=
Copy(
findedsourcefps,
LastDelimiter(' ',findedsourcefps)+1, length(findedsourcefps)-LastDelimiter(' ',findedsourcefps)
);
this showing parsing of resolution:
findedsourceresolutiontagposition := Pos('size:',mencodertextoutput);
findedsourceresolutiontagposition :=
findedsourceresolutiontagposition + 5;
findedsourceresolutiontag := Copy(
mencodertextoutput,
findedsourceresolutiontagposition,
Pos(' ',Copy(mencodertextoutput,findedsourceresolutionta gposition,length(mencodertextoutput)-findedsourceresolutiontagposition)) - 1
);
findedsourceresolutionwidth :=
strtofloat(Copy(findedsourceresolutiontag,
0,
Pos('x', findedsourceresolutiontag) - 1));
findedsourceresolutionheigth :=
strtofloat(Copy(findedsourceresolutiontag,
Pos('x', findedsourceresolutiontag) + 1,
length(findedsourceresolutiontag) - Pos('x', findedsourceresolutiontag)));
You know, if that woman is a girlfriend of your best friend, then it is REALY complicated ...
Ok, I'll never reach those heights :) Good luck to you!
I have never programmed in Bash (only things like delete file), but this is universal guide how to do that:
It's all good, but this script is plain Windows batch file, like in "@echo off" :) The only mean of parsing strings is to feed them to a "for" statement, which isn't so flexible...
How? Is there something like -identify?
mencoder.exe input.avi -o temp
Alas it's very hard to parse strings in Windows batch files
Sure, but there are more powerful tools available. Besides, I'm not sure you can calculate crop correctly, since the calculations are not so simple. Especially if the source pixels are not square, as it often happens with mpeg-2 files.
elviselvis
10-17-2007, 17:42
mencoder.exe input.avi -o temp
NOOOO!!! that is wrong!
this is right and faster (and without creating any file):
"C:\mencoder.exe" "C:\inputvideo.avi" -o NUL -endpos 0:0:0:1 -oac pcm -ovc copy
elviselvis
10-17-2007, 17:48
by the way, if you need an example of anything, then here http://www.jakubsloup.cz/iLove/html3.1/Unit1.html is showed kernel unit of iLove, so you can get example from it
NOOOO!!! that is wrong!
this is right and faster (and without creating any file):
Why not? It's short and simple.
It doesn't create any files, it exits immediately because -oac and -ovc are missing. Try it.
elviselvis
10-18-2007, 00:34
Why not? It's short and simple.
It doesn't create any files, it exits immediately because -oac and -ovc are missing. Try it.
no, the text output is different with my and your command.
this is with my command:
C:\>"C:\mencoder.exe" "C:\b.avi" -o NUL -endpos 0:0:0:1 -oac pcm -ovc copy
MEncoder 1.0rc1-3.4.2 (C) 2000-2006 MPlayer Team
CPU: Intel(R) Pentium(R) M processor 1400MHz (Family: 6, Model: 9, Stepping: 5)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled with runtime CPU detection.
success: format: 0 data: 0x0 - 0x53104
AVI file format detected.
VIDEO: [XVID] 528x288 12bpp 25.000 fps 277.2 kbps (33.8 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:528x288 fps:25.00 ftime:=0.0400
================================================== ========================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
================================================== ========================
videocodec: framecopy (528x288 12bpp fourcc=44495658)
Writing index... 1f ( 2%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp h
eader.
Video stream: 1866.800 kbit/s (233349 B/s) size: 9334 bytes 0.040 secs 1 fra
mes
Audio stream: -1.#IO kbit/s (-2147483648 B/s) size: 0 bytes 0.000 secs
and this is with your command:
C:\>mencoder.exe b.avi -o temp
MEncoder 1.0rc1-3.4.2 (C) 2000-2006 MPlayer Team
CPU: Intel(R) Pentium(R) M processor 1400MHz (Family: 6, Model: 9, Stepping: 5)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled with runtime CPU detection.
success: format: 0 data: 0x0 - 0x53104
AVI file format detected.
VIDEO: [XVID] 528x288 12bpp 25.000 fps 277.2 kbps (33.8 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:528x288 fps:25.00 ftime:=0.0400
No audio encoder (-oac) selected. Select one (see -oac help) or use -nosound.
Exiting...
as you can see the output in your case is shorter, the audio information missing, which is important for my application
Well, I don't care for that. I only need resolution and aspect.
Well, I don't care for that. I only need resolution and aspect.
Why not to check if original audio stream can be preserved?
By the way, I use "-frames 0" instead of -endpos :)
Sure, but there are more powerful tools available. Besides, I'm not sure you can calculate crop correctly, since the calculations are not so simple. Especially if the source pixels are not square, as it often happens with mpeg-2 files.
It's all precalculated, I've spent several days on fine-tuning. And I use "-2" scaling value, so mencoder does half the work.
elviselvis
10-18-2007, 03:28
Why not to check if original audio stream can be preserved?
By the way, I use "-frames 0" instead of -endpos :)
It's all precalculated, I've spent several days on fine-tuning. And I use "-2" scaling value, so mencoder does half the work.
I also using -2, but this is useles if you want crop or zoom it and it have non-square pixels. So some corrections have to be made.
It is very good showed, here http://www.jakubsloup.cz/iLove/html3.1/Unit1.html, search for term
"correction of mpeg 1/2 aspect ratio", it is approximately in the 1/3
Ok i will try to use -frames 0, maybe it is faster, but i think that i already tested it and it caused problems with some videos, but i`m not sure
I also using -2, but this is useles if you want crop or zoom it and it have non-square pixels. So some corrections have to be made.
It is very good showed, here http://www.jakubsloup.cz/iLove/html3.1/Unit1.html, search for term
"correction of mpeg 1/2 aspect ratio", it is approximately in the 1/3
Hmm... I have one 352x288 (5:4) mpeg video, which when using -3 scale zoomed to 300x240, with -2 - 320x240 (4:3). The same with 720x576 mpeg2 (prescales to 16:9). There is aspect ratio information in mpeg files that mencoder takes into accout.
But I've just noticed that my frame aspect autodetection fails on mpeg2 16:9, since mencoder doesn't print correct aspect ratio. It doesn't result in shrunk image, just 22% of the frame is cropped out. Gonna look into this.
Ok i will try to use -frames 0, maybe it is faster, but i think that i already tested it and it caused problems with some videos, but i`m not sure
That's the same as -endpos 0. The only problem I've seen is when audio stream starts a bit later than video, but that doesn't matter, just one warning line in the output.
elviselvis
10-18-2007, 04:04
But I've just noticed that my frame aspect autodetection fails on mpeg2 16:9, since mencoder doesn't print correct aspect ratio. It doesn't result in shrunk image, just 22% of the frame is cropped out. Gonna look into this.
The aspect ratio which mencoder say is very innacurate, for example if aspect is 1,777777:1 it say 1,8:1
and in addition if aspect ratio is 16:9 it say "(aspect 3)", if 4:3 it say "(aspect 2)"
so it is better to detect "(aspect x)" statement
Not "1,8:1", but "1,78:1", which is just 0.1% incorrect.
After some more testing I should say "-frames 0" gives incorrect results.
I replaced it with "-frames 1 -va null -vo md5sum:outfile=nul". In this case mplayer writes actual aspect ratio which is parsed and used.
Btw, aspect=12 is what ratio? :)
mplayer reads it right, but mencoder fails, and the resulting video is squeezed.
elviselvis
10-18-2007, 08:35
Not "1,8:1", but "1,78:1", which is just 0.1% incorrect.
0,1 % is a lot if final resolution is only 320x240, in this resolution it is a 1/4 of pixel, and since i using this also for cropping and zooming (these are applied in series, one filter after another filter), it is too much because this inacurrance can be one or two pixels - and it is definitely visible
After some more testing I should say "-frames 0" gives incorrect results.
I replaced it with "-frames 1 -va null -vo md5sum:outfile=nul". In this case mplayer writes actual aspect ratio which is parsed and used.
I also tried it and it say that it "-va" option is unknown ... i have no clue why...
but it is not important, after some test this seems to be fastest:
"C:\mencoder.exe" "C:\b.avi" -o NUL -frames 1 -oac pcm -ovc copy
Btw, aspect=12 is what ratio? :)
mplayer reads it right, but mencoder fails, and the resulting video is squeezed.
Unfortunately, this part of mencoder is undocumented, i don`t know, but i presume that it can mean 2,35:1
elviselvis
10-18-2007, 08:46
sorry my fault, the
"C:\mencoder.exe" "C:\b.avi" -o NUL -endpos 0:0:0:1 -oac pcm -ovc copy
is faster than
"C:\mencoder.exe" "C:\b.avi" -o NUL -frames 1 -oac pcm -ovc copy
Version with -frames 1 takes 11 seconds and version with -endpos 0:0:0:1 takes 7 seconds. Maybe it is only some inaccurance and both options are the same.
note: i inserted 33 videos
aspect=12 is 1.185:1, 320x270 :)
I guess there are other aspect ratios...
mplayer with my parameters is certainly faster than mencoder with yours :P
3-4% distortion is not visible, at least for me. That's why I shrink videos a little with my script. And you cannot know what was done to video in process of reencoding it to DVD and then ripping to avi...
elviselvis
10-18-2007, 10:28
aspect=12 is 1.185:1, 320x270 :)
I guess there are other aspect ratios...
mplayer with my parameters is certainly faster than mencoder with yours :P
3-4% distortion is not visible, at least for me. That's why I shrink videos a little with my script. And you cannot know what was done to video in process of reencoding it to DVD and then ripping to avi...
Speed is thing that realy don`t interest me ... i made it for pleasure and learning purposes
And in addition main reason why is iLove so slow is that it encodes twice:
first it convert video stream
second it convert audio stream
third it mux it together in FFMpeg
i can see 1 pixel difference, i`m videophile; it is the same as some people can hear difference between 192 and 256 kpbs mp3 and others not; i have minus 2,5 dioptries, so my eyes see everthing bigger and sharper (on short distance) at the cost that i can`t see detail in long distance
The time has come to release version 1.2 (http://not.textual.ru/zverik/any-to-d2-12.zip). Changes list:
+ a/v desync coming from duplicate frames was fixed
* d2r.bat (v1.1) fetches correct mpeg aspect ratio from mplayer
* lame preset standard is now default option, use -mp3 switch if you need 128kbps
* -qs for precise scaling method (slower by ~15%, higher required bitrate)
* more logical way to deal with anamorphed videos
* when incorrect frame size is specified, no stretching occurs
* quotation marks fix in d2_multi.bat
* file name is now first in window title
I'm experiencing no a/v sync problems, even broken videos are encoded correctly. VOB files are accepted. I've tested it only with mpeg2 music videos, though. Probably I'll implement separate audio and video encoding in the next version, but I still haven't encountered a video that has a/v desync noticeable enough to do such a work.
Thanks to elviselvis for rescaling method idea.
Great job, Zverik.
For a few weeks now I've been using your scripts to downscale tv shows for my D2 to watch on the train ride to work.
Version 1.0 worked perfectly for me, except for some 4:3 videos which came out a bit out of sync when playing on my pc and more heavily so on the D2. I'll try them with 1.2 and see what happens.
Hello.
I am not able to get the application to work. Can you help me? I have tried to drag and drop a mediafile to the d2.bat and d2r.bat (like it says in the text), but nothing happens. A dos-window opens for a split second, and then disappears again.
And a question: Is there any sync problems?
Help please...
Ingveo
how do i use this??? i unzipped and there are like 5 different files on my desktop...
Hello.
I am not able to get the application to work. Can you help me? I have tried to drag and drop a mediafile to the d2.bat and d2r.bat (like it says in the text), but nothing happens. A dos-window opens for a split second, and then disappears again.
Did you put mencoder.exe, mplayer.exe, ffmpeg.exe and ffsomething2.dll (comes with ffmpeg) in the d2.bat folder?
And a question: Is there any sync problems?
Probably there are on some files, but I still haven't encountered one.
how do i use this??? i unzipped and there are like 5 different files on my desktop...
You need only d2.bat, d2r.bat and d2_multi.bat files. Put them in some folder and also download mencoder/mplayer exe's and ffmpeg with dll (links are in the first post), then unzip them into d2.bat folder. After that, drag'n'drop any video file (or a bunch of them) onto d2_multi.bat.
..Im sorry, but I still dont get the application to work.....
I have the pthreadGC2.dll, ffmeg.exe, d2.bat, d2r.bat, d2multi.bat, mencoder.exe and mplayer.exe in the same folder......
Then if I understand it right it is just to drag and drop a *.avi-file onto it and it will start the converting????...... I cannot make this work. Once again the dos-windows show for about half a second and then it disapperars.....
Help, please.....((sorry)
i
Maybe you'll get better luck with my converter:
http://www.iaudiophile.net/forums/showthread.php?t=15977
It's kinda similar.
Yes, that one worked. Was quite quick as well, but a little bit out of sync.
Just to share my experience; the best converter is SUPER. It's the only one without syncproblem...all the other converters I have tested have syncproblem (more or less)...
With Super it looks as if it is sync-problem when you first start to look at the video. But if you press the "timeline" (go to another part of the video) and then start at the beginning again....the sync is PERFECT....
....this is just my opinion after testing about 10 different converters.
ingveo
Yes, that one worked. Was quite quick as well, but a little bit out of sync.
Just to share my experience; the best converter is SUPER. It's the only one without syncproblem...all the other converters I have tested have syncproblem (more or less)...
With Super it looks as if it is sync-problem when you first start to look at the video. But if you press the "timeline" (go to another part of the video) and then start at the beginning again....the sync is PERFECT....
....this is just my opinion after testing about 10 different converters.
ingveo
Which 10 converters?
....iriverter, kawairiverter, jetaudio, iLove, GOM, Any-to-D2, mplayer, Total Video Coverter and I'm sure some I don't remember....
ingveo
....iriverter, kawairiverter, jetaudio, iLove, GOM, Any-to-D2, mplayer, Total Video Coverter and I'm sure some I don't remember....
ingveo
Do you know that out-of-sync is result of many factors?
bitrate: normally about 500 kbps works fine
FPS: around 25 is excellent but depends on bitrate, 20 fps rarely fails
location of video: never locate a video on a SD card, except if it is a High speed card.
but never on a converter!!!... [rolleyes]
OK!
I did not know that....thought it was the converter that was the problem...
Still...some converters does not give you the opportunity to change the settings manually in the application (they just start)....and then you have to be a programmer to do the settings....??
Thank you for your information[smile]
OK!
I did not know that....thought it was the converter that was the problem...
Still...some converters does not give you the opportunity to change the settings manually in the application (they just start)....and then you have to be a programmer to do the settings....??
Thank you for your information[smile]
I suggest you to get used to one converter in order to learn all the tricks... for your D2 probably jetAudio can be a good choice as it has both options (presets and user definable). User definable have the right options to touch.
I'm not converted many videos for D2 but I would try using 25 fps as normal with a video bitrate of about 500, audio bitrate can be 128 or 192 depending if the video is of music or just a movie.
In fact I'm fan of jetAudio player for all purposes.
yeah its not working...
I am finding the same problem as these 2 users as well.
Is there an edit to the scripts to keep the msdos window open so we can
find out whats the problem?
thanks
Martin
tried ilove and another convertor but most videos dont convert to anything recognised by the D2.
trying it now :)
I would like a variety of convertors since i am having problems with various videos.
If i can get this script going its another option for vids that dont work.
Martin
I am finding the same problem as these 2 users as well.
Is there an edit to the scripts to keep the msdos window open so we can
find out whats the problem?
Yes, just add "pause" command at the end of d2_multi.bat and use it to encode a video. If you find out what the problem was, please write it here.
"'d2r.bat' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . ."
thats what happens and yes d2r.bat is present in the same directory and is labeled as a msdos batch file!
hope that helps
Martin
elviselvis
01-11-2008, 06:17
"'d2r.bat' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . ."
thats what happens and yes d2r.bat is present in the same directory and is labeled as a msdos batch file!
hope that helps
Martin
check if you have right quotes (quote character = ") right, some application needs them and some not, and some need singe type (') and some double type (")
Martyn123
01-25-2008, 12:02
Does it matter what the name of the DLL file is?
sorry for bothering you, but I can't get this to work.
I put the bat files, mencoder.exe, ffmpeg.exe and mplayer.exe in one folder, if I now drag and drop a videofile on either bat it opens a command line and closes it...
Could you please tell me what I'm missing ? Also I'd like to know how the ini file is created to be able to optimize the conversions yourself.
________
herbalAire vaporizers (http://vaporizers.net/herbalaire-vaporizer)
Bump because I can't get this to work either. :(
thenoble06
03-06-2009, 06:26
It is a shame I can't get this to work (same errors as above posters) because it seems to do everything I want it to do.
Guess I'll keep using the JetAudio engine!
I'm sure there's an easier way to do this with scripting, but I just hardcoded the full folder path into all of the calls to ffmpeg.exe, mencoder.exe, mplayer.exe, etc... and then everything worked.
So my calls look something like:
if exist C:\any-to-d2-12\mencoder.exe goto menc
for %%i in (C:\any-to-d2-12\mencoder.exe) do if not "%%~$PATH:i"=="" goto menc
I had to make changes like that in about a dozen places.
I also had to put in the quotation marks shown below in d2.bat:
set D2TITLE="Anything to D2 AVI encoder v1.2"
Edit: Well, it processed the video, but it doesn't appear to have saved it off anywhere. The work continues.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.