Record short audio output using parec - pulseaudio

I've stumbled upon a problem that if a program outputs short audio then parec is not able to record it.
Here's the recorder
parec --rate 48000 -d alsa_output.pci-0000_00_0e.0.analog-stereo.monitor | hexdump -C
Here is a program producing short audio
play -q -n -c1 synth -n 0.3 triangle 500
If I change 0.3 to 0.4 then hexdump starts to output. So, no output if the audio is shorter than 400ms. Maybe it is also dependent on the computer performance, idn
Is there anything I can do with that?

Related

Flutter FFMPEG Increases in processing time based on size of video even when only cutting the same size

I am by no means an expert with ffmpeg. But I'm finding it strange that the the time to create a gif and trim that section is increasing so much based on the size of the video since I am always grabbing only three seconds.
I am using flutter FFmpeg.
-ss 0:00:01.000000, -i /data/user/0/com.example.example/cache/image_picker1475407716366431469.mp4 -t, 0:00:03.000000 -avoid_negative_ts make_zero, -vf fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse, -loop 0
Is there a command to make sure that ffmpeg doesn't concentrate on the entire video, and only concentrates on the three seconds I am getting in -t, so that the time doesn't increase greatly based on the video size. Or is this just normal for ffmpeg. Does it have to parse the entire video, before creating the gif.
I found a solution for anyone else looking. For some reason its much faster to just trim the original video and then make a gif. So just running '-c:v copy ' on the original video and then running the above command cut the processing time on a 3 minute video down from 1 minute 40 seconds to 10 seconds.

sox soundexchange - how do you stop recording when there is silence longer than 20 sec?

I cannot get sox to stop recording when silence occurs.
I've have successfully gotten the result I needed when using sox with input output files:
sox original.mp3 trimmed.mp3 silence 1 0.3 1% 1 20.0 1%
sox starts recording after the first noise of 0.3 seconds, then records until 20 seconds of silence are detected.
Issue: When I try to do the same with parameter -d (to record from the default device, a microphone, not an input file) - it doesn't work, the recording never stops (even though there is absolute silence):
sox -d temp_new.mp3 silence 1 0.3 1% 1 20.0 1%
Thank you!
Added info:
I am not using a microphone, but a virtual audio cable that routes system noise to the sox app. The respective machine does not have a microphone, so there cannot be local background noise in the recording.

ffplay keep video/audio sync when using select filter

I'm trying to play/skip some clips of a video using ffplay. My first approach to skip say frames 100 to 400 was:
ffplay -vf "select='lte(n\,100)+gte(n\,400)'" -i INPUT
this skips the desired frames, however it also freezes the video during the skipped frames. I tried to fix this by modifying the video presentation time stamp (PTS) with the setpts option:
ffplay -vf "select='lte(n\,100)+gte(n\,400)',setpts='PREV_OUTPTS'" -i INPUT
this seems to work (stills freeze a bit, guess is because of buffering), but now the audio is out of sync. I've tried applying a select filter and modifying the PTS on the audio as well
ffplay -vf "select='lte(n\,100)+gte(n\,400)',setpts='PREV_OUTPTS'" -af "aselect='lte(n\,100)+gte(n\,400)',asetpts='PREV_OUTPTS'" -i INPUT
this skips some audio frames, but still out of sync. I've tried with the aresample=async=10000 option with similar results. Moving some/all of the filters to the output (placing them after the -i INPUT) doesn't work either.
Does someone know how to skip parts of a video using ffplay? Many thanks
Audio frame numbers != video frame numbers. AAC audio generated by FFmpeg's encoder is 1024 samples per frame, so a 48kHz stream has 48000/1024 = 46.875 audio frames per second. Other codecs may have different rates.
Use t instead of n, and generate a continuous series of timestamps.
ffplay
-vf "select='lte(t\,4)+gte(t\,16)',setpts=N/FRAME_RATE/TB"
-af "aselect='lte(t\,4)+gte(t\,16)',asetpts=N/SR/TB"
-i INPUT
I assume a video frame rate of 25 fps. Modify accordingly.

Apple Quick Time Mov Files Slow Down Playback Rate Via Command Line

I am looking for commmandline to slow down Quick Time formated MOV files. Most likely using FFMPEG. I do not mind converting to MP4 format either.
To slow down your video, you have to use a multiplier greater than 1:
ffmpeg -i input.mov -filter:v "setpts=2.0*PTS" output.mov
I am not sure if this works right now.
batch slow down .mov speed (No answer here either)
Almost impossible without full reencoding (or transcondig).
If the source is video only, it can be easily done by simple hex editing. Just change the track timescale value in the MDHD box =>
http://wiki.multimedia.cx/?title=QuickTime_container#mdhd
The lower timescale the slower play rate.
I've tested it works as following:
1) find out current frame rate with Mediainfo tool
2) Open the file with HxD
3) Recklessly search 'mdhd'
4) Between 'mdhd' and 'hdlr', find 16 bit big endian hex representation of frame rate and change it
I'm not sure but this kind of hacking seems not supported by ffmpeg.
But if it also has audio track, changing its timescale will produce noisy sound, therefore reencoding is unavoidable.
Transcoding is rather straightforward work. I'd recommend HandBreak or other GUI frontends.
Use this line
ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv
I used this link
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

Are there better option for a smaller file size than .aiff to be used with AVAudioPlayer?

I'm using AVAudioPlayer to play a short one or two syllables word in my app. Currently there are 250 .aiff files and each of the file is roughly 88KB to 125KB each. Currently my ipa file is at 29Megs and I am trying to find the best way to reduce the size so user don't have to have a wifi to download it.
Each of the sound clip is 1 to 2.5 seconds long. I don't need to pause, rewind, fast forward etc.
Based on what I read so far AVAudioPlayer only play aiff, wav or caf and none of those are compressed. Any recommendation on what I can do? Thank you.
CAF files can be compressed, using either lossy or lossless algorithms. If you're using the command line afconvert utility to convert, you could try:
afconvert -f caff -d ima4 audiofile.wav (for IMA4 compression)
afconvert -f caff -d aac audiofile.wav (for AAC compression)
There's also a -b parameter that allows you to set the output bit rate, and a bunch of other options. The man page is basically empty but the full array of possibilities are listed in QA1534.