iAudiophile.net Forums
Go Back   iAudiophile.net Forums > Flash-Memory Players > Cowon D2/D2+ > D2 Videos & Recordings

Post New Thread  Reply
 
Thread Tools Display Modes
Old 06-13-2007, 15:51   #1
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default [Guide] D2 Video transcoding from multiple formats

  • Do you still haven't found out how to transcode MP4 / M4V for D2 without installing Quicktime?
  • Do you still get annoying glitches and can't get a perfect synced audio / video?
  • Do you still suffer from aspect ratio and sync issues when it comes to DVD ripping for D2?
  • Do you find the file size of transcoded video files just don't match the video quality (bad image quality AND relatively big file size)?
  • Are you still looking for a nice cutting solution to cut out all the crappy advertising?

If you answer only a single question with "Yes!", then this guide is for you!

Learn how to get perfect video and audio sync on your D2, even as you jump around the progress bar like crazy. Learn to transcode H.264/MPEG-4 AVC (MP4 / M4V) and pretty much every video format out there. No installation of crappy proprietary software required (e.g. the ones form the fruit manufacturer). Finally you're able to watch all the Videocasts originally made for iPod. Learn how to keep proper aspect ratio. Never again vertically or horizontally streched video image. Get superior image quality with really efficient transcoding. No longer medium quality coupled with huge file size. And last but not least learn about the easy way of cutting video to fit your needs. All you need is free software tools. You don't have to pay a single $! Also part of the software is open-source, hence really secure software. No viruses, no spyware!

I have experimented with the stuff below quite some time and now I'm at the point that I feel I can share my experiences with you.


I. Here's what you need

Most transcoding work can be done with the little ffmpeg command line encoder alone. You don't have to install it and you don't mess up your system registry, nor have to install sometimes troublesome codec packs. But if you encounter some more tricky file formats as AVC (most MP4 / M4V, most ipoddish Video Podcasts), you will need to install most of the other programs. Generally speaking, these programs are easy on you system registry and don't harm your system in any way. But i can't held responsible for any damage these programs may cause. Use them at your own risk and read carefully the advises on Haalis Media Splitter and ffdshow.

Get the latest versions of
  • ffmpeg (Command Line Encoder. Thanks again Dase and Aesculapius. Look at this thread for background info. For documentation look at ffmpeg HP)
  • Haalis Media Splitter (divides video and audio stream)
  • ffdshow (provides AVC codec)
  • VirtualDub (versatile cutting and encoding tool)
  • GSpot (it's optional, but sometimes becomes very useful to determine codec, framerate, resolution and the like)
  • AVI Synth (scripting frameserver tool)
  • Cut Assistant (it's optional, but you get a very convenient tool for cutting almost all video file formats without reconverting, hence no quality loss through cutting)


II. Here's what you need to do

If you have installed codec packs or large CD/DVD burning suits that are also capable of doing video conversion, make sure this stuff doesn't interfere with the software above. For instance, if you have Nero Vision Express on your system, it is likely that you have to uninstall it.

If you don't want to uninstall your Codec Packs or Nero Vision Express and this kind of software, you can try to do without Haalis Media Splitter and ffdshow and go with the codecs your Codec Packs and CD/DVD burning software provide.

By the way, you don't have to have big codec packs on your system in order to watch (even exotic) video file formats. Just grab a copy of VLC Player It comes with self contained codecs that don't dig into your system causing trouble. It plays a wide range of video and audio formats and it is open-source hence pretty secure software.

Install the above software tools. When installing Haalis Media Splitter and ffdshow, make sure to include all the formats you want them to handle.


III. Basic concept and workflow

Always at the end of all transcoding-work-chains, the final step is to transcode your video file with ffmpeg. Why is that? That is because ffmpeg is the only program i know of that provide a really stable audio / video sync on D2. I guarantee, i have tested quite a lot of conversion tools. Be it JetAudio, AutoGK, Iriverter, ... you name it. Some do a rather good job but all fail when it comes to audio / video sync stability on D2. Additionally with the help of some batch files (originally provided by Dase and Aesculapius), you get a great image quality with good file size relation.

Examples:
  • WMV: transcode with ffmpeg and you're done.
  • DVD Movie: Rip to VOB file (1:1 passthrough, no encoding) and in a second step take ffmpeg to transcode, done.
  • AVI DivX or Xvid: transcode with ffmpeg and you're done.
  • MP4 / M4V AVC: first transcode to Xvid using VirtualDub, second encode with ffmpeg to a D2-readable size and format. Done.

I haven't found any way to make ffmpeg transcode from H.264/MPEG-4 AVC yet. So you need VirtualDub as a step in between. This also involves the use of Haalis Media Splitter, ffdshow and AVI Synth. But this happens behind the scene. VirtualDub utilises them to devide and decode AVC video and audio stream.


IV. Let's get to the nitty-gritty stuff

GSpot

You can get away without GSpot, but it comes in handy when you want to get some information about the video file you're about to convert.

Basically you extract the program to a directory you like (no installation needed) and start the GSpot.exe. After that, you simply drag and drop the video file in question onto the GSpot GUI (graphical user interface) and you get all the information you need to know.


ffmpeg

ffmpeg alone is sufficient for a lot of videofile formats, for instance WMV, AVI [DivX, Xvid], VOB [1:1 DVD copy] ...

1.) Extract ffmpeg to a directory on your harddrive (e.g. C:\ffmpeg). Note that you will need either 7-zip (efficient file archiver, free and open-source software) or WinRAR because ffmpeg comes in 7z archive format.

2.) Copy the batchfiles provided in the next posting of this guide into C:\ffmpeg.

3.) Optional but makes things a bit easier, copy the video file you would like to convert into C:\ffmpeg.

4.) Open up the command line prompt (in most cases that is C:\windows\system32\cmd.exe or simply by start menu.). Type in the drive letter of the drive that contains the folder you have extracted ffmpeg into followed by a ":", for instance "C:", and press ENTER. Second type in "cd <path to folder which contains ffmpeg>. If you chose "C:\ffmpeg" in step 1.), this would be "cd ffmpeg".

5.) Choose an appropriate batchfile and enter the following into the command line prompt:

<batchfile name> <videofile name>

that will look something like this:

C:\ffmpeg>ff34_250.bat testvideo.avi

6.) Hit ENTER and watch those funny numbers. When ffmpeg is done you get the transcoded video ready to transfer to your D2 via USB. Enjoy great image quality, proper aspect ratio and super stable audio / video sync.

Note that there are some frontend GUIs for ffmpeg too (for instance WinFF), so you can forget about the command line prompt. But i know of no frontend that is capable of two pass processing. Recently Dase provoided a batchfile that only utilises single pass processing. If you enter his information into WinFF, that may work. But then again, you really get used to do this command line thing. It's fast and editing a batchfile is really easy. Just rightclick on the batchfile and select "edit".


VirtualDub

VirtualDub (in conjunction with Haalis Media Splitter, ffdshow and AVI Synth) is needed to do the tricky AVC transcoding (most MP4 / M4V video files are encoded with H.256 / AVC), as well as do the transcoding work for some other video formats ffmpeg alone can't handle. But remember that only ffmpeg provides fully stable audio / video sync on D2. So a two step transcoding procedure is needed here.

1.) First i presume that you have already installed VirtualDub, AVI Synth (and of course Haalis Media Splitter [MatroskaSplitter.exe] and ffdshow if you haven't already any other codecs on your Windows machine that provide AVC support). Simply download the programs, run each setup file and follow the onscreen instructions.

2.) Now create a textfile (TXT) and enter the following line into the textfile:

DirectShowSource("<path and videofile name>",<framerate>)

<path and videofile name> is the path and the name of the videofile that you would like to convert.

<framerate> is the framerate of the videofile in question. Most MP4 / M4V files come with a framerate of 25 fps. This is the standard value, VirtualDub presumes. In this case, you don't have to enter the framerate into the textfile. But in some cases the framerate differs from the standard value. Use GSpot if you want to be sure about the framerate. GSpot will tell you the exact value.

When you're finishied, the line will look something like this:

DirectShowSource("C:\ffmpeg\videocast.mp4",30)

3.) Save the textfile to your harddisc, i suggest you choose C:\ffmpeg because keeping all your files in one place makes things a bit easier.

4.) Rename your textfile to something like vdtranscode.avs. The extension "AVS" is important because VirtualDub needs to recognise the file as an AVI Synth-scriptfile.

5.) Run VirtualDub, click away the greeting message and drag & drop the vdtranscode.avs onto the VirtualDub GUI (graphical user interface).

6.) If you get an error message, it is likely that you don't have installed Haalis Media Splitter and / or ffdshow to prevent interference with previously installed codecs on your system OR VirtualDub can't find the right codec to decode the video file because you have not selected the right filetype during installation of Haalis Media Splitter and ffdshow. In either case, please move back to the scetion II. Here's what you need to do and consider the steps mentioned there.

If you get no error message (that should be the case), hit the play button on VirtualDub's icon bar at the buttom of the pragram window (it looks like >1 ). The video should play just fine and you can see the Haalis Media Splitter icon and the ffdshow decoder icon in the icon area of your windows taskbar.

7.) Now it gets somewhat tricky. You have to choose the encoding options in VirtualDub. IF you got a really big harddisc (and i mean a REALLY BIG ONE with like hundreds of free gigabytes), you can go without any compression in this step and move on to the next step if you don't mind filling your harddisc with uncompressed video data. Note that FAT32 formated partitions can't handle such a huge file. This works only on NTFS formated partitions.

I suggest the following: Stop playback, go to the menu bar of VirtualDub and choose Video -> Compression (alternatively hit Ctrl + P). Move down the list and choose the XviD codec (looks something like this "XviD MPEG-4 Codec"). Hit the Configure button and select a preset that will provide good quality compression and high bitrate. I chose Home Theatre PAL and Twopass - 1st pass encoding type. The aim here is to get a good quality encoding because we need to encode a second time with ffmpeg. Image quality that is lost in this step can't be regained further down the line. When you're finished, close all dialog windows hitting OK each time.

8.) Move to the VirtualDub menu bar and select File -> Save as AVI ... (alternatively hit F7). Select the folder, you want to store the converted video file into. I suggest selecting the folder C:\ffmpeg. Enter the filename, hit OK and VirtualDub will start writing the file to disc.

9.) Finally go back to the section on ffmpeg and follow the instructions there to convert your VirtualDub output file into the final D2 video file. ffmpeg always has to be the final step because it provides this great a/v sync on D2.
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU

Last edited by Mantr0nix; 06-14-2007 at 10:06.
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Old 06-14-2007, 07:07   #2
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default

Cut Assistant

Cut Assistant is an additional feature to this guide. It provides the ability to cut your video material conveniently without the need to reencode.

1.) First download and unpack Cut Assistant to any directory you like (no installation needed). Run Cut Assistant by doubleclicking the cut_assistant.exe. On startup Cut Assisant will try to connect to the internet. This is because it's originally designed to cut TV recordings provided by onlinetvrecorder.com The basic idea is, that when you download a TV show and create a cutlist, you're able to share this cutlist with other people. Also you get cutlists from other people.

To prevent Cut Assistant from connecting to the internet, go to Options -> Settings ... -> Info Check Tab and deselect Check Infos on server.

2.) Next go to Options -> Settings ... -> External Cut application tab. Dependent on the video type you would like to edit with Cut Assistant, make sure at least asfbin is selected for WMV files and VirtualDub is selected for AVI files. Get the latest version of asfbin command line tool if you intend to cut WMV files without the need to reencode. Don't worry about command line hassle, this time Cut Assistant takes care of it. Download and unpack asfbin into any folder you like (no installation needed).

3.) Go to Options -> Settings ... -> Asfbin tab and point to the location of asfbin.exe Select the option Recreate keyframe.

4.) Do the same with VirtualDub location (next tab). When you're done hit OK to store the settings and exit the settings dialogue.

5.) Drag & drop the video file you would like to cut onto the Cut Assistant GUI. WMV files most likely will work without any trouble, the same is true for AVI [DivX, XviD] files. In case you want to cut an MP4 / M4V file (AVC), first transcode the video as described under the section VirtualDub.

6.) The GUI is pretty simple to understand. You get the normal Play / Pause / FF / RW buttons along with the ability to move by frame. As soon as you found the beginning point of a cut hit From: Set current, move to the end cutting point, hit End: Set current.

Each time you created a new cut, hit Add new cut. This will buld your cutlist as you cut out for instance unwanted advertising.

7.) When you're done with marking all cutting positions, make sure you select the mode "Crop", hit the scissors icon on the top icon bar, wait until the external cutting app has finished it's work and you've just made your first pristine cutting work.

8.) As always, the final step has to be ffmpeg converting the video file to preserve the a/v sync.

I hope this helps you in your video supplying tasks for your beloved COWON D2.



Batchfiles for ffmpeg
(Also watch for the update on time offset and my first step into anamorphic matrial based zooming)

Here you find some batchfiles for ffmpeg command line encoder. Please create a text file and copy and paste the content of each batchfile into the textfile. Finally replace the extension ".TXT" with the extension ".BAT". Theses batchfiles are based on Dase's and Aesculapius' work.

Some aspects of the batchfiles need to be revised. As soon as they reach the "final build", i will provide these batchfile in a more convenient manner. But for now just do the copy & paste procedure.

ff43.bat High quality 500 kbit, twopass encoding for 4:3 aspect ratio content

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -pass 1 -s 320x240 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -pass 2 -s 320x240 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL
ff43_250.bat Low quality 250 kbit, twopass encoding for 4:3 aspect ratio content. Good to save space when encoding less quality / less important video podcasts.

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -pass 1 -s 320x240 -vcodec mpeg4 -vtag XVID -b 250kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -pass 2 -s 320x240 -vcodec mpeg4 -vtag XVID -b 250kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL
ff43_350.bat Mid quality 350 kbit, twopass encoding for 4:3 aspect ratio content.

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -pass 1 -s 320x240 -vcodec mpeg4 -vtag XVID -b 350kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -pass 2 -s 320x240 -vcodec mpeg4 -vtag XVID -b 350kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL
ff169.bat High quality 500 kbit, twopass encoding for 16:9 aspect ratio content. This works with most cinema movie content (16:9 anamorphic encoded)

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -pass 1 -s 320x180 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -pass 2 -s 320x180 -padtop 30 -padbottom 30 -aspect 4:3 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL

Please help me out and send me a private message if you find some (major) spelling and / or grammar errors. If you know a better way of doing things or if you spotted an error regarding the content of this guide, please tell me. And finally, if certain things are still unclear, please go ahead and just ask. Thank you.
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU

Last edited by Mantr0nix; 06-16-2007 at 17:47.
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Thanks from:
Old 06-14-2007, 08:03   #3
Simplyblue
Member
 
Simplyblue's Avatar
 
Join Date: May 2007
Posts: 64
Default

Deleted my previous post so that there isn't a break between yours.
__________________
Simplyblue is offline View Simplyblue's Photo Album   Reply With Quote
Old 06-14-2007, 10:11   #4
Zverik
Member
 
Join Date: May 2007
Posts: 42
Default

Wow. Epic job, thank you!

But why do you use -padtop and -padbottom? I pan 16:9 movies to 320x192, cutting frame at left and right a bit.
Zverik is offline View Zverik's Photo Album   Reply With Quote
Old 06-14-2007, 10:15   #5
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default

Yapp, that's the next batchfile i plan to do. You are right, it can't hurt to zoom in a bit. The D2 screen isn't exactly huge.
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Old 06-14-2007, 10:44   #6
Aesculapius
Junior Member
 
Join Date: Jun 2007
Posts: 18
Default

Since working with batch files is a bit limited, i was thinking about creating a nice little front-end application to make things just a tiny little bit easier...will be working on that next weekend; just so you guys know
Aesculapius is offline View Aesculapius's Photo Album   Reply With Quote
Old 06-14-2007, 19:46   #7
wader
Senior Member
 
wader's Avatar
 
Join Date: May 2007
Location: NY
Posts: 785
Default

Quote:
Originally Posted by Aesculapius View Post
Since working with batch files is a bit limited, i was thinking about creating a nice little front-end application to make things just a tiny little bit easier...will be working on that next weekend; just so you guys know
I was considering a similar idea, possibly trying to create a quick and dirty Java-based UI that was similar to something like WinMEnc. Will be curious to see your early work in this area.

Mantr0nix: This is definitive work and sincerely appreciated. Like you, I've tried numerous encoders in the quest to find a method and/or settings which might somehow offer better overall A/V synch on the D2, but hadn't gotten to ffmpeg as of yet. Will take all my test samples and try them with your suggested protocol by this weekend, hopefully.

- wader
wader is offline View wader's Photo Album   Reply With Quote
Old 06-16-2007, 17:44   #8
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default

Here is a little update on ffmpeg.

1.) It's also possible to delay audio or video playback.

I found that a few video files still have a slight constant lag between audio and video with ffmpeg. Compensating for that incorporates the -itsoffset option.

Example:

FFMPEG -i "%~f1" -itsoffset 00:00:00.400 -i "%~f1" -map 1:0 -map 0:1 ...

At first that looks a bit scary but in fact it's pretty simple. What you need to do is to devide the audio and video stream and put it back together with the desired time offset.

-i "%~f1" is the inputfile. In case audio and video are retrieved from the same inputfile (that's most likely the case with simple transcoding jobs, i.e. videofile format conversion for D2), you simply enter both as the source.

-itsoffset 00:00:00.400 tells ffmpeg by what timeoffset the video should be delayed (hh:mm:ss.xxx). And the -map option maps input streams to the output in the following way: -map <file>:<stream>. 0 ist the first stream of an input file, 1 the second and so on. Based on this scheme, -map 1:0 maps the video stream (always stream 0) from the second file as video stream to the output. And -map 0:1 maps the audio stream (in this case stream 1, which is the second stream of input file 0 [the first input file] to the output.

As you can see, in our example is the video delayed by 0.4 seconds.


2.) I have begun to experiment with aspect ratio of anamorphic material trying to zoom in into wide cinema screens (2.20:1) a little.

The following batchfile is still at "beta stage" (i think i will have to bring the left and right crop into the first pass too), as i still haven't read through all important aspects of this topic. But if you like to make a zoom-in into anamorphic DVD movie material, the following will give you a good start. The aspect ratio is pretty much kept (although not to the exact pixel since i still haven't found the right formula).


ff169z.bat Zoom in on 16:9 anamorphic material. already with offset compensation (just enter into -itsoffset 00:00:00.000 your desired offset and watch for the mapping -> whether audio or video is gonna be delayed).

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -itsoffset 00:00:00.000 -i "%~f1" -map 1:0 -map 0:1 -pass 1 -s 504x240 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -itsoffset 00:00:00.000 -i "%~f1" -map 1:0 -map 0:1 -pass 2 -s 504x240 -cropleft 92 -cropright 92 -aspect 4:3 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%.avi
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL
Edit: I'm sorry, i forgot to take out the "-t" option (setting the duration of the video file convertion). Now it's right.
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU

Last edited by Mantr0nix; 06-18-2007 at 16:44.
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Old 06-17-2007, 13:03   #9
HipHopScribe
Member
 
HipHopScribe's Avatar
 
Join Date: May 2007
Posts: 89
Default

Good job on the guide Mantr0nix, thanks

Quote:
Originally Posted by Aesculapius View Post
Since working with batch files is a bit limited, i was thinking about creating a nice little front-end application to make things just a tiny little bit easier...will be working on that next weekend; just so you guys know
That would be great
HipHopScribe is offline View HipHopScribe's Photo Album   Reply With Quote
Old 07-10-2007, 07:11   #10
NaturalManiac
Junior Member
 
Join Date: Jul 2007
Posts: 3
Default

Thanks for the extensive guide, sadly though ffmpeg has so far only showed promise with the a/v syncing but nothing more.

I tried your 16:9 script but ended up with a stretched screen. I'm curious if someone else has experienced this or is this the norm?

Edit: Scratch my question. It turned out that it was the player's fault.

Last edited by NaturalManiac; 07-10-2007 at 08:43.
NaturalManiac is offline View NaturalManiac's Photo Album   Reply With Quote
Old 07-10-2007, 09:31   #11
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default

Quote:
Originally Posted by NaturalManiac View Post
Thanks for the extensive guide, sadly though ffmpeg has so far only showed promise with the a/v syncing but nothing more. [...]
Beside the fact that ffmpeg provides stable audio / video sync on D2, it is also a very good quality encoder for various video and audio formats. So what do you mean by though ffmpeg has so far only showed promise with the a/v syncing but nothing more.?

As far as I can tell, elviselvis took ffmpeg for his conversion tool too. Haven't tried his work but it seems as if you get a convenient GUI with his program (if that's what you're looking for). Although I'm not sure whether his conversion tool is also capable of two pass processing. Take a look here: http://iaudiophile.net/forums/showthread.php?t=15620

I will get back to work on these batch files soon since they're not perfect yet.
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Old 07-12-2007, 18:15   #12
Mantr0nix
Member
 
Mantr0nix's Avatar
 
Join Date: Jun 2007
Location: Kiel, GERMANY
Posts: 99
Default

Some words on 16:9 anamorphic footage transcoding

This gets a bit complicated but don't worry too much. The aim is to crop the picture left and right a bit to zoom into the picture. I had no idea about anamorphic stuff. My first batchfile (ff169z.bat) was based on guessing. (Actually I got pretty close by guessing. The actual value to crop left and right of the picture has to be 90. But 92 was pretty close nevertheless. )

First and most important: Physical resolution differs from anamorphic resolution. Anamorphic pixels are not square! So the trick is to bring anamorphic pixels to square pixel format in physical 4:3 aspect ratio resolution. In case of D2 it's 320 x 240 (4:3 physical resolution with perfectly square pixels).

A little math is needed to do the trick.

1.) If you live in places where your anamorphic material (e.g. DVD movie) is provided in NTSC, the anamorphic resolution will most likely be 720x480 pixels. If you live in places where your anamorphic material (e.g. DVD movie) is provided in PAL, the anamorphic resolution will most likely be 720x576 pixels. I'm not aware of any other anamorphic resolution. Just grab GSpot and drag and drop the desired VOB file (1:1 DVD rip) onto its GUI to find out and to be sure.

2.) Devide DVD (anamorphic) resolution width by DVD (anamorphic) resolution height. In case of PAL DVD this would be 720 / 576. The result is 1.25

3.) Now we need the real (physical) aspect ratio. In almost all cases of anamorphic movie DVD footage this is 16:9. Alright, devide the physical width with physical height. In case of 16:9 this would be 16 / 9. The result is 1.7777777777777...

4.) Finally to get the anamorphic factor devide the physical resolution quotient (in our case 1.7777777777777...) by the anamorphic resolution quotient (in our case 1.25). The result is 1,42222222222222...

To put it straight:

(pW / pH) / (aW / aH) = aF

in our case (PAL DVD):

(16 / 9) / (729 / 576) = 1,42222222222222...

5.) Now we need to know how much do we crop left and right of the anamorphic picture to get it fullscreen on our 4:3 D2 screen with perfectly kept aspect ratio. So lets figure out what the target width of the picture has to be. We need this formula:

target width = D2 screen aspect ratio * (anamorphic picture height / anamorphic factor)

that is in our case

cW = (4 / 3) * (576 / 1,42222222222222...) = 540

It's no surprise that you'll get the same value with NTSC DVD since the width (720 pixels) is the same. But now you know how to calculate any anamorphic stuff out there in case you encounter some other anamorphic resolutions.

6.) The final step is to subtract the traget width from original width. That is 720 - 540 = 180. So we need to crop 90 pixels on either side of the anamorphic source picture (2 * 90 = 180).

This is done with the -cropleft [size] and -cropright [size] option with ffmpeg.


.. getting some coffee ... to be continued ...
__________________
(I have to say sorry about my adventurous attitude of putting sentences together. I'm still in the process of learning this wonderful language)

• Trekstor i.Beat mood FM 1 GB
• Cowon iAudio D2 white 4 GB
• Headphones: - still looking for some good arc headphones, maybe inear -


Watch the Mad Spray Monkey™ http://youtube.com/watch?v=GD3dXyZWnSU

Last edited by Mantr0nix; 07-13-2007 at 05:49.
Mantr0nix is offline View Mantr0nix's Photo Album   Reply With Quote
Old 08-12-2007, 18:23   #13
IceBone
Junior Member
 
Join Date: Aug 2007
Posts: 8
Default

Hey, guys, great work here! I've always had a bit of a problem with this. XviD through virtualdubmod, via avisynth for resizing, and the problem i've been having is that the video plays a bit slower than the audio so it's perfectly ok at the start of a movie, but then about 1 second out of sync by the end. I've tried it with ffmpeg now and it seems better, although slower, unless... is it possible to open an avs file with ffmpeg and have avisynth do the resizing, since it's clearly faster?

But anyway, the video and audio play equally fast now, but still not in synch. So a bit of audio interleaving is required... It doesn't show up on the computer though... So it takes trial and error to find the exact synch.

EDIT: ffmpeg opens the .avs file and encodes at 2x the framerate. Will report on end result.

EDIT #2: even a bigger gap in the sync but a 15 minute video looks great. Will do a 1h video during the night.

Comment about the scripts: you don't need the padding thing, the video only refuses to play if the vertical is greater than 240 pixels, the black bars just eat away at the bitrate (very little, but still).

A little avs script like so:

Code:
avisource("sample.avi")
lanczosresize(320,176)
combined with this ffmpeg script:

Code:
@SETLOCAL
@IF NOT "%2"=="" GOTO ELSE
@SET tenframe=300
@GOTO ENDIF
:ELSE
@SET tenframe=%2
:ENDIF

@SET newfile="%~d1%~p1%~n1-d2%~x1"

@echo.
@echo. Doing Cowon D2-conversion to 320x176 in two passes with (10 x framerate) of %2 and destination filename:
@echo. %~n1-d2%~x1
@echo.
@echo.
@echo.===================
@echo. Starting pass 1...
@echo.===================
@echo.
@echo.
FFMPEG -i "%~f1" -pass 1 -s 320x176 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec copy null.avi -threads 2

@echo.
@echo.
@echo.===================
@echo. Starting pass 2...
@echo.===================
@echo.
@echo.
@FFMPEG -i "%~f1" -pass 2 -s 320x176 -vcodec mpeg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g %tenframe% -acodec mp3 -ab 128 -ac 2 -async 1 %newfile%.avi -threads 2

@echo.
@echo.
@echo.=================================
@echo. Done, deleting temporary files...
@echo.=================================
@echo.
@DEL null.avi
@DEL ffmpeg2pass-0.log
@echo.=============================================================================
@echo. All Done, enjoy:
@echo. %newfile%
@echo.=============================================================================
@echo.
@SET tenframe=
@SET newfile=
@ENDLOCAL
is all it takes.

I do however add killaudio() to the avs script and then mux the audio myself in virtualdubmod, i'm too sensitive to leave it to automatics.

Last edited by IceBone; 08-12-2007 at 19:00.
IceBone is offline View IceBone's Photo Album   Reply With Quote
Old 08-22-2007, 00:03   #14
Enzo Umberto
Junior Member
 
Join Date: Aug 2007
Posts: 1
Cursing *.vob ist still *.vob

Quote:
Originally Posted by Mantr0nix View Post
ffmpeg

ffmpeg alone is sufficient for a lot of videofile formats, for instance WMV, AVI [DivX, Xvid], VOB [1:1 DVD copy] ...

1.) Extract ffmpeg to a directory on your harddrive (e.g. C:\ffmpeg). Note that you will need either 7-zip (efficient file archiver, free and open-source software) or WinRAR because ffmpeg comes in 7z archive format.

2.) Copy the batchfiles provided in the next posting of this guide into C:\ffmpeg.

3.) Optional but makes things a bit easier, copy the video file you would like to convert into C:\ffmpeg.

4.) Open up the command line prompt (in most cases that is C:\windows\system32\cmd.exe or simply by start menu.). Type in the drive letter of the drive that contains the folder you have extracted ffmpeg into followed by a ":", for instance "C:", and press ENTER. Second type in "cd <path to folder which contains ffmpeg>. If you chose "C:\ffmpeg" in step 1.), this would be "cd ffmpeg".

5.) Choose an appropriate batchfile and enter the following into the command line prompt:

<batchfile name> <videofile name>

that will look something like this:

C:\ffmpeg>ff34_250.bat testvideo.avi

6.) Hit ENTER and watch those funny numbers. When ffmpeg is done you get the transcoded video ready to transfer to your D2 via USB. Enjoy great image quality, proper aspect ratio and super stable audio / video sync.

After the transcoding a *.vob file, i received also a *.vob file!
What's wrong?

Thanks
Enzo
Enzo Umberto is offline View Enzo Umberto's Photo Album   Reply With Quote
Old 08-25-2007, 00:55   #15
Morfesto
Computer Systems Tech
 
Morfesto's Avatar
 
Join Date: Aug 2007
Location: Ottawa, Ontario, Canada
Posts: 103
Default

I am trying to transcode a .avi video using your batch files but I always get this:


E:\ffmpeg>ff43_350.bat testvideo.avi

Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of an
d destination filename:
testvideo-d2.avi


===================
Starting pass 1...
===================



E:\ffmpeg>FFMPEG -i "E:\ffmpeg\testvideo.avi" -pass 1 -s 320x240 -vcodec mpeg4 -
vtag XVID -b 350kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g 300 -acodec
copy null.avi -threads 2
FFmpeg version SVN-r10141, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --
enable-liba52 --enable-avisynth --enable-libamr-nb --enable-libamr-wb --enable-l
ibfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --en
able-libogg --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx
vid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.5.0
libavcodec version: 51.41.0
libavformat version: 51.12.2
built on Aug 19 2007 19:58:01, gcc: 4.2.1

Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/
2733) -> 23.98 (10000000/417083)
Input #0, avi, from 'E:\ffmpeg\testvideo.avi':
Duration: 00:23:04.6, start: 0.000000, bitrate: 1030 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x480, 23.98 fps(r)
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Output #0, avi, to 'null.avi':
Stream #0.0: Video: mpeg4 (hq), yuv420p, 320x240, q=2-31, pass 1, 350 kb/s, 23
.98 fps(c)
Stream #0.1: Audio: libmp3lame, 48000 Hz, stereo, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
[mpeg4 @ 009CC230]timebase not supported by mpeg 4 standard
Error while opening codec for output stream #0.0 - maybe incorrect parameters su
ch as bit_rate, rate, width or height


===================
Starting pass 2...
===================


FFmpeg version SVN-r10141, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --
enable-liba52 --enable-avisynth --enable-libamr-nb --enable-libamr-wb --enable-l
ibfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --en
able-libogg --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx
vid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.5.0
libavcodec version: 51.41.0
libavformat version: 51.12.2
built on Aug 19 2007 19:58:01, gcc: 4.2.1

Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/
2733) -> 23.98 (10000000/417083)
Input #0, avi, from 'E:\ffmpeg\testvideo.avi':
Duration: 00:23:04.6, start: 0.000000, bitrate: 1030 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 640x480, 23.98 fps(r)
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Unknown codec 'mp3'


=================================
Done, deleting temporary files...
=================================

================================================== ===========================
All Done, enjoy:
"E:\ffmpeg\testvideo-d2.avi"
================================================== ===========================


What am I doing wrong?


:Edit: I tried with a diff video file and it got past the first pass but not the second

E:\ffmpeg>ff43.bat Get_Backers_01.avi

Doing Cowon D2-conversion to 320x240 in two passes with (10 x framerate) of an
d destination filename:
Get_Backers_01-d2.avi


===================
Starting pass 1...
===================



E:\ffmpeg>FFMPEG -i "E:\ffmpeg\Get_Backers_01.avi" -pass 1 -s 320x240 -vcodec mp
eg4 -vtag XVID -b 500kb -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g 300 -a
codec copy null.avi -threads 2
FFmpeg version SVN-r10141, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --
enable-liba52 --enable-avisynth --enable-libamr-nb --enable-libamr-wb --enable-l
ibfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --en
able-libogg --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx
vid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.5.0
libavcodec version: 51.41.0
libavformat version: 51.12.2
built on Aug 19 2007 19:58:01, gcc: 4.2.1
Input #0, avi, from 'E:\ffmpeg\Get_Backers_01.avi':
Duration: 00:25:16.9, start: 0.000000, bitrate: 957 kb/s
Stream #0.0: Video: msmpeg4, yuv420p, 640x360, 23.98 fps(r)
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Output #0, avi, to 'null.avi':
Stream #0.0: Video: mpeg4 (hq), yuv420p, 320x240, q=2-31, pass 1, 500 kb/s, 23
.98 fps(c)
Stream #0.1: Audio: libmp3lame, 48000 Hz, stereo, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=36370 fps= 85 q=2.0 Lsize= 111979kB time=1516.9 bitrate= 604.7kbits/s

video:85917kB audio:23701kB global headers:0kB muxing overhead 2.153970%


===================
Starting pass 2...
===================


FFmpeg version SVN-r10141, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --
enable-liba52 --enable-avisynth --enable-libamr-nb --enable-libamr-wb --enable-l
ibfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --en
able-libogg --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx
vid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.5.0
libavcodec version: 51.41.0
libavformat version: 51.12.2
built on Aug 19 2007 19:58:01, gcc: 4.2.1
Input #0, avi, from 'E:\ffmpeg\Get_Backers_01.avi':
Duration: 00:25:16.9, start: 0.000000, bitrate: 957 kb/s
Stream #0.0: Video: msmpeg4, yuv420p, 640x360, 23.98 fps(r)
Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Unknown codec 'mp3'


=================================
Done, deleting temporary files...
=================================

================================================== ===========================
All Done, enjoy:
"E:\ffmpeg\Get_Backers_01-d2.avi"
================================================== ===========================

Last edited by Morfesto; 08-25-2007 at 01:07.
Morfesto is offline View Morfesto's Photo Album   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:36.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.