Videos created using FFmpeg are not being displayed in web browsers such as Chrome, Firefox, and Safari - ffmpeg

I am attempting to generate an MP4 video by combining images and audio with FFmpeg-Kit-React-Native but it is not being displayed in web browsers.
For your reference I'm attaching the package link below:
ffmpeg-kit-react-native
The commands I utilized to produce the video are as follows:
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360 -f mp4 ${outputFile}
-loop 1 -i ${imageFile} -i ${audioFile.uri} -shortest -acodec copy ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -b:v 2M -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -pix_fmt yuv420p ${outputFile}
-i ${imageFile} -i ${audioFile?.uri} -vf scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1 -f mp4 ${outputFile}
I have attached a link to the video I generated using a single image and one audio file
Additionally, I am unable to install external encoding packages such as full-gpl, full, https-gpl, and min-gpl on the Android side.

You do not specify a video codec for your format (-f mp4). In that case ffmpeg uses 'a' default video codec. If i run ffprobe on your file, the output for the video stream is:
Video: mpeg4 (Simple Profile)
According to https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#mpeg-4_mp4, firefox does not support this codec (as to the other browsers, please do your own research).
The solution is to use one of the supported video codecs, e.g. AVC (H.264) or VP9.
To specify the H.264 codec in ffmpeg use the argument -codec:v libx264.
To list all available encoders, run: ffmpeg -encoders
If the required codecs are not listed in the output, you have to configure ffmpeg and specify, e.g. --enable libx264.
See also: FFmpeg - H.264 Video Encoding Guide

Related

How add scale in my ffmpeg command

i want convert video from any format to mp4. so i am using command:
ffmpeg -i ttt.mp4 -vcodec copy -acodec copy test.mp4
this is working perftectly but now i also add scale in this -s 320:240.
There also many other command for convert LIKE :
ffmpeg -i inputfile.avi -s 320x240 outputfile.avi
but after convert by this command video not play in html5 player
BUT this is not working so tell me in my command how i add scale;
So please provide me solution for this .
Thanks in advance.
You have several problems:
In your command, you have -vcodec copy you cannot scale video without reencoding.
In the command you randomly found on the Internet, they are using AVI, which is not HTML5-compatible.
What you should do is:
ffmpeg -i INPUT -s 320x240 -acodec copy OUT.mp4
Adding to Timothy_G:
Video copy will ignore the video filter chain of ffmpeg, so no scaling is available (man ffmpeg is a great source of information that you will not find on Google). Notice that once you start decoding-filtering-encoding (i.e., no copy) the process will be much slower (x100 time slower or even more). The libx264 is recommended if you want compatibility with all browsers.
$ ffmpeg -i INPUT -s 320x240 -threads 4 -c:a copy -c:v libx264 OUT.mp4
vp9 will provide nearly 50% extra bandwidth saving, but only for supported browsers (Firefox/Chrome), and the encoding will much slower compared to libx264 (that itself is much slower that v:c copy):
$ ffmpeg -i INPUT -s 320x240 -c:a copy -c:v vp9 OUT.webm
Notice that there is a set of formats (containers) accepted by browsers (most admit mp4, some also webm, ...) and for each format there is a set of audio/video codecs accepted. For example you can use mp3 or aac with an mp4 file (container), but not with webm files.
http://en.wikipedia.org/wiki/HTML5_video#Supported_video_formats

Converted mp4 h264 baseline format loads long time

I have converted my video to mp4 x264 baseline format and it works fine with all pc/mobile phones , the problem is it takes long time to load the video while googling came to know that ffmpeg converts and sets the index file at the eof the video so it loads to the end to read and then plays the video, So any advices would be appreciatable to cut short the loading time.
Note:tryied out QT index swapper2 but dint give much difference , please advice .
this is the cmd i used to convert -
ffmpeg -i … -c:v libx264 -profile:v baseline -level 1 …
Thanks for your time .
You have several options to relocate the moov atom so the video can begin playback before it is completely downloaded by the client.
-movflags faststart
The easiest is the option -movflags faststart when re-encoding:
ffmpeg -i input -c:v libx264 -profile:v baseline -movflags faststart output.mp4
If you already encoded your .mp4 file, but simply want to move the atom:
ffmpeg -i input.mp4 -codec copy -movflags faststart output.mp4
You may need to get a more recent ffmpeg version to use this option. See the FFmpeg download page for links to ffmpeg builds for Linux, OS X, and Windows, or you can follow a step-by-step guide to compile ffmpeg.
qt-faststart
Alternatively you can use the qt-faststart tool that comes with the ffmpeg source:
cd ~/ffmpeg/tools
make qt-faststart
./qt-faststart input.mp4 output.mp4
MP4Box
Or you could use MP4Box (usually provided by the gpac package depending on your distro):
MP4Box -add input.mp4 output.mp4
Also See
FFmpeg and x264 Encoding Guide
FFmpeg and AAC Audio Encoding Guide

Pseudo-streaming mp4 files does not work with flash player

I've got a problem with streaming audio on my website. I thought I could put the MP3 file inside an MP4 container with h264 codec, so I can use pseudo-streaming ability of mp4 codec.
The code I'm using to convert my files is:
ffmpeg -i 1.mp3 -y -b:a 32K -vn 1.mp4
Pseudo-streaming (seeking in not-loaded parts of media) now works in HTML5 player but not in any Flash media players such as JWPlayer or FlowPlayer.
I've tested my files on both Apache server with h264 module enabled and Nginx with mod_mp4 enabled, but without any lucks.
I tried MP4Box, QTIndexSwapper and even creating a real video file by mixing of an image loop and my audio file.
ffmpeg -y -i joojoo.png -i 2.mp3 -vcodec mjpeg havij.mp4
MP4Box -add havij.mp4 -isma havij_new.mp4
What am I doing wrong? What can I do to make it work?
You have to hint the file. Check out mp4box -hint

Create MP4 video using FFMPEG and JPEG2000 frames

I'm trying to create an MP4 video with ffmpeg using JPEG2000 images as frames.
It works when the JPEG2000 is 8bpp, but I need it to work for at least 12 bits (ideally 12, but could be 16). The images are grayscale.
This is the command I'm using:
ffmpeg.exe -i imagen.jp2 video1.mp4
If I try to use -pix_fmt it says it's not supported by the encoder (it doesn't matter which format I use).
Some sample images can be found here:
http://ioingresodemanda.com/jp2.rar
I could also use any other tool, it doesn't need to be ffmpeg.
UPDATE: Adding ffmpeg output - http://pastebin.com/NyY3vgpz
Thanks in advance
If you are ok with mp4 file having a different video format the following will work
ffmpeg -strict -2 -i 12bit.jp2 -vcodec libx264 -an out.mp4
ffmpeg -strict -2 -i 12bit.jp2 -vcodec mpeg4 -an out.mp4
ffmpeg doesn't support 12-bit color. Most of the H264 profiles only support 8-bit color; a few support 10-bit, and only the super-obscure lossless Hi444PP profile supports 14-bit color. The x264 encoder does support some of the profiles with 10-bit color, but that's as far as it goes, and you have to explicitly enable it using the --bit-depth option:
http://git.videolan.org/?p=x264.git;a=commit;h=d058f37d9af8fc425fa0626695a190eb3aa032af
As noted in the commit, you may also want to keep in mind that "very few H.264 decoders support >8 bit depth currently".

Stream H264 To Android Using FFMPEG

I'm trying to stream a .ts file containing H.264 and AAC as an RTP stream to an Android device.
I tried:
.\ffmpeg -fflags +genpts -re -i 1.ts -vcodec copy -an -f rtp rtp://127.0.0.1:10
000 -vn -acodec copy -f rtp rtp://127.0.0.1:20000 -newaudio
FFMPEG displays what should be in your SDP file and I copied this into an SDP file and tried playing from VLC and FFPLAY. VLC plays audio but just gives errors re: bad NAL unit types for video. FFPLAY doesn't play anything.
My best guess if that the FFMPEG H.264 RTP implementation is broken or at least it doesn't work in video passthru mode (i.e. using the -vcodec copy).
I need a fix for FFMPEG or an alternate simple open-source solution. I don't want to install FFMPEG in my Android client.
thanks.
Have you tried vlc?I once used vlc for streaming. You can have a look at here.

Resources