FFMPEG make Video Lyrics using JPG MP3 SRT File


Hits: 639  

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

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

2
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.

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

4
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.

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

6
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!

7
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.

8
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?

9
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?


Hits: 623  

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

Song Lyrics: lrc2srt and srt2json


Hits: 637  

LRC2SRT.php

<?php

function lrc2srt( $lrc ) {
	$lrc = explode( "\n", $lrc );
	$srt = "";
	$lines = array();
	foreach ( $lrc as $lrcl ) {
		if ( preg_match( "|\[(\d\d)\:(\d\d)\.(\d\d)\](.+)|", $lrcl, $m ) ) {
			$lines[] = array(
				'time' => "00:{$m[1]}:{$m[2]},{$m[3]}0", // convert to SubRip-style time
				'lyrics' => trim( $m[4] )
			);
		}
	}
	for ( $i = 0; $i < count( $lines ); $i++ ) {
		$n = $i + 1;
		$nexttime = isset( $lines[$n]['time'] ) ? $lines[$n]['time'] : "99:00:00,000";
		$srt .= "$n\n"
		     .  "{$lines[$i]['time']} --> {$nexttime}\n"
		     .  "{$lines[$i]['lyrics']}\n\n";
	}
	return $srt;
}

echo "<pre>";
echo lrc2srt( file_get_contents("FileName.lrc") );
echo "</pre>";

?>

SRT2JSON.php

<?php

define('SRT_STATE_SUBNUMBER', 0);
define('SRT_STATE_TIME',      1);
define('SRT_STATE_TEXT',      2);
define('SRT_STATE_BLANK',     3);

$lines   = file("FileName.srt");

$subs    = array();
$state   = SRT_STATE_SUBNUMBER;
$subNum  = 0;
$subText = '';
$subTime = '';

foreach($lines as $line) {
    switch($state) {
        case SRT_STATE_SUBNUMBER:
            $subNum = trim($line);
            $state  = SRT_STATE_TIME;
            break;

        case SRT_STATE_TIME:
            $subTime = trim($line);
            $state   = SRT_STATE_TEXT;
            break;

        case SRT_STATE_TEXT:
            if (trim($line) == '') {
                $sub = new stdClass;
                $sub->number = $subNum;
                list($sub->startTime, $sub->stopTime) = explode(' --> ', $subTime);
                $sub->text   = $subText;
                $subText     = '';
                $state       = SRT_STATE_SUBNUMBER;

                $subs[]      = $sub;
            } else {
                $subText .= $line;
            }
            break;
		
    }
		
}

echo "<pre>";
print_r($subs);
echo "</pre>";


$count = count($subs);
 
for($i=0;$i<$count;$i++)
{


$playlist['ID'.$i] = array($subs[$i]->text, $subs[$i]->startTime, $subs[$i]->startTime, $subs[$i]->stopTime);


}

echo  json_encode($playlist);

?>

HTML5 MP3 Lyrics Player


Hits: 6491  

HTML5 Lyrics Karaoke Player Plugin enable wordpress users to sing and play song text lyrics.

Free Features

  • Supports MP3 formats
  • Supports Text Song Lyrics
  • Social Links Facebook / Twitter
  • Works in IE, Safari, Firefox, Chrome, Opera
  • Player have shortcode for post/page [html5lyrics id=ID] i.e. [html5lyrics id=1]

Paid Features

  • Supports MP3 formats
  • Supports Text Song Lyrics
  • Support Images on song’s cue points
  • Color / Size Customization
  • Supports Unicode
  • Social Link Customization
  • Multiple player on same page / post
  • Works in IE, Safari, Firefox, Chrome, Opera, mobile devices including Android/iOS
  • Supports Wowza / Amazon Cloud Front / S3 HTTP Streaming
  • Facebook page customization with player
  • Player have shortcode for post/page [html5lyrics id=ID … ] i.e. [html5lyrics id=1 … ]
  • Best support on email / skype

Note: It uses native <audio> where available and an invisible flash player to emulate <audio> for other browsers.
It provides a consistent html player UI to all browsers which can be styled used standard css.

Browser & format support

With Flash as a fallback, it should work pretty much anywhere.

It has been verified to work across:

– Mobile Safari (iOS 3+)
– Android (2.2+, w/Flash), Android (4.0+)
– Safari (4+)
– Chrome (7+)
– Firefox (3+, w/ Flash)
– Opera (10+, w/ Flash)
– IE (6, 7, 8, w/ Flash)

Get fully customized HTML5 Lyrics Karaoke Player for Website Buy Now or Contact Us

Standalone

Credit

Audio.js Player

HTML5 Audio Read-Along