Ffmpeg didn't burn srt subtitle on mkv properly - ffmpeg

`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

Related

Extract frames from video with ffmpeg - header problem?

I want to convert .AVI files coming from a camera-trap to individuals frames, ideally using ffmpeg. Up to now I am not succeeding.
The most simple thing I tried, to try to locate the problem, is this (I want all frames and my test file is test.avi):
ffmpeg -i test.avi output_%04d.png
It fails with the following console message:
[avi # 0x559fb596f8c0] unknown stream type 73647578
[avi # 0x559fb596f8c0] Something went wrong during header parsing, tag [0][0]id has size 338702712, I will ignore it and try to continue anyway.
[mjpeg # 0x559fb59709e0] No JPEG data found in image
Last message repeated 100 times
[avi # 0x559fb596f8c0] decoding for stream 0 failed
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 0 (Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[avi # 0x559fb596f8c0] Could not find codec parameters for stream 1 (Video: none (JUNK / 0x4B4E554A), none, 11025x22050): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, avi, from 'test.avi':
Duration: 00:00:10.50, start: 0.000000, bitrate: 28129 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
Decoder (codec none) not found for input stream #0:1
The actual video duration is 10s (when read using vlc for instance, and this is indeed the length of video programmed on the camera-trap. ffmpeg says the duration is 10.50s, and says there is a problem with header parsing (see above).
I have no idea how to sort this, despite having looked at more than many ffmpeg 'convert video to frames' post. Any hint would be appreciated, thanks.
If you look at the error message, you will see that the file has 2 video streams.
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
and ffmpeg is trying to read for the second one:
Stream mapping:
Stream #0:1 -> #0:0 (? (?) -> png (native))
You can use -map 0:0 to select the first stream.

ffmpeg codec conversion; can't configure encoder

I am simply trying to convert a vp9 webm I have into a vp8 webm. this is the command I'm using.
ffmpeg -i in.webm -c:v vp8 out.webm
the vp8 encoder returns a strange error
Input #0, matroska,webm, from 'in.webm':
Metadata:
encoder : google
Duration: 00:02:34.60, start: 0.000000, bitrate: 404 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/unknown/unknown), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> vp8 (vp8_v4l2m2m))
Press [q] to stop, [?] for help
[vp8_v4l2m2m # 0x56195db9f9f0] Could not find a valid device
[vp8_v4l2m2m # 0x56195db9f9f0] can't configure encoder
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
Conversion failed!
In case I get any questions about whether I have the right encoders and decoders installed here is the output of ffmpeg -codecs | grep "vp[8-9]":
DEV.L. vp8 On2 VP8 (decoders: vp8 vp8_v4l2m2m vp8_cuvid ) (encoders: vp8_v4l2m2m )
D.V.L. vp9 Google VP9 (decoders: vp9 vp9_v4l2m2m vp9_cuvid )
Your ffmpeg build has a Video4Linux wrapper available for a hardware VP8 encoder, but no actual hardware VP8 encoder available.
For software encoding of VP8/VP9, you'll need libvpx enabled and linked. You can get a static git binary from https://johnvansickle.com/ffmpeg/

webm to mp4 conversion using ffmpeg ubuntu

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

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"

Frame rate control of a ts file

I have a ts file, which is created by encoding raw yuv data using x264enc and muxing it with mpegtsmux.
And this file contains more than one stream. For example it may contain two video streams, or it may contain two video and one text stream like that.
It is of 25 fps, and 720X576 resolution. I would like to change it's fps to say 10, and all the three streams must present in the new ts file also.
Is there any pipeline for this in gstreamer? or any command in ffmpeg? How can i do this?
I don't think that this is possible in GStreamer. At least is not straightforward. However, it should be possible with ffmpeg as long as all the sequences in the file can be discovered correctly.
From the wiki of ffmpeg, map option (https://trac.ffmpeg.org/wiki/Map):
The "map" command basically means "include this stream into the
immediately following OUTPUT file."
Using map option it is possible to re-encode the video stream that you want and keep untouched the others.
Using input.ts file as an example with 2 different video streams and some audio streams, the way to follow should be the next:
ffmpeg -i input.ts -map 0:0 -map 0:2 -map 0:3 -map 0:4 -map 0:23 -map 0:10 -map 0:14 -c:v:0 mpeg2video -r:v:0 10 -c:v:1 copy -c:a copy outputmini.ts
Note that the video streams are 0:0 and 0:23. The first video stream (mpeg2) is re-encoded to 10 fps whereas the 0:23 video stream (x264) is just copied to the output. Remember that if there is some unknown stream in the .ts file you may need to add -ignore_unknown flag.
As specified in the link from ffmpeg, the output stream order is specified in the command execution in the map option placement order. With -c:v:0 mpeg2video option, we select the first output video stream and re-encoding codec, while the -r:v:0 10 option puts the first video stream frame rate to 10 fps. The other options from the command line copies the input stream to output with the same parameters.
ffmpeg outputs next:
Output #0, mpegts, to 'outputmini.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video (Main), yuv420p, 640x576 [SAR 6:5 DAR 4:3], q=2-31, 200 kb/s, 10 fps, 90k tbn, 10 tbc
Metadata:
encoder : Lavc57.50.100 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(spa): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 192 kb/s
Stream #0:2(qaa): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 192 kb/s
Stream #0:3(spa): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, 96 kb/s (visual impaired)
Stream #0:4: Video: h264 ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 90k tbn, 90k tbc
Stream #0:5(spa): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, 256 kb/s
Stream #0:6(spa): Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, mono, 64 kb/s (visual impaired)
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg2video (native))
Stream #0:2 -> #0:1 (copy)
Stream #0:3 -> #0:2 (copy)
Stream #0:4 -> #0:3 (copy)
Stream #0:23 -> #0:4 (copy)
Stream #0:10 -> #0:5 (copy)
Stream #0:14 -> #0:6 (copy)
The desired output is achieved.
However, even though I'm not sure this could be done, I would get a glimpse to tsMuxeR appllication (http://www.videohelp.com/software/tsMuxeR). It is a very powerful tool to this kind of tasks.

Resources