Re: [FFmpeg-user] Scale down if resolution is greater than given?
sorry not that one, this one ffmpeg -i video.mov -filter_complex scale=iw*min(1\,min(640/iw\,360/ih)):-1 -vb 600k -ac 2 -ab 96k -ar 44100 -f mp4 out.mp4 On Wed, Jul 29, 2015 at 5:33 PM, Moritz Barsnick barsn...@gmx.net wrote: On Wed, Jul 29, 2015 at 17:27:47 +0200, vedran wrote: Anyway, thank you all guys. I did it like this, although i don't understand well what this does ffmpeg -i myvideo001.3gp -vf scale=1024:-1 -vb 600k -ac 2 -ab 96k -ar 44100 -f mp4 myvideo001out.mp4 Oh my, what's there not to understand? ;-) It scales your input video to a width of 1024 (regardless of whether the input is narrower or wider), while maintaining the aspect ratio. Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Scale down if resolution is greater than given?
Anyway, thank you all guys. I did it like this, although i don't understand well what this does ffmpeg -i myvideo001.3gp -vf scale=1024:-1 -vb 600k -ac 2 -ab 96k -ar 44100 -f mp4 myvideo001out.mp4 On Wed, Jul 29, 2015 at 3:46 PM, Moritz Barsnick barsn...@gmx.net wrote: Hi Mahesh, On Wed, Jul 29, 2015 at 18:08:56 +0530, Mahesh Patade wrote: Check this. I have written this logic in my script. Wow. If you're going to use scripting, why not use it to make life (and readability) easier instead of harder. For instance, just for my(!) readability, I would change this: transcode() { # 128 Bitrate MULBIT128=$(echo ${1}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT128} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $1 -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi fi To this: transcode() { # 128 Bitrate MULBIT128=$(echo ${1}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT128} ]; then SCALE=-s $1 else SCALE= fi if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} $SCALE -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi This makes the difference between the if and the else clause much clearer! MULBIT128, MULBIT256, MULBIT512 could also be differentiated by simple variables/function arguments, and one very common ffmpeg command line. That also makes modifying other arguments to ffmpeg much easier. You don't have to do it X times. That's the whole point of scripting! SCNR. eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width ${FILENAME}) SIZE=${streams_stream_0_width}x${streams_stream_0_height} REOLVIDEO=$(echo ${SIZE} |sed 's#x#*#g' | bc) RESOLUTION=$(echo scale=1; $streams_stream_0_width/$streams_stream_0_height | bc) So REOLVIDEO is the number of pixels, RESOLUTION is what we usually call the aspect ratio? I wouldn't use that to choose the target sizes, but just maintain the aspect ratio. But that's your call. I would use this filter now (we can ignore Mahesh's multi-bitrates for this question): $ ffmpeg [...] -vf scale=w=if(gt(iw*ih\,1280*720)\,iw*min(1280/iw\,1024/ih)\,iw):h=-2 [...] This scales any video with more pixels than 1280*720 inside of a box of 1280*720. An improvement would be to scale it to the correct number of pixels. More math. ;-) Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Scale down if resolution is greater than given?
On Wed, Jul 29, 2015 at 17:27:47 +0200, vedran wrote: Anyway, thank you all guys. I did it like this, although i don't understand well what this does ffmpeg -i myvideo001.3gp -vf scale=1024:-1 -vb 600k -ac 2 -ab 96k -ar 44100 -f mp4 myvideo001out.mp4 Oh my, what's there not to understand? ;-) It scales your input video to a width of 1024 (regardless of whether the input is narrower or wider), while maintaining the aspect ratio. Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Convert .256 to avi with audio
On Wed, Jul 29, 2015 at 3:09 PM, André Luís Duarte andrelduarte-at-yahoo.com...@ffmpeg.org wrote: Hi guys. Need to do a skill in a video that was recorded in a security camera and the video file has the extension .264. The video file can be viewed in the program provided by company (H264Player). The video is displayed with sound normally for this player. I need to check the sound level contained in the video files, for that would use some software that exhibits me this information. I tried to convert the file to avi using the following command in ubuntu 14:04: ffmpeg sudo -i -f H264 Video1.264 -vcodec copy -acodec copy --the filename.avi. Probably shouldn't run ffmpeg as root, as your resulting video will be owned by root and can easily cause all kinds of permission issues. ... Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 352x240, 25 fps, 25 tbr, 1200k tbn, 50 tbc Output #0, avi, to 'Video1.avi': Metadata: ISFT: Lavf56.40.101 Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 352x240, q=2-31, 25 fps, 25 tbr, 50 tbn, 50 tbc Stream mapping: Stream #0:0 - #0:0 (copy) Press [q] to stop, [?] for help We see that the audio stream isn't recognized as going into the final AVI file here. ... Last message repeated 1 times frame=107918 fps=15109 q=-1.0 Lsize= 372978kB time=01:11:56.94 bitrate= 707.8kbits/s video:367913kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.376595% The conversion was successful, but the audio is not inserted in the output file filename.avi. I tried to visualize using VLC, the VLC displays the video (Vídeo1.264) correctly, but without audio as well. What I'm guessing is that the -f H264 is telling ffmpeg that you want to export a .264 container format - which only contains video information - and that is why you aren't getting audio. ffmpeg will natively look at the output file (a .AVI here) and will adjust automatically, or you can specify -f AVI instead. I'd honestly, just remove the -f option entirely. Steve ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Convert .256 to avi with audio
(André, your subject is wrong. ;-)) On Wed, Jul 29, 2015 at 15:33:31 -0500, Steve Boyer wrote: On Wed, Jul 29, 2015 at 3:09 PM, André Luís Duarte andrelduarte-at-yahoo.com...@ffmpeg.org wrote: Probably shouldn't run ffmpeg as root, as your resulting video will be owned by root and can easily cause all kinds of permission issues. There should _never_ be a need for this. If ffmpeg can't access a device or file, fix that file's permissions. What I'm guessing is that the -f H264 is telling ffmpeg that you want to export a .264 container format - which only contains video No, it was given as an option _before_ -i, so it's telling ffmpeg to _import_ the given file as a raw H.264 stream. And that doesn't work too well, because it can't be such a raw video if it contains audio. As Steve suggested, just let ffmpeg detect the input itself. To analyze the overall audio volume: $ ffmpeg -i inputfile -vn -af volumedetect -f null - (ffmpeg can also create graphs of the audio levels or waveforms over time. Otherwise, you may want something like audacity.) Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
[FFmpeg-user] Convert .256 to avi with audio
Hi guys. Need to do a skill in a video that was recorded in a security camera and the video file has the extension .264. The video file can be viewed in the program provided by company (H264Player). The video is displayed with sound normally for this player. I need to check the sound level contained in the video files, for that would use some software that exhibits me this information. I tried to convert the file to avi using the following command in ubuntu 14:04: ffmpeg sudo -i -f H264 Video1.264 -vcodec copy -acodec copy --the filename.avi. the output was as follows: linux@linux-Capella-IbexPeak-M-Chipset:~/Vídeos$ sudo ffmpeg -f h264 -i Video1.264 -vcodec copy Video1.avi ffmpeg version N-73895-g323ec6b Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04) configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab libavutil 54. 28.100 / 54. 28.100 libavcodec 56. 50.101 / 56. 50.101 libavformat56. 40.101 / 56. 40.101 libavdevice56. 4.100 / 56. 4.100 libavfilter 5. 25.100 / 5. 25.100 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc53. 3.100 / 53. 3.100 [h264 @ 0x3242c80] pps_id 4294967295 out of range [h264 @ 0x3242c80] slice type 32 too large at 131319 [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! [h264 @ 0x3242c80] non-existing PPS 0 referenced Last message repeated 1 times [h264 @ 0x3242c80] decode_slice_header error [h264 @ 0x3242c80] no frame! Input #0, h264, from 'Video1.264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 352x240, 25 fps, 25 tbr, 1200k tbn, 50 tbc Output #0, avi, to 'Video1.avi': Metadata: ISFT: Lavf56.40.101 Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 352x240, q=2-31, 25 fps, 25 tbr, 50 tbn, 50 tbc Stream mapping: Stream #0:0 - #0:0 (copy) Press [q] to stop, [?] for help [NULL @ 0x3242c80] too many reference frames 32 [NULL @ 0x3242c80] non-existing PPS 41 referenced [NULL @ 0x3242c80] SEI type 185 size 944 truncated at 40 [NULL @ 0x3242c80] sps_id 2 out of range [NULL @ 0x3242c80] SEI type 64 size 968 truncated at 40 [NULL @ 0x3242c80] SEI type 126 size 968 truncated at 40 [NULL @ 0x3242c80] SEI type 32 size 984 truncated at 40 [NULL @ 0x3242c80] SEI type 95 size 984 truncated at 40 [NULL @ 0x3242c80] missing picture in access unit with size 11 [NULL @ 0x3242c80] too many reference frames 32 [NULL @ 0x3242c80] SEI type 241 size 984 truncated at 40 [NULL @ 0x3242c80] SEI type 133 size 312 truncated at 24.14 bitrate= 719.5kbits/s [NULL @ 0x3242c80] sps_id 2 out of range [NULL @ 0x3242c80] sps_id 5 out of range55kB time=00:09:54.22 bitrate= 730.1kbits/s Last message repeated 1 times [NULL @ 0x3242c80] sps_id 8 out of range [NULL @ 0x3242c80] sps_id 3 out of range
Re: [FFmpeg-user] Scale down if resolution is greater than given?
Hey, Check this. I have written this logic in my script. streams_stream_0_width= ; streams_stream_0_height= eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width ${FILENAME}) SIZE=${streams_stream_0_width}x${streams_stream_0_height} REOLVIDEO=$(echo ${SIZE} |sed 's#x#*#g' | bc) RESOLUTION=$(echo scale=1; $streams_stream_0_width/$streams_stream_0_height | bc) transcode() { # 128 Bitrate MULBIT128=$(echo ${1}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT128} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $1 -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi fi # 256 Bitrate MULBIT256=$(echo ${2}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT256} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $2 -movflags rtphint -b:v 256k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-256000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-256000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 256 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 256k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-256000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-256000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 256 Bitrate Conversion fi fi # 512 Bitrate MULBIT512=$(echo ${3}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT512} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $3 -movflags rtphint -b:v 512k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-512000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-512000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 512 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 512k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-512000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-512000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 512 Bitrate Conversion fi fi # 712 Bitrate MULBIT712=$(echo ${4}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT712} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $4 -movflags rtphint -b:v 712k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-712000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-712000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 712 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 712k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-712000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-712000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 712 Bitrate Conversion fi fi } if [ ${RESOLUTION} = '1.3' ]; then
Re: [FFmpeg-user] Scale down if resolution is greater than given?
Hi Vedran, On Wed, Jul 29, 2015 at 03:42:05 +0200, vedran wrote: I'm looking for simple bash script which scales down video only if it has greater resolution than given. You won't need a bash script necessarily. ffmpeg can handle expressions. The problem is also with vertical videos. So i need to check width and height. Do you need the math to express what to do, or do you need the ffmpeg command line? For instance, if you want ffmpeg to scale down anything wider than 1280, use a filter somewhat like this: $ ffmpeg [...] -vf scale=w=min(iw\,1280):h=-2 [...] (h=-2 maintains the aspect ratio, using only even numbers.) You can make that expression more complex, e.g. if you want to restrict both width and height, or you want their product not be larger than a certain number, by construction if-the-else (actually and/or) type expressions. What logic were you thinking of? (If the video is so-and-so, do this, else if ... do that, else do something else, else don't change resolution.) Can you express it in words? Cheers, Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Compile ffmpeg w libvpx libvorbis on Ubuntu 14.04.02 x64
On Tue, Jul 28, 2015 at 20:09:31 +0300, arcas...@gmail.com wrote: 4) after checking the output folder ~/android-ndk-r10e/sources/ffmpeg/android/arm/ realized that in the lib folder I couldn't find any so files, not to mention any libvpx or libvorbis related artefacts. Did you expect libvpx and libvorbis here as well? If so, it isn't an ffmpeg problem, but apparently, step 2) didn't go well: 2) downloaded, configured, make and make install for the following libs: libogg, libvorbis and libvpx (according to [1]). All the libs where downloaded in ~/android-ndk-r10e/sources/ffmpeg Did you give the correct prefix? Did you get libav* installed, but without libvpx support? 3) after that used build_android.sh (used the one form [2], with some adaptations to enable libvpx and libvorbis and disable other unusefull options). 4) after checking the output folder ~/android-ndk-r10e/sources/ffmpeg/android/arm/ realized that in the lib folder I couldn't find any so files, not to mention any libvpx or libvorbis related artefacts. Well, assuming you were in the correct directory (for $(pwd)) ;-), what output did you get from the build? Did it look like it was compiling files and linking libav libraries? If in doubt, check (or attach :-)) the complete output of configure first (config.log), then check the output from make and from make install. We can't guess at which of these stages something went wrong. A lot of guess-work here. :( Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] ffmpeg streaming on ARM
Hi All, I’ve compiled ffmpeg for ARM platform(Cortex A9 dual core 800Mhz) and able to stream H.264 video at 5fps. Did any one tested PAL or higher resolution @25fps on ARM platform? I would like to know the any optimization is available for H264 encoding for ARM platform? With Regards, Mithun From: Mithun Sent: Thursday, July 23, 2015 6:29 PM To: ffmpeg-user@ffmpeg.org Cc: mith...@iwavesystems.com Subject: ffmpeg streaming on ARM Hi, I’ve been trying to stream a video file from our custom board (Altera cyclone V SoC ) using the below command. ffmpeg -re -i test.mp4 -f mpegts -an udp://@192.168.2.11:1234 but video’s native video rate was 24fps but ffmpeg could encode only at 15fps and stream. Any setting/parameter need to set in the ffmpeg to achieving native frame rate? Attached the log file (ffmpeg_streaming.txt) for the testing. Regards, Mithun ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
[FFmpeg-user] Real-time streaming of rawdata images to Android with FFMPEG
*Hello :)* *CONDITIONS* I have an C++ server (Linux) and want to transmit rawdata images (RGB, 32bit) to an Android device in real-time. The server generates the rawdata images (with or without bitmap header) continuously every x miliseconds. Now, I want to put the rawdata images into a stream and transmit them without much delay to the Android client. I've chosen FFMPEG for this kind of job. The input for FFMPEG should be the rawdata images, which are generated just in time. The output should be an rtsp stream (h264 or is another format better?). On client side I will play the stream with the Android MediaPlayer. That works for a RTSP url like rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov http://rtsp//184.72.239.149/vod/mp4:BigBuckBunny_115k.mov -- *PREVIOUS APPROCH:* I've installed FFMPEG on my server (192.168.1.20). Depending on this question: https://ffmpeg.org/pipermail/ffmpeg-user/2013-April/014617.html ... here is my FFMEG command: ffmpeg -an -f rawvideo -vcodec rawvideo -pix_fmt rgb32 -r 10 -i -vcodec libx264 -r 30 -tune zerolatency -preset ultrafast -bsf:v h264_mp4toannexb http://192.168.1.20:8090/feed1.ffm *Explanation of the parameters:* - -an = ignore audio - -report = log file in current directory *INPUT:* - -f = rawvideo (video format) - -vcodec = rawvideo (video codec) - -pix_fmt = rgb32 - -r = 10 (frame rate) *OUTPUT:* - -vcodec = libx264 - -r = 30 (frame rate) - -bsf:v = h264_mp4toannexb -- *C++ Server Code Snippet:* /* --- Get image rawdata from source --- */.../* --- Create image header which fits to the image rawdata --- */... /* --- Store the picture local (not necessary?) --- */FILE *f; f = fopen(/home/philies/test.bmp,wb); //Write Bitmap Headers fwrite(imageFileHeader,1,sizeof(imageFileHeader),f); fwrite(imageInfoHeader,1, imageInfoHeader,f); //Write Bitmap Rawdata fwrite(lastImage.GetBitmapRawData(),1,imageSize,f); — ffmpeg ??? -- *ffserver.conf* After that I will set up a FFserver to create a RTSP stream like that. Is it also correct? Port 8090BindAddress 0.0.0.0RTSPPort 7654RTSPBindAddress 0.0.0.0MaxClients 10MaxBandwidth 1NoDaemon Feed feed1.ffmFile /tmp/feed1.ffmFileMaxSize 30M ACL allow 127.0.0.1 ACL allow 192.168.1.0 192.168.1.255 ACL allow 192.168.5.0 192.168.5.255 /Feed Stream mystream.sdpFeed feed1.ffmFormat rtpVideoCodec libx264VideoSize 640x480AVOptionVideo flags +global_headerNoAudio/Stream -- *PROBLEMS/QUESTIONS:* 1. How can I specify the rawvideo of the ffmpeg command respectively how can I specify my bitmap rawdata (with or without header?) as the input of the FFMPEG? 2. Is the FFMPEG command correct? 3. Is the ffserver.conf correct? If I fire the FFMPEG command in the terminal I get this error: vcodec: no such file or directory -- *Android Device (192.168.5.5):* VideoView videoView =(VideoView)findViewById(R.id.VideoView);MediaController mediaController= new MediaController(this); mediaController.setAnchorView(videoView); Uri uri = Uri.parse(rtsp://192.168.1.20:7654/mystream.sdp); videoView.setMediaController(mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] Scale down if resolution is greater than given?
Hi Mahesh, On Wed, Jul 29, 2015 at 18:08:56 +0530, Mahesh Patade wrote: Check this. I have written this logic in my script. Wow. If you're going to use scripting, why not use it to make life (and readability) easier instead of harder. For instance, just for my(!) readability, I would change this: transcode() { # 128 Bitrate MULBIT128=$(echo ${1}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT128} ]; then if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -s $1 -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi else if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi fi To this: transcode() { # 128 Bitrate MULBIT128=$(echo ${1}|sed 's#x#*#g' |bc) if [ ${REOLVIDEO} -gt ${MULBIT128} ]; then SCALE=-s $1 else SCALE= fi if ! ffmpeg -threads ${CPUNO} -ss ${START_TIME} -t ${LENGTH} -i ${FILENAME} $SCALE -movflags rtphint -b:v 128k -vcodec libx264 -acodec libfaac -ab 20k -ar 44100 -y ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.ts ${OUTPATH}${FILEWOEXT}.part${CURRENT_NODE}-128000.log.txt 21; then ERROR=1 ERRORLOG=${ERRORLOG}Failed: 128 Bitrate Conversion fi This makes the difference between the if and the else clause much clearer! MULBIT128, MULBIT256, MULBIT512 could also be differentiated by simple variables/function arguments, and one very common ffmpeg command line. That also makes modifying other arguments to ffmpeg much easier. You don't have to do it X times. That's the whole point of scripting! SCNR. eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width ${FILENAME}) SIZE=${streams_stream_0_width}x${streams_stream_0_height} REOLVIDEO=$(echo ${SIZE} |sed 's#x#*#g' | bc) RESOLUTION=$(echo scale=1; $streams_stream_0_width/$streams_stream_0_height | bc) So REOLVIDEO is the number of pixels, RESOLUTION is what we usually call the aspect ratio? I wouldn't use that to choose the target sizes, but just maintain the aspect ratio. But that's your call. I would use this filter now (we can ignore Mahesh's multi-bitrates for this question): $ ffmpeg [...] -vf scale=w=if(gt(iw*ih\,1280*720)\,iw*min(1280/iw\,1024/ih)\,iw):h=-2 [...] This scales any video with more pixels than 1280*720 inside of a box of 1280*720. An improvement would be to scale it to the correct number of pixels. More math. ;-) Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user