BIPEDU

my ideas in action

Category Archives: Uncategorized

use ffmpeg to edit videos

I want to show here how to produce a video and what are the steps to post-production.

All these are using free and open source software. No need to be expert in computers , only a little bit of courage.

You can use this recipe for homemade videos that you post online, for your vlog/blog or whatever.

I use ffmpeg and Inkscape that are available for Linux and Windows also.

As a general rule, if you have Linux/Unix, then please use the RAM since it is faster (read/write in /tmp folder always for all temporary files).

 

These are the steps :

1= record the video + audio

use a decent camera (preferable HD or 4K) with preferable audio . DSLR is OK also.

If your camera do not have good audio recording from builtin mic, then record the audio separate and clap in front of camera so that you can synchronize video/audio in post-production. Preferably use an external microphone ( ex. lavalier) as close as possible of the sound source. A cheap and good lav mic is Boya BM-M1 (see Amazon)

You can also record with a smartphone but be aware that the sample rate may be 44100 instead of 48000 as camera will record. This may produce audio that is not in sinc with video.

During recording please keep 5-10 seconds of silence , because you may need it later to do some noise reduction (see next step)

2= extract the audio separated and do some processing (if necessary)

Personally I use Audacity ( free and open source) .

I import audio and I do mainly two operations : Noise reduction and Compression. I use default settings from Audacity .. are ok for most cases. In case the audio sample rate is on 44100 then it is preferable to change it to 48000 to match the video.

Save the audio as WAV ( 16bit) in 48000.

3= then replace the video old audio with the new audio (new audio is with noise reduction)

3.1 = strip the audio from the video

ffmpeg -i /tmp/DSC_0009.MOV -an -c:v copy -c:a copy /tmp/p1.mov

3.2 = add new audio to the video

ffmpeg -i /tmp/p1.mov -i /tmp/DSC_0009.wav -vcodec copy -acodec copy /tmp/p2.mov

 

4= cut the video to the correct size

play first the new video and check the quality and note on paper the moments you want to save. For example : from 00:01:12 till 00:25:48 (hh:mm:ss format)

use example : cut from 20 sec till 9min and 36sec :

ffmpeg -i /tmp/p2.mov -vcodec copy -acodec copy -ss 00:00:20 -to 00:09:36 /tmp/p3.mov

5= (optional) add some logo/title/watermark

5.1 = Create the logo

With Inkscape (free and open source) create a image that has the same format as the video. Example if video is HD 1920*1080 then create a page that is 1920*1080. On this place your logo/watermark / artwork and preferable use alpha (transparency) to get more effect. Save the work and export it to PNG and keep the transparency.

5.2 = Overlay the PNG image to the video with ffmpeg

ffmpeg -i /tmp/p3.mov -loop 1 -i /tmp/TitleFile.png -filter_complex “[1:v]fade=in:st=0:d=0.1:alpha=1,fade=out:st=9:d=1:alpha=1[png];[0:v][png]overlay=x=0:enable=’between(t,0,10)'” -b:v 2000k -bufsize 2000k /tmp/p4.mov

Here I overlay the PNG image from second 0 ( st=0) in 0.1sec (d=0.1) and then fadeout starting at second 9 (st=9) for 1 second (d=1). The entire overlay is from seconds 0 to 10 ( see : between(t,0,10) ). Then I also force bitrate to be 2Mb/s (-b:v 2000k -bufsize 2000k) to avoid too much loss of quality. If not the ffmpeg will reduce the bitrate even more and it may be too low.

 

6= (optional) add a static picture at the final with credits/ links/Thanks or other announcements

6.1 = use Inkscape to create a closing image. Same as before, can use transparency (alpha) .

6.2= use ffmpeg to create and concatenate the image at the end of the video:

ffmpeg -i /tmp/p4.mov -loop 1 -framerate 30 -t 5 -i /tmp/Closing.png -f lavfi -t 0.1 -i anullsrc=channel_layout=stereo:sample_rate=48000 -filter_complex “[0:v][0:a][1:v][2:a]concat=n=2:v=1:a=1” -b:v 2000k -bufsize 2000k /tmp/final.mov

options :

framerate=30 : need to match the original framerate of your video ( if you shoot in 60FPS then use 60 here also)

t 5 : generate 5 seconds video that will show your Closing.png image

stereo : add stereo sound if youd video is stereo ( if not you can put mono)

sample_rate=48000 : use the same sample rate as your audio (other option is 44100)

 

7=(optional) post the video online ( Ex: Youtube, Vimeo……etc)

 

 

Advertisements

use PAC file for automatic proxy selection

I will explain how to use automatic proxy selection for a local network.

For example let’s say that you have a proxy server but that proxy is not available all time. In this case the you need to find each time if the proxy is alive (available) and if yes to use it. If not then browser will select direct connection.

The easiest way to use it is to create a PAC file and to add it in the Firefox as automatic proxy selection.

Go to Preferences–>Advanced –> Network –>Settings and choose “Automatic proxy configuration URL”

Then type there the path to a local PAC file. Normally there should be a web page address but if the file is locals works also ( no web server needed)

FFsettings

To create the PAC file use any text editor and create a file called “autoproxy.pac” and put this content:

function FindProxyForURL(url, host)
{
return “PROXY 192.168.1.29:3128; DIRECT”;
}

The Proxy in this case is on local network at 192.168.1.29 (Squid Proxy on port 3128) and Firefox try to use it first . In case it is not responding it will use direct connection.

You can set there multiple proxy servers. The order is important.

In the example below you can have two proxies. If the first one (192.168.1.29) is not responding then the second one (192.168.1.42) will be selected, and if the second one also do not respond the direct network connection will be used.

function FindProxyForURL(url, host)
{
return “PROXY 192.168.1.29:3128; PROXY 192.168.1.42:3128; DIRECT”;
}

The name of the PAC file is not important ( “autoproxy.pac” is name used by me), any name will do.

More details regarding the PAC file , examples, more advanced functions can be found here : http://findproxyforurl.com/

 

 

 

Lab power supply with PIC microcontroller (3)

I have some updates regarding my project.

First of all, I have a limited time to work on this project. So it is normal to take such long time to develop it.

Second I do not want to jump too fast in “making” phase and I prefer to go slowly step by step to get a good result.

So, I was worried about the stability of my previous schematic. So after a few hours on spice simulation I understand what was the problem. Well, the main issue is that the voltage loop contained 3 low frequency poles.

One is the opamp itself that has a dominant pole at ~10Hz ( see MCP6022 spec), this cannot be avoided since any opamp will have a pole approx in this range.

The second is the output node. The main issue with this pole is that is moving with the load ( R and C) and since this is a lab power supply it will always be different.So what I decided to do is to use a small output capacitance of 1-10uF and to use a dummy load of approx 10mA. This will force the output NPN ( 2N3055) to have a minimum current even if there is no load. The main reason is that when the current is very small in the 2N3055 transistor the predriver ( BC139) will have almost no current. So the gain drops dramatically and the loop become unstable.

The other pole is at the gate of the predriver NPN . this is a “design” fault since the internal node should not affect the functionality.

So I decided to change the loop architecture and to use a intermediate amplifier with of gain of approx 5. The intermediate amplifier is made with Q4 and Q9 and the gain ratio is set by R24+R9 and R18. I chooses a gain of 5 since this gives me a opamp output voltage range between 1.3V and 4.5V for a output voltage of 0 to 21V.  Also this intermediate opamp has a high poles and do not require any compensation. Also since the gain of the amplifier set the voltage range at the output of the opamp this give me the ability to use a non Rain-to-rail output OPA. But I will keep the MCP6022 since the offset is very low and the input is rail-to-rail.

The other changes are the fact that I eliminated the resistor to SUP24V that was feeding the base of the predriver NPN.  Also I swap the opamp inputs ( intermediate amplifier has positive polarity) and I added a 100-330nF capacitor over the opamp. This compensation capacitor is necessary since I noticed that the loop may become unstable in certain conditions ( when load is changing). I need such a small value ( in the hundreds range) since the opamp will amplify the effect of this capacity  ( miller effect) and the pole generated is very low.

So the new version of the schematic is here : LabPicPowerSupply_v3_SCH

There are other minor changes :

  • removed reset PIC switch
  • removed capacitors from DAC output
  • changed the positions of some PIC  IO’s
  • added protection for the input of the opamps that measure the load current ( anti-parallel diodes)
  • added the buffer before ADC voltage measurement ( VMON). before this buffer was inside the voltage loop.
  • the ILIM protection is made by changing the voltage reference ( output of the DAC)
  • small changes in the components value
  • not use the MJ3001

I made a real test of this new architecture . I used a simple breadboard and I noticed that the stability is OK . I did not had a full test under all conditions since the 2N3055 was not on the heatsink but even like that it was capable to deliver 1A at 18V output for few seconds, this means 18W !!. I  had to stop it after few seconds since the 2N3055 became too hot.

The dummy output load I made it with the BF254B device. It was the easiest and I had laying around some devices. It can be made is many different ways but in my case I do not need accuracy.

There are some aspects that I noticed also. The predriver transistor BD139 can dissipate some power. This depend on the gain current (Hfe) of the 2N3055. My transistor had a gain of 35 at Ic=1mA so this means that trough BD139 will flow approx 30mA in the worst case. If this is happening when the output voltage is at 0V ( hard short of the lab supply terminals) then this means that the predriver will dissipate 30mA*24V =  0.72W. It may not seem too much but the datasheet show that this can bring the BD139 temperature to  ~75degC above the air temperature. If the air surrounding the device is at 30C this give a junction temperature of 100C. It is high for my taste !!! so a heatsink is mandatory !

The other issue that I noted is that 5V regulator also need a heatsink. The current consumed may reach 50mA and the power dissipated can be 1W. In this conditions LM7805 can go to 65C above the air temperature. And this is continuous and not a “error condition” like in the case of BD139. So a heatsink is really necessary. Some may argue that is not bad to use them without heatsink since this is a tolerable temperature and many Chinese manufacturers do it… well it is my design and I do not want to risk.

I made also a layout tentative.  It was not easy but at least I have a workable PCB. I still need to double-check the connection of each device to be sure that it is the correct package and the footprint is matching the actual component that I have. I hope to finish this step soon so that I can start the real manufacturing of the PCB and then component soldering.

Here are all the files for version 3  (KICAD schematic and PCB)

schematic : LabPicPowerSupply_v3_SCH

BOM list : LabPicPowerSupply_v3_BOM

PCB layout : LabPicSupply_v3_PCB

minciuna

Mă uitam azi la TV și mi-am dat seama că de fapt CNA-ul ar trebui să forțeze televiziunile să schimbe modul de prezentare al emisiunilor.

De exemplu se spune : Genul programului : divertisment.

Mai corect ar fi să se spună : Genul programului : tâmpenie.

Opțional CNA ar putea oferi televiziunilor o listă de opțiuni. Și în funcție de program să se aleagă.

Ca exemplu dau următoarea listă:

 

Antena 1:

X factor = vise deșarte, prostituție

Burlăcița, Next Top Model : prostituție

Observator : manipulare

Access Direct : brainwash (spălare pe creier)

În gura presei : Limbi la fundul lui Felix sau lătratul de unul singur.

Un show păcătos : prostie în formă concentrată

 

Antena 3:

Sinteza zilei: Limbi la fundul lui Felix

Subiectiv : Limbi la fundul lui Felix sau brainwash (spălare pe creier)

celelalte emisiuni : Limbi la fundul lui Felix sau brainwash (spălare pe creier)

Antena 3 e un caz mai special. Ar trebui sa existe o atenționare publică în momentul în care comuți pe A3 . Nu mai are rost să faci avertizare la fiecare emisiune…

 

TVR:

Jurnal : comandă politică ( de fapt profilul se schimbă în functie de partidul care a numit consiliul de administrație)

 

Pro TV:

Serviciul Român de Comedie : Bășcălie de prost gust.

Dansez pentru tine : brainwash (spălare pe creier)

Horoscop : Credințe păgâne, vrajitorie

Pro Motor: Fetele și mașinile pe cere nu ți le permiți

Vremea : timp pierdut.

Apropo TV : Bârfă cu târfe

Românii au talent : exibiționismul idioților

Master Chef: Boi la masă

Stirile ProTV : timp pierdut.

 

Prima TV:

Vreau să divorțez : cum să ne distrugem viața

Fete Bune : labă

Verde-n Față : timp pierdut.

M-a făcut mama artist : acvariul cu tâmpiți.

Cronica cârcotașilor : Bârfe cu târfe

Mondenii: Cretini noi și vechi

Miss fata de la țară : pregătirea pentru prostituție ( de la astfel de show-uri se recruteaza viitoarele prostituate pentru export)

Schimb de mame : swing ( cine nu știe ce-i aia să caute cu Google/Wikipedia)

Casa : teleshopping

Focus : timp pierdut

cu restul nici nu are rost să-mi bat capul.

 

B1 TV

Sub semnul întrebării: nu mă minți !

La taifas cu Ion Cristoiu : dacă ești prost nu te uita.

Lumea lui Banciu : lătratul de unul singur.

restul emisiunilor sunt pentru umplerea grilei așa că n-are rost să-mi bat capul cu ele.

 

OTV : trebuie o etichetă pentru toată televiziunea : vomă !

 

Realitatea TV: trebuie o etichetă pentru toată televiziunea : Limbi la fundul lui Felix si Vântu !

 

 

Hello world!

Welcome to WordPress.com! This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.

Happy blogging!