Encoding 25mp video - encoding

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! :)

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 - Down-mix AC3 5.1 to Fraunhofer FDK ACC 2.1

I'm trying to re-encode some of my old videos to "archive" them.
I do not need to keep the audio 5.1, but I would like to down-mix it to 2.1 instead of Stereo which sounds just too dull.
This is the relevant part which takes care of the down-mix to Stereo and re-encodes the audio, I would like to adjust it to down-mix to 2.1.
-ac 2 -c:a libfdk_aac -vbr 3
I did some research and it seems that there is a -layouts switch which does support 2.1, but I don't know, how to use it. What channel should go where?
Just for illustration and for you to get the whole picture - I'm currently using this script:
#!/bin/bash
for i in *.mkv;
do
#Output new files by prepending "x265" to the names
/cygdrive/c/media-autobuild_suite/local32/bin-video/ffmpeg.exe -y -i "$i" -c:v libx265 -preset slow -b:v 512k -x265-params pass=1 -c:s copy -c:a copy -f matroska NUL && \
/cygdrive/c/media-autobuild_suite/local32/bin-video/ffmpeg.exe -i "$i" -c:v libx265 -preset slow -b:v 512k -x265-params pass=2 -c:s copy -ac 2 -c:a libfdk_aac -vbr 3 x265_"$i"
done
The FDK aac encoder does not support 2.1, but the native encoder does.
ffmpeg -i "$i" ... -c:s copy -af pan=2.1 -c:a aac x265_"$i"

FFmpeg - The two pass in VP9 generates a empty output file for the first pass

When I try to encode a video file with a two pass in ffmpeg, the output file of the first pass is empty using vp9. Hence I can not proceed with the second part.
Code for the two-pass:
1.pass:
ffmpeg -y -s:v 3840x1920 -framerate 30 -i video_framerate_resolution.yuv -c:v libvpx-vp9 -crf 20
-pass 1 -an -f avi NULL && \
2.pass
ffmpeg -s:v 3840x1920 -framerate 30 -i video_framerate_resolution.yuv -c:v libvpx-vp9
-pass 2 -b:v 1000K -f avi out.avi
Any help would be greatly appreciated. Thanks.
You don't need to generate a file for the first pass. The purpose is simply to send the frames to the encoder so that it can log stats. However, you should skip the muxer.
So, Pass 1
ffmpeg -s:v 3840x1920 -framerate 30 -i video_framerate_resolution.yuv -c:v libvpx-vp9 -b:v 1000k -pass 1 -an -f null -
Pass 2
ffmpeg -s:v 3840x1920 -framerate 30 -i video_framerate_resolution.yuv -c:v libvpx-vp9 -pass 2 -b:v 1000K out.avi

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.