webm to mp4 conversion using ffmpeg ubuntu - ffmpeg

I have video and I want to convert that to mp4
It is working fine for the .flv and other formats. But when I'm trying to convert webm to mp4 the video is not getting converted
ffmpeg -i /input.webm /output.mp4
It is only converting to a 48kb file. The actual size of video is 850mb
I am getting this
Output #0, mp4, to '/output.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Killed 21 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
It is working locally but on live server it's not generating the output as expected

Related

FFmpeg changes framerate to Variable when remuxing

I'm trying to change .MKV container to .MP4 using FFmpeg without re-encoding video stream:
ffmpeg -i input.mkv -c copy output.mp4
The input file has Constant framerate:
Frame rate mode: Constant
Frame rate : 30.000 fps
However, the output file got a variable framerate according to Mediainfo:
Frame rate mode : Variable
Frame rate : 30.000 fps
Minimum frame rate : 29.412 fps
Maximum frame rate : 30.303 fps
Total number of frames stays the same.
The output from ffmpeg:
Output #0, mp4, to 'input.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 2560x1440 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 16k tbn, 1k tbc (default)
Metadata:
DURATION : 00:05:00.766000000
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 9023 fps=0.0 q=-1.0 Lsize= 209201kB time=00:05:00.66 bitrate=5699.9kbits/s
video:209045kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.074948%
Is it possible to set constant bitrate for the output? I've tried -vsync and -r but they seem to be ignored when -c copy is set.

FFMPEG: how to wrap h264 stream into FLV container?

What I want is straightforward: wrap H.264 video stream into a FLV container. However, ffmpeg just decode the input stream and pack raw video stream into FLV. The details are described below:
The input stream is captured from a hardware-encoder video camera, and the FLV will be sent to some video server. Firstly I used following command:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -f flv "rtmp://some.website.com/receive/path"
However, the resultant stream is suspicious. The watching side don't get any H.264 thing. Then I made a test by writing output to local files.
1: Read raw stream, encode by h264_omx, write to FLV file:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video0 -codec h264_omx -f flv raw_input_h264_omx.flv
......
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 194017.870905, bitrate: 18432 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 18432 kb/s, 15 fps, 15 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_omx))
......
2: Read H264 stream, write to FLV file:
$ ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -f flv h264_input.flv
......
Input #0, video4linux2,v4l2, from '/dev/video1':
Duration: N/A, start: 194610.307096, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 320x240, 15 fps, 15 tbr, 1000k tbn, 2000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
......
Then read the two files correspondingly:
$ ffmpeg -i raw_input_h264_omx.flv
......
Stream #0:0: Video: h264 (High), yuv420p(progressive), 320x240, 200 kb/s, 15 fps, 15 tbr, 1k tbn
$ ffmpeg -i h264_input.flv
......
Stream #0:0: Video: flv1, yuv420p, 320x240, 200 kb/s, 15 fps, 15 tbr, 1k tbn
It is clear when I give a H.264 stream, ffmpeg firstly decodes it, then pack the raw video into FLV. How to avoid that happen, and have the H.264 stream packed directly?
Supplement: I will eventually pushing multiple video streams, so don't ask me to allow ffmpeg's silent decoding, and encode the stream again.
Unless told otherwise, ffmpeg will transcode streams.
Use
ffmpeg -framerate 15 -s 320x240 -i /dev/video1 -c copy -f flv "rtmp://website/receive/path"

How to generate an RTMP test stream using ffmpeg command?

I would like to test my streaming infrastructure by generating an RTMP test video with a timestamp. This could look like that screen. The image doesn't matter. I'm after the working stream generated on-the-fly and timestamp only. I intend to use the ffmpeg tool for that purpose. The command could look something like
$ ffmpeg -i image.png \
-vf drawtext="fontfile=/Library/Fonts/Arial.ttf: \
timecode='00\:00\:00\:00': r=1: fontcolor=white: \
fontsize=24: box=1: boxcolor=black#0.5: \
boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" \
-f flv rtmp://localhost/live/test
I do run locally a streaming server based on NGINX and its RTMP module.
However, the above command gives me the following error:
Input #0, png_pipe, from 'image.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgb24(pc), 768x576 [SAR 7874:7874 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> flv1 (flv))
Press [q] to stop, [?] for help
[Parsed_drawtext_0 # 0x7fb78450ece0] Using non-standard frame rate 1/1
Output #0, flv, to 'rtmp://localhost/live/test':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 768x576 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.89.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[flv # 0x7fb785812a00] Failed to update header with correct duration.
[flv # 0x7fb785812a00] Failed to update header with correct filesize.
frame= 1 fps=0.0 q=8.6 Lsize= 50kB time=00:00:00.00 bitrate=406016.0kbits/s speed=0.019x
video:49kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.451271%
The streaming server operates as expected. The problem is with the command. Would anyone be able to help me?
ffmpeg has testsrc you can use as a test source input stream:
ffmpeg -r 30 -f lavfi -i testsrc -vf scale=1280:960 -vcodec libx264 -profile:v baseline -pix_fmt yuv420p -f flv rtmp://localhost/live/test
-r, scaling, profile, etc are just an example and can be ommited/played with. The point is using -i testsrc

Ffmpeg didn't burn srt subtitle on mkv properly

`ffmpeg version:git-fc6de70 (2013-07-18) with libass and fontconfig support.
command line:ffmpeg.exe -i test.mkv -vf subtitles=test.srt out.mkv
and i got this error.:
Metadata:
encoder : Lavf55.12.102
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x5
76 [SAR 1:1 DAR 20:9], q=-1--1, 1k tbn, 23.98 tbc (default)
Stream #0:1: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo
, fltp (default)
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libvorbis)
Press [q] to stop, [?] for help
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. A
ssuming 384x288
http://tinypic.com/r/2ag52so/5
The message you get:
[Parsed_subtitles_0 # 00000000027b9960] Neither PlayResX nor PlayResY defined. Assuming 384x288
means that your ssa or srt file doesn't specify the PlayResX and Y values. So the VFilter assume a display resolution of 384x288, thats why your subtitles looks so small on a 1280x576 video.
A workaround for your issue is:
convert SRT to SSA/ASS
ffmpeg -i file.srt file.ass
edit your SSA/ASS file to set the correct value. For SSA the format is describe here and it's easy to set PlayRes X and Y.
[Script Info]
; This is a Sub Station Alpha v4 script.
....
ScriptType: v4.00
Collisions: Normal
PlayResX: 1280
PlayResY: 576
PlayDepth: 0
....
And finally, launch your command again using the ass file.
Burning subntitles with FFmpeg is tricky due to canvas size with pictured-based subtitles and charset encoding with text files (srt or ssa).
I guess I managed to handle it for almost all cases in DVDx 4.1 Free Encoder version (Beta 1.0):
http://www.labdv.com/dvdx/4.1/docs/burn-subtitles-in-video.php

Increase the bitrate tolerance of ffmpeg for creating screenshots of a movie

I'm getting the error bitrate tolerance too small for bitrate so far no problem. I know that there are several switches to increase that but nothing works.
ffmpeg -y -r 1/30 -b:v 999999k -bt 999999k -maxrate 999999k -i in.flv out%03d.jpg
The source of that commandline is directly from ffmpeg. But that crashes:
ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 2 2012 20:23:29 with gcc 4.7.1 (GCC)
[...]
Input #0, flv, from 'in.flv':
Duration: 00:05:00.13, start: 0.000000, bitrate: 259 kb/s
Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 22050 Hz, mono, s16
[mjpeg # 04356860] bitrate tolerance too small for bitrate
[mjpeg # 04317540] ff_frame_thread_encoder_init failed
Output #0, image2, to 'out%03d.jpg':
Stream #0:0: Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 0.03 tbc
Stream mapping:
Stream #0:0 -> #0:0 (flv -> mjpeg)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Some ideas what I'm doing wrong?

Resources