Sunday, August 23, 2015

how to create video from one audio file and one image file

I- List what we have
   - mysong.mp3   (duration 3:29 mn)
   - myimage.jpg   (width 300, height 300)

2- create list of image for creating a video, but since we want to use just only one image, so we will create a list only exist that image name

  create  a file name list-txt and it content is
  myimage.jpg  (total 3980 lines)
  why 3980 lines of myimage.jpg in the list-txt file, it is depend of what is your   mp3 file duration and fps of the video that you will create
 in this example i will create video with 19 fps and duration of our mp3

 so it will be 3:29 mn = 209 s, 209 * 19  = 3971  and I put 3980 to make it last
 a little longer than our mp3

 if you're lazy to copy/paste, this is the bash script to create list-txt file with your
 provided lines

rm "list-txt"
for i in  $(seq 1 1 $1)
   echo $2 >> list-txt

usage: sh 3980 "myimage.jpg "

3- create a video file from our list
$ mencoder mf://@list-txt -mf w=300:h=300:fps=1:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o myvideo.avi

4- add mp3 file to the video file
$ avidemux myvideo.avi  --external-mp3 mysong.mp3  --output-forma avi --save finalvideofile.avi --quit 

finally you'll get the video file and the mp3 saving as finalvideofile.avi
and look like below

No comments:

Post a Comment