FFMPEG make Video Lyrics using JPG MP3 SRT File

FFMPEG make Video Lyrics using JPG MP3 SRT File

Input Files

– Image (test.jpg)
– MP3 File (test.mp3)
– SRT Lyrics (test.srt)

FFMPEG Command

# ffmpeg -loop 1 -y -i test.jpg -i test.mp3 -vf subtitles=”f=test.srt:force_style=’FontName=Arial,FontSize=14″ -shortest test1.mp4

Output File: test1.mp4

SRT Lyrics Preview

00:00:00,330 --> 00:00:04,936
Hello Feifei. I didn't know you shopped at this supermarket too.

00:00:05,354 –> 00:00:12,303
Hi Finn. Usually I don’t. But it’s close to the office and I have to rush home to welcome an important guest.

00:00:13,378 –> 00:00:15,321
Who is it? Someone I know?

00:00:15,402 –> 00:00:29,763
No, it’s my landlady. She’s coming to collect some of her post and… well, I want to make her like me because next month, the contract on my flat is due to be renewed and she might want to increase the rent.

00:00:30,426 –> 00:00:34,919
Yeah, I see what you mean. So you’d better butter her up then!

00:00:35,450 –> 00:00:43,498
Butter? Oh, yes. But I’m a pretty bad cook. If I baked a cake it would probably be horrible!

00:00:44,474 –> 00:00:56,703
No. I don’t mean butter for a cake. In English, when you say you’ll ‘butter someone up’, you mean you’ll be especially nice to them in the hope they’ll do something good for you in return.

00:00:57,498 –> 00:01:08,424
Oh, I see. So I’ll be nice to her and pay her compliments so that she likes me and keeps the rent low. I’ll ‘butter her up’! But isn’t it a bit insincere?

00:01:09,522 –> 00:01:22,522
Well, it can have a negative connotation, yes. Let’s hear some examples of how to use ‘to butter someone up’ or ‘to butter up someone’, which is today’s expression in The English We Speak.

How to add MP3 audio delayed in MP4 video?

FFMPEG Command: Add MP3 Audio file delayed in MP4 video file

# ffmpeg.exe -i “fox-story.mp4” -itsoffset 5.00 -i “fox-story.mp3” -map 0:v -map 1:a -vcodec copy -acodec copy “The Fox and Crow Story.mp4”

Input: fox-story.mp4 and fox-story.mp3
Output: The Fox and Crow Story.mp4

-itsoffset 5.00 -i “movie.mp3”
Offsets timestamps of audio streams by 5.00 seconds

-map 1:v -map 0:a
Takes audio stream from the second (delayed) input and video stream from the first input

Record Live Streaming Radio to MP3

Sometime you want to record Live Radio Stream to MP3 file, you can find many online linux tools for recording radio stream to server and then download to your local computer.

You can use Linux “wget” or “curl”


# curl -sS -o stream.mp3 –max-time 150 http://Radio-Server:Port/stream
Bitrate: 128 kb/s [it will make approx 2MB MP3 file]

# curl -sS -o stream.mp3 –max-time 150 http://Radio-Server:Port/stream
Bitrate: 64 kb/s [it will make approx 1MB MP3 file]


# ffmpeg -y -i http://Radio-Server:Port/stream stream.mp3

# ffmpeg -i http://Radio-Server:Port/stream -t 00:00:40 -acodec copy stream.mp3
[It will record MP3 file stream.mp3 of duration of 40 sec with same Radio Stream Codec Info & Bitrate]


# mplayer ‘http://Radio-Server:Port/stream’ -endpos ’00:01:00′ -vo null -ao pcm:waveheader:file=stream.wav &> /dev/null
# lame stream.wav stream.mp3 &> /dev/null


# wget -O stream.mp3 “http://Radio-Server:Port/stream”

Live Transcoder for Nimble Streamer

WMSPanel’s Transcoder for Nimble Streamer is a premium add-on for Nimble Streamer which can decode, transform and encode live streaming media.

The Transcoder use H.264, MPEG2 video and AAC, MP3, MP2, Speex audio as Input. It support RTMP pulled and published, RTSP pulled and announced, MPEG-TS via HTTP and UDP as input protocols.

The Transcoder use H.264/AAC with pass-through support as Output. It support HLS, MPEG-DASH, RTMP and RTSP playback and re-publish, MPEG-TS playback and multicast as output protocols.

Transcoder for Nimble Streamer apply existing FFmpeg filters to the processed content.

– FFMPEG Filters are applied without streams interruption
– 4 different strategies for adding key frames alignment
– Resize / crop to create multiple resolutions
– Graphic overlays, picture-in-picture video
– Make filtering chains without additional decoding
– Audio transrating, e.g. 256Kbps to 192Kbps
– Audio re-sampling, e.g. 44KHz to 22KHz
– Mix several audio sources
– Add any custom or third-party filter

The Transcoder is provided per monthly subscription with an affordable pricing. With Nimble Streamer your total cost of ownership will be as low as possible.

Wowza Live Audio Video Mixing

Wowza doesn’t do transcoding. So, we highly recommend to use FOSS solutions

Where we need Wowza Live Audio Video Mixing?

1) Live event is broadcasting through Wowza
2) We need a multi lingual setup somewhere and comment or transcode that live event with voice.
3) Flash client might receive the stream where
Output Video Stream = Video of live event + Audio transcoder (multi lingual human voice)

Modern IP cameras provide RTP/RTSP/RTMP with MPEG, MPEG4 or h.264 encoded stream for broadcasting through Wowza.

We might need a RTP/RTSP/RTMP client to decoder and manipulate streams then re-encode stream and serve it over standard protocol like RTP/RTSP/RTMP.

Best Solution should use Xuggler to serve streams to Flash. Media Server might be Wowza or Red5.

Xuggler is the easy way to uncompress, modify, and re-compress any media file (or stream) from Java.

Xuggler in Action: A free open-source library for Java developers to uncompress, manipulate, and compress recorded or live video in real time.


Mixing audio and video with ffmpeg

Mixing audio with video file without audio track
# ffmpeg -i audio-file.mp3 -i video-file.avi -acodec copy -vcodec copy output-file.avi

Mixing audio with video file with existing audio track.
# ffmpeg -i audio-file.mp3 -i video-with-audio.avi -acodec copy -vcodec copy output-file.avi -map 0.0 -map 1.0

-map -> the output file would contain two streams audio and video.

Contact us for Live Audio Video Mixing.

Email: svnlabs[at]gmail.com
Skype: svnlabs
MSN: svnlabs[at]hotmail.com

FFMpeg Video to Image Gallery

1. FFMpeg create images using video source

# ffmpeg -i video.mp4 -s 560×315 images/image%d.jpg

2. Create image sequence gallery


$files = array();

foreach (glob("images/*.jpg") as $filename) {
$files[] = $filename;


<div id="slideshow">

<?php $i=1; foreach ($files as $filename) { 
if($i%15==0) { ?>
<img src="<?php echo $filename; ?>" <?php if($i==15) { ?> class="active" <?php } ?> />
<?php } $i++; } ?>


3. Synchronize images with video

$(function() {
    setInterval( "slideSwitch()", 1000 );

Demo for Image Sequence

Red5 figure out audio/video out of sync issue

I had worked Red5 WebCam application that lets users to record video clips from their webcams. The users could talk while they record clips.

I was using PHP with Zend Gdata for uploading recorded video clips to YouTube. But I had issue in FLV files generated by Red5 server, the clip’s audio / video content was out of sync. 🙁

Code to upload Red5 FLV to YouTube

Then after few searches I got… FFMpeg might be a good option to solve this issue to convert clip from FLV to MP4. 🙂


I have to add -itsoffset 00:00:01.16 before the -i, because flash player prompts user to allow or deny webcam access during the process the video begins to record. these are seconds of recording where nothing is recorded. To audio video sync add the itsoffset that tell ffmpeg to wait a second before it starts the the transcoding.

FFMpeg syntax to sync the audio and video using MP4 file:


//........... svnlabs.com

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$file= 'tmp/'.$fileName.".flv";

// convert FLV file to MP4 using -vcodec libx264

$mp4file= 'tmp/'.$fileName.".mp4"; 

exec("/usr/bin/ffmpeg -y -itsoffset 00:00:01.166000 -i ".$file." -s 640x480 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -r 24 -g 48 -b 520000 -threads 64 ".$mp4file);

$file = $mp4file;

$file = realpath($file);  



Other Command
# /usr/bin/ffmpeg -i “svnlabs.flv” -s 640×480 -y -strict experimental -acodec aac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -vpre medium -vpre ipod640 -r 24 -g 48 -b 520000 -threads 64 “svnlabs.mp4”

Related Article: https://www.svnlabs.com/blogs/applications/media-streaming/

If you would hit the mark, you must aim a little above it…



# ffmpeg is a command line tool to convert one video file format to another. It can also grab and encode in real time from a TV card.
# ffserver is an HTTP and RTSP multimedia streaming server for live broadcasts. It can also time shift live broadcast.
# ffplay is a simple media player based on SDL and on the FFmpeg libraries.
# ffprobe is a command line tool to show media information.

# Convert video files into another format.
# flv -> avi
# flv -> mp4
# flv -> wmv
# flv -> swf
# avi -> mp4
# avi -> wmv
# avi -> flv
# avi -> swf
# mp4 -> avi
# mp4 -> wmv
# mp4 -> flv
# mp4 -> swf
# wmv -> mp4
# wmv -> avi
# wmv -> flv
# wmv -> swf
# divx -> mp4
# divx -> avi
# divx -> flv
# divx -> wmv
# divx -> swf
# Audio extraction
# flv -> mp3
# avi -> mp3
# mp4 -> mp3
# wmv -> mp3
# divx -> mp3
# swf -> mp3

if ($target == ‘mp3’)
$ffmpeg_cmd = exec($ffmpeg.” -y -i “.$source.” -acodec “.$acodec.” -vn “.$target);
} else {
$ffmpeg_cmd = exec($ffmpeg.” -y -i “.$source.” -acodec “.$acodec.” “. $ar .” -ab 128kb “.$vcodec.” “.$r.” -b 1200kb -mbd 2 -cmp 2 -subcmp 2 “.$size.” “.$aspect.” “.$target);

Couldn’t find video filter ‘x264’


x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.

x264 itself provides a command line interface as well as a library-level interface.

x264 is used to encode video files in mp4, m4v, h.264 (HD) output format.

Install x264

*  Download the latest snapshot(tarball) here:
# wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20090113-2245.tar.bz2

* Extract tarball
# bzip2 -cd x264-snapshot-20090113-2245.tar.bz2 | tar xvf -
# cd x264-snapshot-20090113-2245

* Build and install
# ./configure
# make
# make install

Some problems with mplayer & x264

Install/compile mplayer with x264 support

-x264encopts is not an MEncoder option
Checking for x264 ... no (in libavcodec: no)   (./configure)

# svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

# cd /usr/local/src/mplayer

# svn update

# ./configure

After configure make sure you got

Checking for x264 ... yes (in libavcodec: yes)

# make && make install

Try latest version of video tools ffmpeg, mplayer, mencoder, flvtool2, mediainfo  🙂

Find correct path where you installed these components try …..

# locate command

“make sure you are using /usr/bin/mencode and NOT /usr/lib/bin/mencode”