Showing posts with label FFmpeg. Show all posts
Showing posts with label FFmpeg. Show all posts

Monday, April 18, 2016

convert avi video to HTML5 video tag supported format

convert avi video to HTML5 video tag supported format

.h264 is just a raw H.264 bytestream. That's just video content, which can be played back by sophisticated players, but usually you want to put everything into a container format, such as MPEG-4 Part 14 ("MP4").

So, run:

# ffmpeg -i test_video.avi -c:v libx264 -pix_fmt yuv420p test_video.mp4

For HTML5 progressive download you may want to move the moov atom of the MP4 container to the beginning of the file, which allows instant playback:

# ffmpeg -i test_video.avi -c:v libx264 -pix_fmt yuv420p -movflags faststart test_video.mp4

You may be interested in: What is a Codec (e.g. DivX?), and how does it differ from a File Format (e.g. MPG)?

<html>
<body>
<h1>Test Video</h1>
<video width="300" height="300" autoplay loop>
  <source src="test_video.mp4" type="video/mp4">
</video>
</body>
</html>


Reference:

http://superuser.com/questions/750811/convert-avi-into-h-264-that-works-inside-an-html5-video-tag

Friday, December 11, 2015

【好物介紹】把瀏覽器當虛擬平台?

每次要跑虛擬機時,都要有一個Hypervisor,不管是原生或寄居架構,但不管是哪一種架構,總要有一個硬體平台吧?總要分配CPU、記憶體或磁碟空間吧?下面這個Linux,卻是真正把VM的層次拉高到最上層:瀏覽器。這是一個用Javascript重寫的Linux核心,而Javascript的執行平台正是瀏覽器!曾經有人懷疑這只是一個模擬Linux的介面而已,但現在已證實是真正的Linux核心了。


Fabrice Bellard是誰應該不用介紹了,是ffmpeg、QEMU的原創人,高中時就開發出LZEXE這個壓縮軟體,不但是有名的電腦工程師,也是有名的數學家,這邊可以看到Fabrice Bellard的維基介紹。

這個用Javascript寫出來的Linux不但可以執行,更可以用來學習Linux的指令,如vi等。大家就到

http://bellard.org/

到這邊來玩玩吧!

Reference:
http://vaemon.com/article/1363.html
http://www.softwarequalityconnection.com/2011/03/fabrice-bellard-portrait-of-a-superproductive-programmer/

===

A PC emulator in Javascript (a recent browser is required): how much time takes your browser to boot Linux ?
2700 billion decimal digits of Pi computed with a desktop computer.
Analog and Digital TV (DVB-T) signal generation by displaying an image on a PC display.
QEMU is a generic machine emulator and virtualizer.
FFMPEG, the Open Source Multimedia System. I launched this project in year 2000 and led it during several years.
TCC is a tiny but complete ISOC99 C compiler which enables you to use C as scripting language. TCC has its roots in the OTCC project. The TCCBOOT boot loader demonstrate the speed of TCC by compiling and launching a Linux kernel in less than 15 seconds.
QEmacs (for Quick Emacs) is an emacs clone I began to learn Unicode rendering algorithms, text buffers manipulation and XML/HTML/CSS parsing.
OTCC is a very small self-compiling compiler for a subset of C I wrote to win the 2001 edition of the International Obfuscated C Contest.
TinyGL: a Small, Free and Fast Subset of OpenGL.
An online Scientific Web Calculator.
Pi formulas, algorithms and computations.
tiny C program to print the biggest known prime number.

19 ffmpeg commands for all needs

ffmpeg is a multiplatform, open-source library for video and audio files. I have compiled 19 useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.

Getting infos from a video file
ffmpeg -i video.avi
Turn X images to a video sequence
ffmpeg -f image2 -i image%d.jpg video.mpg
This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.
Turn a video to X images
ffmpeg -i video.mpg image%d.jpg
This command will generate the files named image1.jpg, image2.jpg, …
The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4
Explanations :
  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 128kb/s
  • Video codec : mpeg4
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Encode video for the PSP
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4
Explanations :
  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 32kb/s
  • Video codec : xvid
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Extracting sound from a video, and save it as Mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
Explanations :
  • Source video : source_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : sound.mp3
Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg
Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi
Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif
Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 128k -ar 44100 -b 512k -r 15 -s 640x480 -f flv video_finale.flv
Convert .avi to dv
ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv
Or:
ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to mpeg for dvd players
ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg
Explanations :
  • target pal-dvd : Output format
  • ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
  • aspect 16:9 : Widescreen
Compress .avi to divx
ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Compress Ogg Theora to Mpeg dvd
ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg
Compress .avi to SVCD mpeg2
NTSC format:
ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg
PAL format:
ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg
Compress .avi to VCD mpeg2
NTSC format:
ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg
PAL format:
ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg
Multi-pass encoding with ffmpeg
ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2

Reference:
http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

Convert video to gif

Convert video to gif

Install ImageMagick. ImageMagick has already included ffmpeg.exe in its installation file.

# mkdir tmp

# mkdir out

# ffmpeg -i MyVideo.avi -vf fps=fps=10 tmp/out%06d.png

(or ffmpeg -i MyVideo.avi -t 10 tmp/out%06d.png)
(or ffmpeg -i MyVideo -an -r 10 -y -s 640x480 out/out%06d.png)

# mogrify -format gif tmp/*.png

# convert -delay 10 tmp/*.gif -loop 0 out/out.gif

# convert -layers Optimize out/out.gif out/out_optimized.gif

# del "tmp\*"

Reference:

http://stackoverflow.com/questions/6079150/how-to-generate-gif-from-avi-using-ffmpeg

http://www.atrixnet.com/animated-gifs/