I record video from web using flash media server. Now using flex default player i tried to play video but, it will not play ipad.(ios device)
I checked that video codec and it is something like following:
libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 45.100 / 55. 45.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 10.100 / 4. 10.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
[flv # 0000000002b60220] Stream discovered after head already parsed
Input #0, flv, from 'C:\Users\Administrator\Desktop\123654789.flv':
Metadata:
canSeekToEnd : false
createdby : FMS 4.5
creationdate : Tue Jun 30 16:27:22 2015
Duration: 00:00:15.25, start: 0.000000, bitrate: 52 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x227, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: speex, 16000 Hz, mono, s16, 20 kb/s
Stream #0:2: Data: none
I record video following ways:
netstream.publish("FILENAME","record");
Thanks.
Edit:
Another flv file i got which is played in ios. But when i check it's codec it something like following:
r --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab -
-enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 45.100 / 55. 45.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 10.100 / 4. 10.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from 'C:\Users\Administrator\Desktop\16402.flv':
Metadata:
major_brand : 3gp4
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf55.45.100
Duration: 00:00:13.23, start: 0.000000, bitrate: 304 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x240, 300 kb/s, 15 fps, 15 tbr, 1k tbn
, 1k tbc
Stream #0:1: Audio: mp3, 22050 Hz, mono, s16p, 0 kb/s
How, can i record/convert flv like below?
It's a normal behavior that iPAD didn't play your FLV video because simply it's not supported by iOS, as mentioned here by Apple :
iOS supports many industry-standard video formats and compression standards, including the following:
H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats
H.264 video, up to 768 Kbps, 320 by 240 pixels, 30 frames per second, Baseline Profile up to Level 1.3 with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats
MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats
Hope that can help.
You should transcode it into H.264 mp4 stream on Flash Media Server and feed that stream into your flex application. If you record the video by Adobe Live Video Encoder there is an option to set the output format either. I did that a few years ago.
Related
Regards community,
I want to use ffmpeg to generate a file (txt, csv) from audio values.
Any idea?
I use this code to generate the audio levels:
ffplay -f lavfi "amovie=input.aac, asplit [a][out1]; [a] showvolume=f=1:b=4:w=800:h=70 [out0]"
Thank you a lot
The command below will generate a CSV format where the first column represents the audio frame time in seconds, the second column the overall RMS dB volume for that frame, the 3rd column RMS volume for the first channel and the last column the RMS volume for the 2nd channel.
ffprobe -f lavfi -i amovie=input.aac,astats=metadata=1:reset=1 -show_entries frame=pkt_pts_time:frame_tags=lavfi.astats.Overall.RMS_level,lavfi.astats.1.RMS_level,lavfi.astats.2.RMS_level -of csv=p=0
Output:
Duration: N/A, start: 0.023220, bitrate: N/A
Stream #0:0: Audio: pcm_f64le, 44100 Hz, stereo, dbl, 5644 kb/s
0.023220,-inf,-inf,-inf
0.046440,-inf,-inf,-inf
0.069660,-inf,-inf,-inf
0.092880,-27.330401,-22.685612,-24.414572
0.116100,-21.141091,-18.986082,-19.931269
0.139320,-20.955719,-18.549085,-19.587788
0.162540,-20.938002,-18.198237,-19.355561
0.185760,-19.852306,-20.032553,-19.941494
0.208980,-20.495281,-21.684953,-21.049508
The reset determines how often the stats are calculated. I've set the value to 1 i.e. calculated for each audio frame in isolation.
I've been trying just about every single permutation of options on ffmpeg to try to get a transcoded video to display on Chrome - OSX 39.0.2171.71 (64-bit) - so far nothing has worked.
The settings I am currently using look like:
/usr/local/Cellar/ffmpeg/2.4.3/bin/ffmpeg -i source.m4v -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -preset slower -crf 23 -vf scale=640:360 target.mp4
but I've tried various options from various other answers with no success.
The video-js demo video works fine, so it must be possible somehow. Here's a dump of the encoded video:
*** General Parameters ***
- Name: test-1 (2).mp4
- Container: MP4 - QuickTime
- Size: 3.45 MB
- Duration: 32s 299ms
- Bitrate: 856 Kbps
*** Video Track Parameters ***
- Format: H.264/MPEG-4 AVC
- Bitrate: Max.: --- / Average: 721 Kbps / Min.: ---
- Frame rate (fps): Max.: --- / Average: 30.000 / Min.: ---
- Encoding profile: Baseline#L3.0
- Image size: 640*360
- Pixel Aspect Ratio: Undefined
- Display Aspect Ratio: 16:9
- Interlacing: Progressive
*** First Audio Track Parameters ***
- Format: AAC - MPEG-4 audio
- Bitrate: 128 Kbps
- Resolution: Undefined
- Rate: 44.1 KHz
- Channel(s): 2 (stereo)
- Position: Front: L R
Turns out that the metadata is in the wrong place. Adding -movflags +faststart to the ffmpeg parameter list makes it start working.
I have a problem.
I'm currently trying to manually calculate the bitrate of a .mkv video I want to encode to get a specific file size so I can use that in my batch file.
Size I want the clip to be: 1900 MB --
Duration: 2587 seconds --
Audio bitrate: 1509 kbps
My current calculation is:
1900MB*1024 seconds 1509/8 seconds
(1945600 - (2587 x 188,625) ) / 2587 = 563,44303247004252029377657518361 KBps
563,44303247004252029377657518361 * 8 = 4507,5442597603401623502126014689 kbps
I tried encoding with this bitrate, however the file size won't match 1900 MB, so I
used a bitrate calculator and after putting in my settings it says for 1900 MB, the video needs a bitrate of 4647 kbps (encoded with this bitrate, and it was 1899 MB).
My question is, what did I miss in my calculation?
"kilo" is 1024 for data size, but 1000 for bitrate.
1992294400 bytes for whole file [1900 MB * 1024 * 1024]
-487972875 bytes for audio [1509/8 * 1000 * 2587]
= 1504321525 bytes for video [4652/8 * 1000 * 2587]
video bitrate: 4652 kbps
This result more closely matches the calculator you used than your result, although I can't explain the remaining discrepancy of about 5kbps. Perhaps the calculator accounts for framing overhead or seek tables or some other metadata.
I would trust the calculator, since using its value gave you results very close to your goal.
I am trying to specify a specific video/audio codec in the video tag using
<video poster="movie.jpg" controls>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'/>
<p>This is fallback content</p>
</video>
but can't find the right codecs statement to play the video , i have downloaded a video analyser and can see that its an avc1 and can see that the audio map.40.2 but can work out the rest of the codec, what does the 4d401e mean in the above ?
Cheers
Toby
The codecs parameter is specified by RFC 6381. Specifically, see section 3.3 for the meaning of avc1 and mp4a values.
In the case of avc1.4D401E, avc1 indicates H.264 video, and this is followed by a dot and three 2-digit hexadecimal numbers defined by the H.264 standard:
profile_idc
the byte containing the constraint_set flags (currently constraint_set0_flag through constraint_set5_flag, and the reserved_zero_2bits)
level_idc
Some examples:
avc1.42E01E: H.264 Constrained Baseline Profile Level 3
avc1.4D401E: H.264 Main Profile Level 3
avc1.64001E: H.264 High Profile Level 3
These are also the second, third, and fourth bytes of the Sequence Parameter Set and the AVC Configuration Box in an MP4 file. You can dump these bytes using a program such as mp4file: mp4file --dump movie.mp4. Look for the avcC (AVC Configuration) Box and the hexadecimal values for AVCProfileIndication, profile_compatibility, and AVCLevelIndication.
As for mp4a.40.2, mp4a indicates MPEG-4 audio. It is followed by a dot and a hexadecimal ObjectTypeIndication (objectTypeId in mp4file output), which can be looked up on the MPEG4 registration site. If this hexadecimal value is 40 (ISO/IEC 14496-3 Audio), it is followed by another dot and an audio object type in decimal. These are listed in the ISO/IEC 14496-3 standard and on Wikipedia, and correspond to the first 5 bits of the DecoderSpecificInfo (decSpecificInfo) (unless these bits equal 31, in which case add 32 to the next 6 bits). mp4a.40.2 indicates AAC LC audio, which is what is usually used with H.264 HTML5 video.
For example, codecs="avc1.42E01E, mp4a.40.2" would be correct for the movie below:
$ mp4file --dump movie.mp4
...
type avcC (moov.trak.mdia.minf.stbl.stsd.avc1.avcC) ◀━━ avc1
configurationVersion = 1 (0x01)
AVCProfileIndication = 66 (0x42) ◀━━ 42
profile_compatibility = 224 (0xe0) ◀━━ E0
AVCLevelIndication = 30 (0x1e) ◀━━ 1E
...
type esds (moov.trak.mdia.minf.stbl.stsd.mp4a.esds) ◀━━ mp4a
version = 0 (0x00)
flags = 0 (0x000000)
ESID = 2 (0x0002)
streamDependenceFlag = 0 (0x0) <1 bits>
URLFlag = 0 (0x0) <1 bits>
OCRstreamFlag = 0 (0x0) <1 bits>
streamPriority = 0 (0x00) <5 bits>
decConfigDescr
objectTypeId = 64 (0x40) ◀━━ 40
streamType = 5 (0x05) <6 bits>
upStream = 0 (0x0) <1 bits>
reserved = 1 (0x1) <1 bits>
bufferSizeDB = 0 (0x000000) <24 bits>
maxBitrate = 78267 (0x000131bb)
avgBitrate = 78267 (0x000131bb)
decSpecificInfo
info = <2 bytes> 11 90 |..| ◀━━ 2 (first 5 bits in decimal)
...
You can use MP4Box tool to find out codec strings in RFC6381 format. Still you have to join them with commas.
You can use this command:
MP4Box -info big.mp4 2>&1 | grep RFC6381 | awk '{print $4}' | paste -sd , -
mark4o gives by far the best explanation I've seen of how to decipher codec information. Excellent.
One piece which may require a little more detail is how to break out the specific audio object type from the decSpecificInfo value. Finding the "mp4a.40" part is very clear, the ".2" section can be a little tricky.
We start with a sequence of single byte hexadecimal values: "11 90" in mark4o’s example or "12 08" in my case. Both of those are a total of 2 bytes... there may be more values but only the first 2 matter for finding the object type (and usually only the first byte). We're looking for individual bits so convert each digit in the hexadecimal values to binary; there should be 4 binary digits for each hexadecimal digit. Take the first 5 binary digits — 4 from the first hex digit, 1 from the next — and convert that binary value to decimal. Here are the steps:
Example 1 (11 90):
Starting value: 11 90
Separate the hex digits: 1 1 9 0
Convert each digit to binary: 0001 0001 1001 0000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
Example 2 (12 08):
Starting value: 12 08
Separate the hex digits: 1 2 0 8
Convert each digit to binary: 0001 0010 0000 1000
Take the first 5 bits: 0001 0
Combine into binary value: 00010
Convert to decimal: 2
They are the same object type in spite of having different decSpecificInfo values.
You could also simply do this to find the right codec infor:
go to the folder containing your video file, lets assume the file is called movie.mp4,
The run the command:
vlc movie.mp4
assuming you have vlc installed, if the video plays vlc will have the correct codec information,
Click on the tools menu above, a drop down list will be displayed with an option to view the codec information as below.
I am creating an MPEG-4 file from H.264 stream. H.264 stream comes in NAL format (EG: 0,0,0,1,67,...,0,0,1,68,...).
Each video frame is transmitted as multiple I-frame/P-frame fragments. For eg: Frame 1 contains approximately 80 I-frame fragments and Frame 2 contains around 10 P-frame fragments.
I understand that MDAT atom of the MPEG-4 file is supposed to contain H.264 streams in NAL format.
I would like to know how these fragments can be converted to a single I-frame before I can put it into MDAT atom of MPEG-4.
I do not want to use any libraries.
Thanks for your help.
You are going to convert H.264 Annex B NAL stream into MP4 file packets. In order to do that you need to:
Split your original file into NAL units ( 00 00 00 01 yy xx xx ... );
Locate frame boundaries: each H.264 frame typically contains a number of slices and optionally one of these: SPS, PPS, SEI. You'll need to parse the 'yy' octet above to determine what kind of NAL unit you are looking at. Now, in order to know the boundary of a frame you will need to parse the first part of each slice called 'SliceHeader' and compare 'frame_number' of consequitive slices.
As soon as you know the frame boundaries you can form MP4 packets. Each packet will contain exactly one frame and and NAL units in this format:
l1 l1 l1 l1 yy xx xx ...
l2 l2 l2 l2 yy xx xx ...
so basically your replace each delimeter '00 00 00 01' with integer holding the length of this NAL unit.
Then in order to obtain correct MP4 header you'll need to use MP4 muxer and populate correct 'AvcC' atom inside of a sample entry of your video track.
This is a rather tedious process but if you want to get into specifics you can study the source code of JCodec ( http://jcodec.org ): org.jcodec.samples.transcode.TranscodeMain , org.jcodec.containers.mp4.MP4Muxer