Re: [FFmpeg-user] Extract audio from video and use one frame as cover image

2021-01-07 Thread Gyan Doshi



On 08-01-2021 06:37, Bernhard Döbler wrote:

Hi,

I saw, today, FFMpeg, finally, allows for embedding a single image as 
cover image into an .M4A file using the "-disposition:v:1 
attached_pic" argument as explained in an answer on StackOverflow: 
https://stackoverflow.com/a/61015965/577052


This works very well, when I convert a .FLAC file, that already has 
one single frame embedded as cover, to .M4A using a command line like
ffmpeg.exe -y -i "e:\01. Music.flac" -c:a aac -q:a 2 -c:v mjpeg -q:v 2 
-disposition:v:0 attached_pic -movflags +faststart "e:\01. Music.m4a"


I have video files. I want to extract the audio and use one single 
frame from the video track as cover image.

The command line looks like this
ffmpeg.exe -y -i "e:\01. Video.mp4" -filter:v 
"select=between(145\,prev_pts*TB\,pts*TB)" -frames:v 1 -c:a copy -c:v 
mjpeg -q:v 2 -disposition:v:0 attached_pic "e:\01. Audio.m4a"


This is supposed to embed a frame from around second 145 as cover image.
The issue is that the whole processing of the file stops after the 
single image was extracted and my resulting file has a length of 2:25 
minutes. I want the audio file to be as long as the video.


`-frames` is set to terminate the output when fulfilled. Use trim within 
the filtergraph.


ffmpeg.exe -y -i "e:\01. Video.mp4" -filter:v 
"select=between(145\,prev_pts*TB\,pts*TB),trim=end_frame=1" -c:a copy 
-c:v mjpeg -q:v 2 -disposition:v:0 attached_pic "e:\01. Audio.m4a"


Regards,
Gyan
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Extract audio from video and use one frame as cover image

2021-01-07 Thread Bernhard Döbler

Hi,

I saw, today, FFMpeg, finally, allows for embedding a single image as 
cover image into an .M4A file using the "-disposition:v:1 attached_pic" 
argument as explained in an answer on StackOverflow: 
https://stackoverflow.com/a/61015965/577052


This works very well, when I convert a .FLAC file, that already has one 
single frame embedded as cover, to .M4A using a command line like
ffmpeg.exe -y -i "e:\01. Music.flac" -c:a aac -q:a 2 -c:v mjpeg -q:v 2 
-disposition:v:0 attached_pic -movflags +faststart "e:\01. Music.m4a"


I have video files. I want to extract the audio and use one single frame 
from the video track as cover image.

The command line looks like this
ffmpeg.exe -y -i "e:\01. Video.mp4" -filter:v 
"select=between(145\,prev_pts*TB\,pts*TB)" -frames:v 1 -c:a copy -c:v 
mjpeg -q:v 2 -disposition:v:0 attached_pic "e:\01. Audio.m4a"


This is supposed to embed a frame from around second 145 as cover image.
The issue is that the whole processing of the file stops after the 
single image was extracted and my resulting file has a length of 2:25 
minutes. I want the audio file to be as long as the video.


To overcome this, I provide the same video file twice as input and 
select the audio track of one file and the video track from the other 
using the map argument.
ffmpeg.exe -y -i "e:\01. Video.mp4" -i "e:\01. Video.mp4" -filter:v 
"select=between(145\,prev_pts*TB\,pts*TB)" -frames:v 1 -map 0:1 -map 1:0 
-c:a copy -c:v mjpeg -q:v 2 -disposition:v:0 attached_pic "e:\01. Audio.m4a"


This works!

I'm now wondering if there's a way to make this work providing the input 
file only once, selecting a single frame and the whole audio.


Is there a best practice to convert video files to audio files 
maintaining one single frame a cover image?



Best,
Bernhard
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] How to record video and audio in parallel for every 40ms continuous upto 10s

2021-01-07 Thread Vijay Rakesh Munganda
Hi,

I’m new to FFMEPG, how to record video and audio in a separate files for every 
40ms continuously upto 10 seconds from webcam using FFMPEG? I used below 
command, but it is generating 250 audio and only 1 video file. Also it is 
generating audio then video, I need it parallel, video with respective audio. 

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 audio_%003d.aac -c:v 
libx264 -t 0:10 -segment_time 00:00.040 -f segment out_%003d.h264

Thanks & Regards,
Vijay Rakesh
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Convert to .MP4 using ffmpeg preserving KLV metadata

2021-01-07 Thread Mar Andrés López
Dear All,


I have the following video klv.mpeg, composed by two streams, a video stream 
and a klv data stream. As you can see:


[mpegts @ 0146ceeaaec0] start time for stream 1 is not set in 
estimate_timings_from_pts
Input #0, mpegts, from 'klv.mpeg':
  Duration: 00:01:30.80, start: 0.50, bitrate: 1347 kb/s
  Program 1
Stream #0:0[0x3e8]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), 
yuv420p(tv, bt470bg, progressive), 640x480 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 
90k tbn, 60 tbc
Side data:
  cpb: bitrate max/min/avg: 100/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:1[0x90]: Data: klv (KLVA / 0x41564C4B)


I am trying to preserve the klv data stream when converting it to mp4 but it 
seems imposible.


  1.  The first thing I am trying is to try to copy the data codec with the 
following command:

ffmpeg -i klv.mpeg -map 0:v -vcodec h264 -map 0:a? -acodec aac -map 0:d? -codec 
copy output.mp4


But it results in the following error:


[mp4 @ 01ff0d8c8fc0] Could not find tag for codec klv in stream #1, codec 
not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): 
Invalid argument

  2.  The second thing that I am trying is to convert just the video and audio 
with the same command as above without the data stream.


ffmpeg -i klv.mpeg -map 0:v -vcodec h264 -map 0:a? -acodec aac output.mp4


Then i extract just the klv with the following command:


ffmpeg -i klv.mpeg -map 0:d -codec copy -f data output.klv


After that I try to join the output.mp4 and the output.klv with:


ffmpeg -i output.mp4 -i output.klv -map 0:v -map 0:a? -map 1:d? final.mp4


But the error is:


[mov,mp4,m4a,3gp,3g2,mj2 @ 0288d7b2c040] Format mov,mp4,m4a,3gp,3g2,mj2 
detected only with low score of 1, misdetection possible!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0288d7b2c040] moov atom not found
prueba.mp4: Invalid data found when processing input


I tried to use the -movflags faststart as I have read also but with no 
successfull result.


Is there anyway to do this?


A lot of thanks in advance

P Please consider the environment before printing this e-mail.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] cant stream audio and video at the same time

2021-01-07 Thread Gisbert Haas

Hi again,


anyone got a bride idea what else I can try? Could it be a bug?


Thanks again



On 1/5/21 10:24 PM, Gisbert Haas wrote:


Hi,

as I tried to explain, on the link you provided I learned about the 
v4l2 timestamps option "-ts abs" I'm now using:


Linux Mint Laptop:

ffmpeg -f alsa -i default -f v4l2 -input_format yuv420p -video_size 
1280x720 -ts abs -i /dev/video0 -c:v libx264 -b:v 8M  -c:a aac -f 
mpegts  udp://230.10.1.1:5700



Raspberry Pi 4, RasbianOS 32 bit

ffmpeg -f alsa -i default -f v4l2 -input_format yuv420p -video_size 
1280x720 -ts abs -i /dev/video0 -c:v h264_v4l2m2m -b:v 8M -c:a aac -f 
mpegts  udp://230.10.1.1:5700


only difference between the two is the video output format due to 
different architecture.



On Linux Laptop the start_time is now in sync (with -ts abs):

Input #0, alsa, from 'default':
  Duration: N/A, start: 1609881042.036804, 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: 1609881042.395996, bitrate: 147456 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 
1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc



On the Raspberry Pi even with the -ts abs set, the start_time did not 
change:


Input #0, alsa, from 'hw:2,0':
  Duration: N/A, start: 1609881274.125326, 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: 0.00, bitrate: 884736 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 
1280x720, 884736 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc


instead I'm getting an error:

[video4linux2,v4l2 @ 0x23d0440] Unknown timestamps


with using option -ts mono2abs the time stamps are not quite the same:

Input #0, alsa, from 'default':
  Duration: N/A, start: 1609881635.974239, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2,v4l2 @ 0x1028850] Detected monotonic timestamps, converting
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1609851045.581055, bitrate: 294912 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 
640x480, 294912 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc



I hope with the -ts option I'm using the right option as I cant find 
anything else on v4l2 would modify the start_time



Thanks a lot






On 1/5/21 8:58 PM, Carl Eugen Hoyos wrote:
CAUTION: This email originated from outside of the organization. Do 
not click links or open attachments unless you recognize the sender 
and know the content is safe.





Am 05.01.2021 um 16:05 schrieb Gisbert Haas >:


Input #0, alsa, from 'hw:2,0':
  Duration: N/A, start: 1609858998.181873, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2,v4l2 @ 0x32cd6e0] Dequeued v4l2 buffer contains 
corrupted data (0 bytes).

Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 0.00, bitrate: 884736 kb/s


These streams cannot get synchronised because of the different start 
times.

See https://ffmpeg.org/ffmpeg-devices.html#Options-18

Please find out what top-posting means and avoid it here.
And please do not reply in private to emails sent to a mailing list.

Carl Eugen

___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".