[FFmpeg-user] Unable to play recorded audio and video from webcam using ffmpeg
Vijay Rakesh Munganda
vijayrakeshmunganda at gmail.com
Mon Jan 11 14:02:59 EET 2021
Hi All,
Kindly please anyone suggest me.
Thanks & Regards,
Vijay Rakesh
> On 11-Jan-2021, at 10:06, Vijay Rakesh Munganda <vijayrakeshmunganda at gmail.com> wrote:
>
>
> Hi Moritz,
>
>> Assuming ffmpeg actually segments like this (and not on keyframes): Individual
>> frames cannot normally be played, unless they are keyframes. You should
>> play the complete segment "playlist" as a whole. ffplay will have
>> trouble identifying the streams and codecs in such a short sample:
>> I have add keyframes
>
> I have added the keyframes option in ffmpeg command as ffmpeg -f alsa -thread_queue_size 1024 -i hw:0 -f video4linux2 -i /dev/video0 -c:a aac -ar 48k -t 0:10 -segment_time 00:00.04 -f segment sample-%003d.aac -c:v h264 -force_key_frames "expr:gte(t,n_forced*0.04)" -pix_fmt yuv420p -s:v 640x480 -t 0:10 -r 25 -g 1 -segment_time 00:00.04 -f segment frame-%003d.h264. But still I get an error as frame-001.h264: Invalid data found when processing input.
>
> Console Output:
> configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
> libavutil 55. 78.100 / 55. 78.100
> libavcodec 57.107.100 / 57.107.100
> libavformat 57. 83.100 / 57. 83.100
> libavdevice 57. 10.100 / 57. 10.100
> libavfilter 6.107.100 / 6.107.100
> libavresample 3. 7. 0 / 3. 7. 0
> libswscale 4. 8.100 / 4. 8.100
> libswresample 2. 9.100 / 2. 9.100
> libpostproc 54. 7.100 / 54. 7.100
> Guessed Channel Layout for Input Stream #0.0 : stereo
> Input #0, alsa, from 'hw:0':
> Duration: N/A, start: 1610338632.931406, bitrate: 1536 kb/s
> Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Input #1, video4linux2,v4l2, from '/dev/video0':
> Duration: N/A, start: 3405.427360, bitrate: 147456 kb/s
> Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
> Stream mapping:
> Stream #0:0 -> #0:0 (pcm_s16le (native) -> aac (native))
> Stream #1:0 -> #1:0 (rawvideo (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [alsa @ 0x55777d96fe00] ALSA buffer xrun.
> [segment @ 0x55777d983d80] Opening 'sample-000.aac' for writing
> Output #0, segment, to 'sample-%003d.aac':
> Metadata:
> encoder : Lavf57.83.100
> Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
> Metadata:
> encoder : Lavc57.107.100 aac
> [libx264 @ 0x55777d98fa20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
> [libx264 @ 0x55777d98fa20] profile High, level 3.0
> [libx264 @ 0x55777d98fa20] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=1 keyint_min=1 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
> [segment @ 0x55777d98dda0] Opening 'frame-000.h264' for writing
> Output #1, segment, to 'frame-%003d.h264':
> Metadata:
> encoder : Lavf57.83.100
> Stream #1:0: Video: h264 (libx264), yuv420p, 640x480, q=-1--1, 25 fps, 25 tbn, 25 tbc
> Metadata:
> encoder : Lavc57.107.100 libx264
> Side data:
> cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
> [segment @ 0x55777d983d80] Opening 'sample-001.aac' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-001.h264' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-002.h264' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-003.h264' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-004.h264' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-005.h264' for writing
> [segment @ 0x55777d98dda0] Opening 'frame-006.h264' for writingA dup=1 drop=0 speed=1.07x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-018.h264' for writingA dup=5 drop=0 speed=0.714x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-029.h264' for writingA dup=12 drop=0 speed=0.768x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-042.h264' for writingA dup=21 drop=0 speed=0.834x
> ...
> [segment @ 0x55777d983d80] Opening 'sample-055.aac' for writingA dup=31 drop=0 speed=0.89x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-067.h264' for writingA dup=39 drop=0 speed=0.887x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-081.h264' for writingA dup=49 drop=0 speed=0.92x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-091.h264' for writingA dup=56 drop=0 speed=0.904x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-105.h264' for writingA dup=66 drop=0 speed=0.927x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-119.h264' for writingA dup=76 drop=0 speed=0.944x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-130.h264' for writingA dup=84 drop=0 speed=0.938x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-144.h264' for writingA dup=94 drop=0 speed=0.952x
> ...
> [segment @ 0x55777d983d80] Opening 'sample-154.aac' for writingA dup=103 drop=0 speed=0.958x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-168.h264' for writingA dup=111 drop=0 speed=0.952x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-182.h264' for writingA dup=121 drop=0 speed=0.962x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-193.h264' for writingA dup=129 drop=0 speed=0.956x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-207.h264' for writingA dup=139 drop=0 speed=0.965x
> ...
> [segment @ 0x55777d983d80] Opening 'sample-218.aac' for writingA dup=149 drop=0 speed=0.974x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-231.h264' for writingA dup=156 drop=0 speed=0.964x
> ...
> [segment @ 0x55777d98dda0] Opening 'frame-249.h264' for writing
> frame= 250 fps= 24 q=-1.0 Lsize=N/A time=00:00:10.00 bitrate=N/A dup=168 drop=0 speed=0.98x
> video:2707kB audio:149kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
> [aac @ 0x55777d98cf00] Qavg: 260.500
> [libx264 @ 0x55777d98fa20] frame I:250 Avg QP:26.77 size: 11085
> [libx264 @ 0x55777d98fa20] mb I I16..4: 13.4% 72.3% 14.3%
> [libx264 @ 0x55777d98fa20] 8x8 transform intra:72.3%
> [libx264 @ 0x55777d98fa20] coded y,uvDC,uvAC intra: 54.2% 91.6% 64.5%
> [libx264 @ 0x55777d98fa20] i16 v,h,dc,p: 13% 18% 6% 62%
> [libx264 @ 0x55777d98fa20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 18% 16% 6% 7% 6% 12% 5% 10%
> [libx264 @ 0x55777d98fa20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 11% 6% 8% 8% 10% 5% 6%
> [libx264 @ 0x55777d98fa20] i8c dc,h,v,p: 58% 20% 15% 7%
> [libx264 @ 0x55777d98fa20] kb/s:2216.90
>
> Thanks & Regards,
> Vijay Rakesh.
>
>> On Sat, Jan 9, 2021 at 8:33 PM Vijay Rakesh Munganda <vijayrakeshmunganda at gmail.com> wrote:
>> Hi Moritz,
>>
>>>
>>> "-segment_time 00:00.040"?
>>> Are you trying to create a segment for each single frame?
>>>
>>
>> No, I’m trying to create h264 video and aac audio of every 40ms continuously upto 10s. So that I can send these video and audio files as a fragments to the AWS kinesis video streams, at cloud end it will get combined for playing. When I use ffplay on these samples it plays video, but not audio https://github.com/awslabs/amazon-kinesis-video-streams-producer-c/tree/master/samples. I want to generate similar video and audio files from webcam. Since I’m new to ffmpeg I’m unable write correct ffmpeg command, kindly please suggest me.
>>
>> Thanks & Regards,
>> Vijay Rakesh
>>
>>>> On 09-Jan-2021, at 19:51, Moritz Barsnick <barsnick at gmx.net> wrote:
>>>>
>>> Hi Vijay,
>>>
>>>> On Sat, Jan 09, 2021 at 14:33:59 +0530, Vijay Rakesh Munganda wrote:
>>>> ffmpeg -f alsa -thread_queue_size 1024 -i hw:0 -f video4linux2 -i /dev/video0 -c:a aac -t 0:10 -segment_time 00:00.040
>>>> -f segment sample-%003d.aac -c:v libx264 -s:v 640x480 -t 0:10 -r 25 -g 1 -segment_time 00:00.040 -f segment frame-%003d.h264
>>>
>>> "-segment_time 00:00.040"?
>>> Are you trying to create a segment for each single frame?
>>>
>>> Assuming ffmpeg actually segments like this (and not on keyframes): Individual
>>> frames cannot normally be played, unless they are keyframes. You should
>>> play the complete segment "playlist" as a whole. ffplay will have
>>> trouble identifying the streams and codecs in such a short sample:
>>>
>>>> [h264 @ 0x7f1220000b80] Format h264 detected only with low score of 1, misdetection possible!
>>> [...]
>>>> [aac @ 0x7f0ce8000b80] Format aac detected only with low score of 1, misdetection possible!
>>>
>>> The other errors likely also come from missing references.
>>>
>>>> [aac @ 0x7f0ce8000b80] Estimating duration from bitrate, this may be inaccurate
>>>> Input #0, aac, from 'sample-000.aac':
>>>> Duration: 00:00:00.04, bitrate: 109 kb/s
>>>> Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 109 kb/s
>>>> 13.16 M-A: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
>>>
>>> Please remember to always post the complete, uncut console output of
>>> the errored command, in this case ffplay. The output of ffmpeg would
>>> also have been helpful, but perhaps, in this case, your edited output
>>> may be enough.
>>>
>>> Regards,
>>> Moritz
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list