ffmpeg monochrome rawvideo - encoding

I am trying to generate a raw video stream with luma only (monochrome, YUV400) 8bit pixel data using the following command:
ffmpeg -i input.mp4 -vcodec rawvideo -pix_fmt raw.yuv
After that I want to h.264 encode the raw stream with the profiles that support monochrome pixel data (eg: high)
ffmpeg -f rawvideo -vcodec rawvideo -pix_fmt gray -s 640x512 -r 60 -i raw.yuv -codec:v libx264 -profile:v high -c:a copy out.mp4
However, i always get the following error, which indicates that the raw stream is not in the monochrome format that I expected:
x264 [error]: high profile doesn't support 4:4:4
I am new to ffmpeg and video formats in general. Can somebody please point out what I am missing?
Thank you!
Edit:
I also tried to use the following filter to extract only the luma channel. Unfortunately, the end result was the same.
ffmpeg -i input.mp4 -vcodec rawvideo -pix_fmt gray -filter_complex 'extractplanes=y[y]' -map '[y]' raw.yuv

The ffmpeg version installed was quite old (3.4.7). After installing 4.2.3 everything worked fine.

Related

Text streaming with RTMP?

I'm trying to get the output of a bash file to an RTMP stream.
I've successfully done it with FFMPEG using a filter, but the stream stops at Random intervals.
I assume that it's FFMPEG reading NULL data from the file.
I already write another file "output.txt", delete " input.txt" (which FFMPEG is reading) and rename "output.txt" to "input.txt".
Is there any way to do it more atomic in bash so it will work? Or is there a more elegant way to turn a changing text (max one time per second) to an FFMPEG stream?
Here is my current script:
ffmpeg -s 1920x1080 -f rawvideo -pix_fmt rgb24 -r 10 -i /dev/zero -f lavfi -i anullsrc -vcodec h264 -pix_fmt yuv420p -r 10 -b:v 2500k -qscale:v 3 -b:a 712000 -bufsize 512k -vf "drawtext=fontcolor=0xFFFFFF:fontsize=15:fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf:textfile=input.txt:x=0:y=0:reload=1" -f flv "rtmp://example.com/key"

FFmpeg VP9 - Different Quantisation Parameters but same output files

I want to encode a video with vp9 with different quantisation parameters (qp=[16,20,24,28,32]). Unfortunately the output files have the same data rate after encoding and don't show any quality differences.
This is my code for qp=20:
ffmpeg -s:v 3840x1920 -framerate 30 -i video_3840x1920_30fps_8bit_420_erp.yuv -c:v libvpx-vp9 -qp 20 -f avi out.avi
Many thanks for any pointers you can give me.
-qp only works for internal mpegvideoenc-derived encoders, such as FFmpeg's built-in MPEG-1/2/4 encoders. Libvpx, like x264/5, uses -crf to do this instead. See the Wiki for more details. You can also type ffmpeg -h encoder=libvpx-vp9:
$ ffmpeg -h encoder=libvpx-vp9
[..]
-crf <int> E..V.... Select the quality for constant quality mode (from -1 to 63) (default -1)
So for qp=20, you would use ffmpeg -s:v 3840x1920 -framerate 30 -i video_3840x1920_30fps_8bit_420_erp.yuv -c:v libvpx-vp9 -crf 20 -b:v 0 out.avi.

Encoding 25mp video

I have a 25MP uncompressed video file of 100 frames.
I tried to encode it with ffmpeg and h264 encoder into a .mp4 file, but the encoding got stuck around the 10th frame.
This is the script:
avconv -y -i input.avi -c:v libx264 -preset medium -b:v 5000K -pass 1 -c:a libfdk_aac -b:a 5000K -f mp4 /dev/null && \
avconv -i input.avi -c:v libx264 -preset medium -b:v 5000K -pass 2 -c:a libfdk_aac -b:a 5000K output.mp4
I am running it on a jetson TK1 with nvidia gpu, is there any way to use an accelarating encoding in order to make the encoding possible?
Please, if you can, give me a sampler script of something that might work.
Right now, I dont care how much time the encoding take, as long as it will work.
Thank you in advance! :)

ffmpeg apply filters without rencoding?

I want to rotate a video using ffmpeg, but I don't want to lose quality by re-encoding.
If I try
ffmpeg -i in.mp4 -vf 'vflip,hflip' -ss 120 -t 200 -c:v copy -c:a copy out.mp4
No rotation gets preformed. If I instead specify the encoding by using, say -c:v h264, I'm afraid I'll lose some quality. Is there a "losssless" (relative to the original encoding) way of applying a filter?
Use a lossless encoder
Use of filters requires re-encoding. You can use a lossless encoder if quality is the most important factor:
ffmpeg -i in.mp4 -vf 'vflip,hflip' -ss 120 -t 200 -c:v libx264 -preset veryslow \
-crf 0 -c:a copy out.mp4
Using -crf 0 when using libx264 will create a lossless output but the file size may be very large.
Rotate upon playback
Rotating during playback will of course preserve the quality:
ffplay input.mp4 -vf hflip,vflip
Also see
FFmpeg and x264 Encoding Guide
How to flip a video 180° (vertical/upside down) with FFmpeg?

ffmpeg rtmp webcam live stream iphone/pad segment size too big

I'm transcoding a rtmp stream from a red5 server for use to live stream on a iphone or ipad device. I built latest ffmpeg version from git repo using the built in segmenter to create .ts files and m3u8 playlist file using the following:
ffmpeg -probesize 50k -i "rtmp://localhost/oflaDemo/red5StreamDemo live=1" \
-c:v libx264 -b:v 128k -vpre ipod320 -flags -global_header -map 0 \
-f segment -segment_time 3 -segment_list foo.m3u8 -segment_list_flags +live \
-segment_list_type m3u8 -segment_list_size 5 -segment_format mpegts foo%d.ts
This works fine, but I can't get the segment size smaller than about 12 sec even set to 3 (-segment_time 3). It seems to be caused by libx264 vcodec.
Am I missing any flag?
By the way, you can simple run the ffmpeg command above successfully by starting red5 SimpleBroadcaster example.
i suspect it is because of GOP size. segmenter needs I-frame boundary to be able to create segments.
ffmpeg -probesize 50k -i "rtmp://localhost/oflaDemo/red5StreamDemo live=1" \
-c:v libx264 -b:v 128k -g 90 -vpre ipod320 -flags -global_header -map 0 \
-f segment -segment_time 3 -segment_list foo.m3u8 -segment_list_flags +live \
-segment_list_type m3u8 -segment_list_size 5 -segment_format mpegts foo%d.ts
added -g 90. could help.