flv to mp4 using ffmpeg cli on debian - ffmpeg

I'm trying to convert this flv file into .mp4 using ffmpeg on debian.
Stream 0 Type: Video Codec: Flash Video (FLV1) Resolution: 640x480
Frame rate: 1000 Decoded format: Planar 4:2:0 YUV
Stream 1 Type: Audio Codec: NellyMoser ASAO (NELL) Channels: Mono
Sample rate: 22050 Hz Bits per sample: 32
I'm currently using this simple command...
sudo avconv -i videoStream_1424268207948_854.flv videoStream_1424268207948_854.mp4
These are the warnings I receive:
[flv # 0x14fab20] Estimating duration from bitrate, this may be inaccurate
[libx264 # 0x14fdaa0] MB rate (1200000) > level limit (983040)
Multiple frames in a packet from stream 0
[flv # 0x14fca60] Bad picture start code
[flv # 0x14fca60] header damaged
Error while decoding stream #0:0
... and it results in messed up video and audio.
Can anyone help with some parameters?

It worked for me using ffmpeg version 2.5.4. Try upgrading avconv, or switching to ffmpeg.

Related

When I use the hevc_videotoolbox encoder in ffmpeg it always prompts me the same error

when i use
ffmpeg -i BabyShark.mp4 -c:v hevc_videotoolbox -b:v 6000k BabyShark1.mp4
it always returns an error like
[hevc_videotoolbox # 0x7fec79206e00] Error encoding frame: -12905
[hevc_videotoolbox # 0x7fec79206e00] popping: -542398533 Error
initializing output stream 0:0 -- Error while opening encoder for
output stream #0:0 - maybe incorrect parameters such as bit_rate,
rate, width or height [aac # 0x7fec79208a80] Qavg: 13693.864 [aac #
0x7fec79208a80] 2 frames left in the queue on closing Conversion
failed!
but
ffmpeg -i BabyShark1.mp4 -c:v h264_videotoolbox -b:v 6000k BabyShark2.mp4
works fine.
Other tutorials say that the above error is a problem of out-of-sync audio and video
But I changed a lot of videos, the error still appears, even the videos I recorded myself.
How can i fix it.
My computer model is MacBook Pro 2019
I want to use GPU to convert video to H265 encoding
Same problem with a computer using another M1 chip With GPU

How to convert MP4 frame rate like 14.939948fps to 15fps

Description
I pushed a USB camera stream by ffmpeg to a RTMP stream server which is called SRS.
The SRS had saved a MP4 file for me. The frame rate is not a common value in VLC - it's 14.939948. I've checked it out - It seems to be the 'ntsc' format.
Meanwhile, I had received the stream by OpenCV and saved it as another MP4 file.They're not synchronized.
I have tried to convert the frame rate by ffmpeg but was still not synchronized. The only way to make it is to put it in Adobe Premiere and modify the frame rate. Here is the ffmpeg commands I executed:
ffmpeg -i 1639444871684_copy.mp4 -filter:v fps=15 out.mp4
Aside from the stream server, how can I convert the frame rate to normal and keep synchronized at the same time?
Note: For live streaming, you should never depends on the FPS, because RTMP/FLV always use fixed TBN 1k, so there is always introduce some deviation, when publish stream as RTMP or record to other format like TS/MP4.
Note: For WebRTC, the fps is variant, please read Would WebRTC use a constant frame rate to capture video frame or about the Variable Frame Rate (VFR)
It's not a problem of SRS or FPS, you can also replay it by FFmpeg.
Use FFmpeg to transcode doc/source.flv from 25fps to 15fps, then publish to SRS by RTMP(15fps).
Use FFmpeg to record the RTMP(15fps) as output.mp4(15fps).
Use VLC to play the output.mp4(15fps), it show the fps IS NOT 15fps.
First, please start SRS by bellow config, note that DVR disabled:
# ./objs/srs -c test.conf
listen 1935;
daemon off;
srs_log_tank console;
vhost __defaultVhost__ {
}
Run FFmpeg to transcode and publish to SRS, change the fps to 15:
cd srs/trunk
ffmpeg -re -i doc/source.flv -c:v libx264 -r 15 -c:a copy \
-f flv rtmp://localhost/live/livestream
Record the RTMP stream(in 15fps) to output.mp4, note tat the fps is, in FFmpeg logs, it's 15fps:
ffmpeg -f flv -i rtmp://localhost/live/livestream -c copy -y output.mp4
Use VLC to play the output.mp4 which is 15fps, open the Window -> Media Information, you will find out that the fps is changing around 14.8fps, not 15fps!
It's because the TBN of RTMP/FLV, is fixed 1000(1k tbn, each frame is about 66.66666666666667ms), so the deviation is introduced when publish MP4 to RTMP stream. It's not caused by DVR, it's caused by RTMP/FLV TBN.
Note: However, for SRS, using fixed TBN 1k is not a good choice, because it's not friendly for MP4 duration, I reopen the issue srs#2790.
Ultimately, the framerate/fps is not a fixed stuff, it's just a number that give some tips about the stream. Instead, the player always use the DTS/PTS to decide when and how to render the picture.
Answer myself. Here is my method: Read by OpenCV and write frames to a new file at 15FPS. They're going to be synchronized.
with -r
ffmpeg -i 1639444871684_copy.mp4 -r 15 out.mp4

FFmpeg, how to skip late input?

I'm running ffmpeg to display incoming stream on a Decklink BlackMagic card with the following command line:
ffmpeg -y -f ourFmt -probesize 32 -i - -f decklink -preset ultrafast
-pix_fmt uyvy422 -s 1920x1080 -r 30 -af volume=0.1 -max_delay 10000
DeckLink Mini Monitor
Basically I get the video over the internet by UDP and stream it to ffmpeg stdin. Both audio and video streams have pts and dts and are fully in sync, if the connection is good there is no problems.
However if there are issues with the connection i start getting errors, sometimes the video delay grows significantly, and audio stops working.
The errors i get are:
ffmpeg: [decklink # 0x26cc600] There are not enough buffered video
frames. Video may misbehave! ffmpeg: [decklink # 0x26cc600] There's no
buffered audio. Audio will misbehave! ffmpeg: Last message
repeated 4 times ffmpeg: [decklink # 0x26cc600] There are not enough
buffered video frames. Video may misbehave! ffmpeg: [decklink #
0x26cc600] There's no buffered audio. Audio will misbehave! ffmpeg:
Last message repeated 3 times ffmpeg: frame= 5204 fps= 30 q=-0.0
size=N/A time=00:02:53.76 bitrate=N/A dup=385 drop=5 speed=0.993x
ffmpeg: [decklink # 0x26cc600] There's no buffered audio. Audio will
misbehave! ffmpeg: Last message repeated 18 times ffmpeg:
[decklink # 0x26cc600] There are not enough buffered video frames.
Video may misbehave! ffmpeg: [decklink # 0x26cc600] There's no
buffered audio. Audio will misbehave!
The problem is when the connection is back to normal, the video keeps misbehaving until I restart the stream. What I want to do is for FFmpeg to skip to the content of the last second and play synchronized video from there, drop all the late data in between, is it possible?

How can I generate encoded HEVC bitstream using ffmpeg?

I am able to encoded YUV file to mp4 using HEVC:
ffmpeg.exe -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i input.yuv -c:v hevc -r 30 -x265-params crf=27 -vframes 300 -an -y test.mp4
Here is the mp4box -info test.mp4 shows:
* Movie Info *
Timescale 1000 - Duration 00:00:10.000
1 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom - version 512
Created: UNKNOWN DATE Modified: UNKNOWN DATE File has no MPEG4 IOD/OD
iTunes Info:
Encoder Software: Lavf56.11.100
Track # 1 Info - TrackID 1 - TimeScale 15360 - Media Duration 00:00:10.000 Track has 1 edit lists: track duration is 00:00:10.000 Media Info: Language "Undetermined" - Type "vide:hev1" - 300 samples Visual Track layout: x=0 y=0 width=1920 height=1080 MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x23 HEVC Video - Visual Size 1920 x 1080
HEVC Info: Profile Main # Level 5 - Chroma Format 1
NAL Unit length bits: 32 - general profile compatibility 0x60000000
Parameter Sets: 1 VPS 1 SPS 1 PPS
SPS resolution 1920x1080
Bit Depth luma 8 - Chroma 8 - 1 temporal layers
But how can I get the decodeble bit stream? I tried
mp4box -raw 1 test.mp4 -out out.bin
It gives:
Extracting MPEG-H HEVC stream to hevc
But the out.bin couldn't be decoded by HM or elecard.
Thanks
Use
ffmpeg -i input.mp4 -c:v hevc -f hevc out.bin
to generate an Annex B bytestream. This can be fed to another decoder.

ffmpeg error mb_type 7802 in P slice too large at 50 35kbps

When I decode a h264 rtmp stream with ffmpeg I am getting the following error in the console:
[h264 # 02c3af20] mb_type 7802 in P slice too large at 50 35kbps
[h264 # 02c3af20] error while decoding MB 50 35
ffmpeg can't play my h264 rtmp stream but if I en-decode vp6 rtmp stream there is no problem. Why is this?
Because your H.264 stream is broken (out of spec) or you incorrectly decoding stream. It was broken either during encoding or during network transfer.

Resources