Greeting your users with specially designed video cards can strengthen the levels of loyalty they have with you. Designing a video card demands serious dedication and approach that would be ideal in terms of appealing to all the target users.You need to keep a good account for all the aesthetics as well as the technicalities involved in this process to make it the very best. Creating a video card specially in mp4 format from animated SWF files is a challenging task. Our Client need was to send mp4 video greeting cards to his users. This will be a user centric application where user will provide the text and images that will be shown in the mp4 video.
We provided him a solution that if he build his animations in SWF format with variables, then we can automate the whole process. The challenge came up to convert SWF files to mp4 videos along with the integrated dynamic variables.
We did research and came up with a partially unknown tool GNU Gnash. Its a SWF Player for Linux environments. This player also have support of passing dynamic variables. Gnash came up with a tool called dump-gnash which actually parse and save raw video and audio streams separately. We used the following command to create video and audio files:
dump-gnash -1 -D output_video.raw@30 -A output_audio.wav -P "FlashVars=title=Some Title" swf_file_with_variables.swf
Now we have two files called output_video.raw which is a raw video file, @30 convention is used to tell Gnash to use 30 frames per second. Other file we have output_audio.wav which is raw audio file.
Now we need to merge both audio and video files together to make mp4 file. For this, we have most popular ffmpeg. We used the following command to merge audio and video files:
ffmpeg -i output_audio.wav -f rawvideo -pix_fmt rgb32 -s:v 550x400 -r 30 -i output_video.raw -c:v libx264 -r 30 -b 160k -strict -2 output_video.mp4
Challenging part to merge both was using raw video format with ffmpeg. Our research leaded us to `-strict -2` option which actually helps to use a raw video format.