convert from avi to mp4 using ffmpeg - html

I want to play an avi video format file in browsers using HTML5 video code. Since the
avi format file doesn't play in browsers i have to convert it into mp4 format file.
For conversion i am using the ffmpeg code in Windows.
ffmpeg -i input.avi OUTPUT.mp4
The conversion of video is completed but the video codec and audio codec isn't valid thus it fails to play to play using video tag in html5.
Please find me proper code which coverts the file.
another conversion code i tried was.. ffmpeg -i input.avi -c:v libx264 -preset slow -crf 22 -c:a libfaac -b:a 128k OUTPUTAVINew.mp4 but i got error as libfaac unknown encoder
please help me out and even i downloaded the **libfaac.dll** but didn't work out
`

Old, but this post comes up tops in searches so...
ffmpeg should easily convert from avi to mp4 without re-encoding. (Do not specify new codecs!)
ffmpeg -i input.avi -c:v copy -c:a copy OUTPUT.mp4
Should also mention that batch conversions run most reliably when the script contains static data with each ffmpeg call on a new line (as opposed to having the script generate each call dynamically using variables).

I would suggest you use the latest version of ffmpeg. You don't
need to download extra dlls.
Use libvo_aacenc instead of libfaac
-crf 22 is high use lower say -crf 19
As far my experience I would use
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 19 -c:a libvo_aacenc -b:a 128k

code to avi to mp4.ffmpeg provides the best solution
ffmpeg -i input.avi -strict -2 output.mp4

For example there is a video file 139MB input.avi
ffprobe input.avi
Input #0, avi, from 'input.avi':
Metadata:
encoder : Lavf51.12.1
Duration: 00:21:20.16, start: 0.000000, bitrate: 891 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (xvid / 0x64697678), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 769 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 32000 Hz, stereo, fltp, 112 kb/s
For the nearly loseless re-containering use:
ffmpeg -i "input.avi" -c:v copy -c:a copy "input.mp4"
where -c:v copy copy video
-c:a copy copy audio
Conversion about 2 sec, result is input.mp4 138MB. It is fast, and almost same quality as original. Best practice is let the audio in the original format.
ffprobe input.mp4
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.29.100
Duration: 00:21:20.16, start: 0.000000, bitrate: 884 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 769 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 32000 Hz, stereo, fltp, 112 kb/s (default)
Metadata:
handler_name : SoundHandler
If you have time, and want to recodec almost same quality, but 1/3 size, use this:
ffmpeg -i "input.avi" -c:a copy -c:v vp9 -b:v 100K "input.vp9.mp4"
where -c:a copy copy audio -c:v vp9 -b:v 100K re-encode video with 100K bitrate. 138MB re-encoding takes about 40min and the new file size is 41MB the quality is nearly same as original, but pixeled a bit.
ffprobe input.vp9.mp4
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.29.100
Duration: 00:21:20.16, start: 0.000000, bitrate: 261 kb/s
Stream #0:0(und): Video: vp9 (Profile 0) (vp09 / 0x39307076), yuv420p(tv, progressive), 640x480, 146 kb/s, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 32000 Hz, stereo, fltp, 112 kb/s (default)
Metadata:
handler_name : SoundHandler

Related

Gstreamer misses H.264

I wanted to try GStreamer to connect to a remote IP camera using RTSP stream.
So I've downloaded and installed the last version.
On Using GStreamer page said: GStreamer also provides playbin, a basic media-playback plugin that automatically takes care of most playback details
So I've tried to connect to the camera using the following command:
gst-launch-1.0 playbin uri=rtsp://192.168.1.2:554/av0_0
Unfortunately I get error:
ERROR: from element
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: Your GStreamer
installation is missing a plug-in. Additional debug info:
../gst/playback/gsturidecodebin.c(988): no_more_pads_full ():
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: no suitable
plugins found: ../gst/playback/gstdecodebin2.c(4679):
gst_decode_bin_expose ():
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0:
no suitable plugins found: Missing decoder: H.264 (Main Profile)
(video/x-h264, stream-format=(string)byte-stream,
alignment=(string)au, level=(string)3.1, profile=(string)main,
width=(int)1280, height=(int)720, framerate=(fraction)0/1,
interlace-mode=(string)progressive, chroma-format=(string)4:2:0,
bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8,
parsed=(boolean)true)
Does it mean that my installation missed decoder for h264? How could it been? I guess that h264 is the most popular codec. Did I do something wrong?
Update:
./gst-inspect-1.0 | grep h264
videoparsersbad: h264parse: H.264 parser
typefindfunctions: video/x-h264: h264, x264, 264
rtp: rtph264pay: RTP H264 payloader
rtp: rtph264depay: RTP H264 depayloader
openh264: openh264enc: OpenH264 video encoder
openh264: openh264dec: OpenH264 video decoder
Have you installed GStreamer MSI with the "Complete" option? If it's installed in Typical mode, then the libav plugins won't be installed. You can change the installation and select the additional feature or do a re-install.
When you install in the Complete mode, you should be able to find avdec_h264. Alternatively, you can select Custom mode and then enable the "GStreamer 1.0 libav wrapper".
$ gst-inspect-1.0.exe libav | grep h264
avdec_h264: libav H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder

How to setup HLS and DVR functionality and read it?

I want to create an audio stream live with the DVR functionality.
In my player I want to listen live or seek the past stream (few minutes ago).
I use nginx to serve the hls stream.
How to setup the DVR functionality? Do I use a specific module in nginx for live stream and past stream with a param like past.m3u8?seek=timestamp
I'm also looking for a web player in html5 and fallback in flash to read the live stream and can seek the past.m3u8 stream.
I've setup nginx with this config:
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
I create hls stream with avconv.
avconv -i [input] -vn -sn -c:a libfdk_aac -b:a 64k -hls_time 10 /path/to/hls/playlist.m3u8
To read this stream I use clipr player who permits to seek the stream.

FFmpeg Converted files not working on firefox

When i convert a file with ffmpeg and play the video in firefox i get this error :
"VIDEOJS:" "ERROR:" "(CODE:3 MEDIA_ERR_DECODE)" "The video playback was aborted due to a corruption problem or because the video used features your browser did not support." Object { code: 3, message: "The video playback was aborted due to a corruption problem or because the video used features your browser did not support." }
In other browsers it's working perfect.
This is my ffmpeg convert command:
ffmpeg -i {input} -b 5500k -minrate 5500k -maxrate 5500k -bufsize 5500k -ab 384k -vcodec libx264 -acodec aac -strict -2 -ac 2 -ar 96000 -s 1280x720 -y {output}
Can someone tell me why the videos won't play in firefox?

How can I watch my video from a sdp file?

I'm using ffmpeg to create a streaming. It works fine. I have a server and with ffplay I can watch my stream.
My only (big) constraint is real time.
I have to embed it into an HTML page accessible from mobile devices.
I tried with HTML5 video tag but I can't include sdp files into it.
With ffmpeg I create a stream from my webcam. I have also created the sdp file but in HTML5 doesn't work.
The code is here:
ffmpeg server:
sudo ffmpeg -re -f video4linux2 -i /dev/video0 -fflags no buffer rtp://224.10.20.30:20000
file.sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 224.10.20.30
t=0 0
a=tool:libavformat 55.7.100
m=video 20000 RTP/AVP 96
b=AS:200
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1
ffplay: (It works)
ffplay file.sdp
How can I view the stream in a browser?

how to unsquashfs or mount a firmware image?

i want to extract my routers firmware, and modify it. so i used bitsum's firmware mod kit. it seems there is no error. i can get image_parts directory also there is rootfs.img (squashfs image) file. but the problem is i can neither mount it nor unsquashfs.
This is extraction output:
# ./extract-ng.sh AirTies_Air5021RU_FW_1.2.0.16_FullImage.bin
Firmware Mod Kit (extract-ng) 0.69 beta, (c)2011 Craig Heffner, Jeremy Collake
http://www.bitsum.com
Scanning firmware...
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
65228 0xFECC Squashfs filesystem, big endian, version 2.0, size: 1369418 bytes, 382 inodes, blocksize: 65536 bytes, created: Tue May 3 13:44:22 2011
Extracting 65228 bytes of header image at offset 0
Extracting squashfs file system at offset 65228
Extracting 160 byte footer from offset 1972107
Extracting squashfs files...
Firmware extraction successful!
Firmware parts can be found in 'fmk/*'
Mount attempt output:
fmk# ls
image_parts logs rootfs
fmk# cd image_parts/
fmk/image_parts# ls
footer.img header.img rootfs.img
fmk/image_parts# file rootfs.img
rootfs.img: Squashfs filesystem, big endian, version 2.0, 1369418 bytes, 382 inodes, blocksize: 65536 bytes, created: Tue May 3 13:44:22 2011
fmk/image_parts# mount rootfs.img /mnt/rootfs/ -o loop -t squashfs
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
fmk/image_parts# dmesg | tail -n 1
[24799.284066] SQUASHFS error: Can't find a SQUASHFS superblock on loop0
unsquashfs attempt output:
fmk/image_parts# unsquashfs rootfs.img
Reading a different endian SQUASHFS filesystem on rootfs.img
Parallel unsquashfs: Using 1 processor
336 inodes (377 blocks) to write
[=============================| ] 99/377 26%
gzip uncompress failed with error code -3
Failed to write squashfs-root/lib/libqueue.so, skipping
[=============================| ] 100/377 26%
gzip uncompress failed with error code -3
gzip uncompress failed with error code -3
gzip uncompress failed with error code -3
...
Failed to write squashfs-root/lib/modules/2.6.8.1/extra/blaa_dd.ko, skipping
[====================================| ] 123/377 32%
gzip uncompress failed with error code -3
gzip uncompress failed with error code -3
...
Failed to write squashfs-root/webs/management/ui_password.html, skipping
[========================================================| ] 191/377 50%
gzip uncompress failed with error code -3
Failed to write squashfs-root/webs/index.html, skipping
[========================================================| ] 192/377 50%
gzip uncompress failed with error code -3
...
Failed to write squashfs-root/usr/sbin/brctl, skipping
[===============================================================================================================|] 377/377 100%
created 188 files
created 46 directories
created 52 symlinks
created 95 devices
created 1 fifos
i searched "error code -3", it is Z_DATA_ERROR ( data is corrupted or incomplete ).
now what should i do?
thanks
Bcm63xx firmware images has a special format like squashfs-lzma. i got some tools to extract firmware images named bcm tools (brfwmod.exe). It has a command named lzma-unsquash. i successfully unaquash it with theese tools.