Wednesday, September 28, 2016

Combining and Trimming Videos Without Re-encoding Using FMPEG

Recently I was tasked with trimming and combining some videos for work. We had filmed 16 hours of lectures and needed to make them ready to be published. Unfortunately the cameras we used split the video into 19 minute segments that then had to be recombined into one long video. I got to work.

It was recommended to me that I just use Windows Movie Maker. I was skeptical, but I decided to give it a try. I copied the first 3 videos into the Windows Movie Maker workspace and waited. After waiting several minutes for the files to import and seeing the progress bar barely move, I decided there had to be a better way. I had used FFMPEG in the past in the form of SUPER media encoder. However, this time I decided to go directly to the source and use FFMPEG from the command line. Since Windows 7 (64 bit) is my primary operating system, I would use that. Likewise, my videos are mp4 files, so these instructions are written for those.

Disclaimer: I am not an FFMPEG expert. This is just what I found that worked for me. No guarantees that it is the most efficient way or that it will even work for you.

1) Download FFMPEG -

FFMEG can be found at the link above. Select your operating system and put it in a convenient folder (I used a Windows static version). Unzip it, and it is ready to use.

2) Separate Files into Directories

The first thing you are going to want to do is separate each set of files that you want to join into directories (ie. folders). One thing to make your life easier, make the name short and leave out any spaces. For example, "JohnsBirthday" instead of "Johns Birthday May 22 1934"

3) Run Batch File and Navigate to Directory

Run the batch file in the folder where you unzipped FFMPEG. It should be called "ff-prompt.bat". This will launch FFMPEG in a command prompt in the directory where it is located. 

Now you need to navigate in the command prompt to the directory (the folder) where you put the videos. If you know how to do this, use your favorite method. If you don't, here are some basic instructions. "cd" is the command to change directory. The usage is below.
  • Use "cd .." to go up one level
  • Use "cd folderName" to navigate to a folder in your current directory
If you get lost, you could always put the videos you are working on in the folder with the batch file. Then you would not have to navigate anywhere.

4) Combine Videos Using FFMPEG

To combine a video we are going to "concatenate" them. If you are familiar with programming, it is the same concept as concatenating a string. You are taking one and sticking on the end of the other. HERE is the link to the ffmpeg wiki page with the documentation, but I will copy the steps below that I used.

1) Copy the command below into the command line you have open. Replace "mp4" with the file type of your videos (.wav, .mov, etc.). Then run the command. It should execute very quickly.
(for %i in (*.mp4) do @echo file '%i') > mylist.txt
This creates a list of the files to be concatenated. Alternatively, you can create the file by hand. One note on this, I am not sure how it determines the order. It seems to be by the name. Also, spaces in the name cause problems, so make sure no file names have spaces. 

2) Now copy this into the command line you have open. Note that the ".mp4" was added by me to get it to work. The wiki implies you shouldn't need it.
ffmpeg -f concat -i mylist.txt -c copy output.mp4
This will take some time to execute, but it will still be much faster than re-encoding the video. I was combining about 1.5Gb of video and it took 3 minutes.

Command Line at the End of Successful Execution

3) Verify video. I went through and double checked at the points were it transitioned to make sure everything worked out. This step is obviously optional

5) Trim Videos Using FFMPEG

Trimming is a bit more complicated. "Why does my audio get desynced when trimming with FMPEG?" This is because of something called "key frames" that mp4 files use. I did not take the time to research those all that much, but the long and short seems to be that you have to trim at a key frame if you want to be able to trim a video without re-encoding or desyncing the audio. This is the command line instruction.
ffmpeg -ss 00:03:35 -i output.mp4 -t 00:57:04 -c copy outputtrimmed.mp4
As best I understand it, here is what is happening - the -ss "searches" for the closest key frame to the time 00:03:35. This will happen at the speed of re-encoding (slow). It will then pull in the file "output.mp4" starting at that key frame and will copy from that frame until time 00:57:04 into the file "outputtrimmed.mp4". This part will happen without re-encoding and will be fairly fast. This does not allow to trim at exact points, but it allows you to do it quickly and without losing audio sync (both important in my book).

6) Repeat

Do this for all of your videos.


So that is how I combined and trimmed a bunch of 19 minute segments into hour long blocks totaling about 16 hours quickly and without re-encoding the video. No guarantees it will work for you. I just had a hard time finding detailed instructions on this, so I thought I would post. One note, I imagine trimming before you combine would speed up the process a bit. For me it just made sense to do it after so I would not have to juggle so many files. The process isn't that long anyway.

That's it! If you have any questions or comments post those in the comments below. If you have any other methods to try or ways to make this better, post those too!

Until later,

Friday, December 25, 2015

Fixing Login on Xiaomi Mi Band 2

This will be a fairly short post. I just wanted to get this out there in case others are working on this over Christmas. I may update this later as things progress. This all occurred yesterday 12/24/2015.

My mother received a mi band 2 for Christmas this year, and I was tasked with setting it up. I downloaded the latest version of mifit (version 1.8.111) and followed the setup procedure. I created an account using an email address and logged into google when prompted.

I tried multiple times, but it always gave an error - either "error 96103" or "invalid email address".

What worked for me...

1) Uninstall the most recent app.
2) Download an older version of the app. I used version 1.3.412 found HERE, but I cannot vouch for its safety apart from not receiving any obvious damage.
3) Transfer this file to the phone (or download it on the phone) and click on it. I used ES Filer Explorer for this.
4) Run this file. On ES File Explorer just navigate to the file, tap it, and select install. Here you may be required to turn off a security setting or two. Do this at your own risk. I would recommend turning it back on when you're done.
5) Follow the setup procedure and create an account. You will be required to put in a phone number and an email address.
6) Uninstall the old version.
7) Reinstall the current version and log in with the account you created.
8) Enjoy your mi band and comment on this page how the process went.

What I suspect will also work...

Just create an account using a phone number. The older version of the app requires a phone number to create the account. This leads me to believe just using the most recent app and selecting "create account with phone number" (or something like that) might also work.

If this works please comment on this post, so others will know. If you know of any other fixes please mention them there as well.

What didn't work - but could be tried again...

I tried using this link on a laptop. This did not work. It gave me the page below.

I hope this helps. Merry Christmas!

Sunday, December 6, 2015

3D Printed Disc Golf Disc


I will begin by saying, if you are thinking about printed a disc golf disc to get into disc golf, don't. Go buy a nice 165g dx shark online for $10 and know exactly how its going to fly when you take it out of the plastic. With that said, this was an interesting proof of concept that might be fun for others to attempt. If you had better filament materials, I believe it could be possible to print a fairly useful disc.


I originally used my X-out KC Pro Roc as a pattern for what my disc should look like. Taking measurements off of  the disc directly as well as using dimensions from the PDGA list of approved discs I was able to get a model of something that looked pretty close to the Roc. From the dimensions of my Prusa i3 print bed I decided that I would split the rim into thirds and then a single piece central domed flightplate.

This first disc I designed was quite naturally perfect; it was a work of art, flawless, sublime. A triumph equaled only by its monumental failure. The inevitability of its doom is as apparent to me now as a consequence of the imperfection inherent in every FDM 3D printer.Thus I redesigned it based on my printer's capabilities to more accurately reflect the varying grotesqueries of a 3D printed object. However, I was again frustrated by failure. I have since come to understand that the answer eluded me because it required a less typical design, or perhaps a design less bound by the parameters of perfection..

But seriously, when I did some initial prints of the profile based off the KC Roc, it didn't go very well. My printer did not handle the overhangs very well, and I did not want to go with support material as I didn't want to mess up the surface finish. I then started editing the profile until I got something that would both fit on my printer and print with fairly clean overhangs. The main thing that suffers from this is the dome top. In order to have a flat surface to print the rims on and have a flight plate still fit on my build plate, there is about an inch section where the disc is flat on top before the dome of the flight plate begins. I imagine this decreases the lift it creates. My final design I deemed the TTU Roc.


The final design can be downloaded from Thingiverse HERE. Construction is as follows.

Print 3 of the file TTURocRim_120C.stl . I used settings:

Layer Height: 0.1mm
Perimeters: 4
Infill: 25%
Combine Infill every: 2 layers
Support: Off

Print 1 of the file FlightPlateC.stl. I used settings:

Layer Height: 0.2mm
Perimeters: 4
Infill: 30%
Combine Infill every: 1 layers
Support: On

Next you will need to drill out the holes for the filament splints. These are the holes in the ends of the rim pieces that splint the 3 pieces together. I used plain 1.75mm filament to do this. Just drill them out so that they are an easy fit.

Now it is time to glue the disc together. I used super glue, and it is what I would recommend. This took me an hour or so of gluing in stages. If you know how to friction weld you might try that here. Really, join them however you want.

Next I applied some DIY plastic rivets. Drill 1.75mm holes through the bottom of the rim into the flight plate. Then glue in the filament, snip it off, and and sand it down to level. This was just something else I did to try to strengthen the joints between the flight plate and the rim. Use as many of them as you see fit. I imagine you could also use friction based rivets if you are comfortable with that.

Finally, sand the disc smooth and finish it however you want. I sanded it fairly smooth and then did a light coat of acetone to smooth it out some. Use whatever finishing techniques you have.


My final disc weight came out to 156 grams. I consider that an acceptable weight. Overall, the disc flew surprisingly well. To my amateur eye, it flies similar to a Roc. It appears to be a little slower and have less glide. Honestly, I haven't thrown it that many times for fear it will rip apart in my hand. I also doubt it will "beat in" very well. As ABS is pretty hard I imagine it would just break if it hit a tree. It also is not terribly comfortable in my hand. It is too hard and scratchy. In conclusion I made this chart to compare 3d printed disc golf discs of today to traditional discs.

3D Printed Disc Golf Discs:
  • Infinitely customizable
  • Expose new players to the game 
  • Fun!
  • Lack consistency
  • Brittle materials
  • Poor surface finish
  • Made of joined parts 

Again, download CAD files HERE.