Executing avprobe test.h264
outputs
Input #0, h264, from 'test.h264':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 720x480, 25 fps, 25 tbn, 50 tbc
Executing file test.h264
outputs
test.h264: JVT NAL sequence, H.264 video @ L 30
Note that the file isn't damaged or corrupted, I can play it with no problem on VLC.
Is there a way to get the duration and bitrate from a raw H264 file? I read somewhere that it might be possible if I decode the file first, but I'm not sure how this can be done.
Edit #1
I'm the one creating the H264 file with a Python library called picamera
.
Edit #2
Console output when running avconv -i test.h264 -f null -
avconv version 11.7-6:11.7-1~deb8u1+rpi1, Copyright (c) 2000-2016 the Libav developers
built on Jun 17 2016 02:13:49 with gcc 4.9.2 (Raspbian 4.9.2-10)
[h264 @ 0x1bcc200] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'test.h264':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 720x480, 25 fps, 25 tbn
Output #0, null, to 'pipe:':
Metadata:
encoder : Lavf56.1.0
Stream #0.0: Video: rawvideo, yuv420p, 720x480, q=2-31, 200 kb/s, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.1.0 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press ctrl-c to stop encoding
frame= 208 fps= 68 q=0.0 Lsize= 0kB time=10000000000.00 bitrate= 0.0kbits/s
video:13kB audio:0kB other streams:0kB global headers:0kB muxing overhead: unknown
You could mux it to a container and then check
ffmpeg -i test.h264 -c copy test.mp4
ffprobe test.mp4
You can also count frames in the H264 and divide by frame rate
ffprobe test.h264 -count_frames -show_entries stream=nb_read_frames,avg_frame_rate,r_frame_rate
Duration = nb_read_frames / avg_frame_rate
The reason duration is N/A is that annexb (raw) H.264 files usually have no timestamp or framerate information stored in the file. Framerate can optionally be stored in the VUI of the PPS, but this file apparently doesn't have that, so all it knows is framecount (by parsing the whole file), but not anything timestamp-related.
One method is to decode the file with ffmpeg
to get the duration:
ffmpeg -framerate 24 -i input.h264 -f null -
Then refer to time=
in the second-to-last line in the console output for the duration. For example, a 5 second input:
frame= 125 fps=0.0 q=-0.0 Lsize=N/A time=00:00:05.00 bitrate=N/A speed= 189x
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.