Posts Tagged ‘video’

youtube lectures on computer science

June 27, 2015 Leave a comment

convert .wmv to .mp4

ffmpeg -i input.wmv -c:v libx264 -crf 23 -profile:v high -r 30 -c:a libfaac -q:a 100 -ar 48000 output.mp4

More info here.

Categories: bash Tags: , , , ,

extract an animated gif from a video

You have a video and you want to create an animated gif from a part of it.

You can use MoviePy for that. Here you can find a blog post from the author of MoviePy, where the process is explained through several examples. Here I copy three simple examples:

Example 1:

from moviepy.editor import *

clip = (VideoFileClip("frozen_trailer.mp4")  # input video
        .subclip((1,22.65),(1,23.2))         # part to extract, where 1’22.65 means 1 minute 22.65 seconds
        .resize(0.3))                        # resize to 30% of the original
clip.write_gif("use_your_head.gif")          # output animated gif

Example 2 (cropping):

kris_sven = (VideoFileClip("frozen_trailer.mp4")
             .crop(x1=145,x2=400))  # cropping: remove left-right borders

Example 3 (play forward and backward):

def time_symetrize(clip):
    return concatenate([clip, clip.fx( vfx.time_mirror )])

clip = (VideoFileClip("frozen_trailer.mp4", audio=False)
        .crop(x1=189, x2=433)
        .fx( time_symetrize ))  # the effect is added here

For more advanced usage, see the original blog post.

Categories: python Tags: , , ,

media info

December 28, 2014 Leave a comment

You have a media file (audio, video, image) and you want to get some detailed information about it: duration, bit rate, resolution, etc. How to extract these pieces of information?

Use the MediaInfo project. You can install it via your package manager and you will get a command called “mediainfo”.


$ mediainfo movie.avi


Complete name                            : movie.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format profile                           : OpenDML
Format settings                          : rec
File size                                : 1.27 GiB
Duration                                 : 2h 29mn
Overall bit rate                         : 1 218 Kbps
Writing application                      : AVI-Mux GUI, Feb 16 201019:42:50

ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Muxing mode                              : Packed bitstream
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 2h 29mn
Bit rate                                 : 1 086 Kbps
Width                                    : 720 pixels
Height                                   : 304 pixels
Display aspect ratio                     : 2.35:1
Frame rate                               : 23.976 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.207
Stream size                              : 1.13 GiB (89%)
Writing library                          : XviD 64

ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Mode                                     : Joint stereo
Mode extension                           : MS Stereo
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 2h 29mn
Bit rate mode                            : Constant
Bit rate                                 : 128 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 136 MiB (11%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 747 ms (17.92 video frames)
Interleave, preload duration             : 216 ms
Title                                    : mp3
Writing library                          : LAME3.99r
Encoding settings                        : -m j -V 4 -q 2 -lowpass 17 -b 128

There is a simple Python wrapper for it called pymediainfo. Its github page is here.

Categories: bash, python Tags: , , ,

Replace the audio track in a video

You have a video with an audio track (call it video.mp4). You have an audio file (e.g. audio.mp3) that you want to put on the video, replacing the original audio of the video file.

With Audacity, you can open both video.mp4 and audio.mp3 and you can synchronize the mp3 to match the original audio. Important points: speech/music should start at the same time, and its length should be the same or a little bit less than the original audio.

Once you have a good audio.mp3 file, do the replacement with the following command:

ffmpeg -i audio.mp3 -i video.mp4 -c copy final_video.mp4

Solution #2
Before the previous solution, I used Avidemux, but it tends to crash sometimes :) When I have such videos where Avidemux crashes, I use ffmpeg from the command-line.

Lots of Ruby conference videos

November 13, 2013 Leave a comment
Categories: ruby Tags: ,

HTML / CSS / JavaScript video tutorials

November 2, 2013 Leave a comment

Check out for HTML / CSS / JavaScript video tutorials. As I saw they are freely available!


Categories: Uncategorized Tags: , , , , ,

Get every new post delivered to your Inbox.

Join 82 other followers