
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (21)
-
Gestion générale des documents
13 mai 2011, parMédiaSPIP ne modifie jamais le document original mis en ligne.
Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...) -
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users. -
MediaSPIP Player : problèmes potentiels
22 février 2011, parLe lecteur ne fonctionne pas sur Internet Explorer
Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)
Sur d’autres sites (2578)
-
Main process is held by ffmpeg command
6 octobre 2024, par Michael LopezI created a python program for handling my Arlo Camera. To do that I have been using the
pyaarlo
library (https://github.com/twrecked/pyaarlo) to catch camera's events.
The goal is to monitor if there is an active stream on cameras, get the RTSP stream url and reStream it to a HLS playlist for local usage.

Here the python code :


import asyncio
from decouple import config
import logging
from my_pyaarlo import PyArlo
import urllib.parse
from queue import Queue
import signal

# Read config from ENV (unchanged)
ARLO_USER = config('ARLO_USER')
ARLO_PASS = config('ARLO_PASS')
IMAP_HOST = config('IMAP_HOST')
IMAP_USER = config('IMAP_USER')
IMAP_PASS = config('IMAP_PASS')
DEBUG = config('DEBUG', default=False, cast=bool)
PYAARLO_BACKEND = config('PYAARLO_BACKEND', default=None)
PYAARLO_REFRESH_DEVICES = config('PYAARLO_REFRESH_DEVICES', default=0, cast=int)
PYAARLO_STREAM_TIMEOUT = config('PYAARLO_STREAM_TIMEOUT', default=0, cast=int)
PYAARLO_STORAGE_DIR = config('PYAARLO_STORAGE_DIR', default=None)
PYAARLO_ECDH_CURVE = config('PYAARLO_ECDH_CURVE', default=None)

# Initialize logging
logging.basicConfig(
 level=logging.DEBUG if DEBUG else logging.INFO,
 format='%(asctime)s [%(levelname)s] %(name)s: %(message)s'
)
logger = logging.getLogger(__name__)

ffmpeg_processes = {}
event_queue = Queue()
shutdown_event = asyncio.Event()

async def handle_idle_event(camera):
 logger.info(f"Idle event detected for camera: {camera.name}")
 await stop_ffmpeg_stream(camera.name)

async def get_stream_url(camera):
 try:
 # Attempt to get the stream URL
 stream_url = await asyncio.to_thread(camera.get_stream()
 if stream_url:
 return stream_url
 else:
 logger.warning(f"Unable to get stream URL for {camera.name}. Stream might not be active.")
 return None
 except Exception as e:
 logger.error(f"Error getting stream URL for {camera.name}: {e}")
 return None

async def handle_user_stream_active_event(camera):
 logger.info(f"User stream active event detected for camera: {camera.name}")

 # Get the stream URL
 stream_url = await get_stream_url(camera)
 if stream_url:
 logger.info(f"Stream URL for {camera.name}: {stream_url}")
 await start_ffmpeg_stream(camera.name, stream_url)
 else:
 logger.warning(f"No stream URL available for {camera.name}")

async def event_handler(device, attr, value):
 logger.debug(f"Event: {device.name}, Attribute: {attr}, Value: {value}")
 if attr == 'activityState':
 if value == 'idle':
 await handle_idle_event(device)
 elif value in ['userStreamActive']:
 await handle_user_stream_active_event(device)
 elif attr == 'mediaUploadNotification':
 logger.info(f"Media uploaded for camera: {device.name}")

def sync_event_handler(device, attr, value):
 # This function will be called by PyArlo's synchronous callbacks
 event_queue.put((device, attr, value))

async def process_event_queue():
 while not shutdown_event.is_set():
 try:
 if not event_queue.empty():
 device, attr, value = event_queue.get()
 await event_handler(device, attr, value)
 await asyncio.sleep(0.1) # Small delay to prevent busy-waiting
 except asyncio.CancelledError:
 break
 except Exception as e:
 logger.error(f"Error processing event: {e}")

async def display_status(arlo):
 while not shutdown_event.is_set():
 print("\n--- Camera Statuses ---")
 for camera in arlo.cameras:
 print(f"{camera.name}: {camera.state}")
 print("------------------------")
 await asyncio.sleep(5)

async def start_ffmpeg_stream(camera_name, stream_url):
 if camera_name not in ffmpeg_processes:
 output_hls = f"/tmp/{camera_name}.m3u8"

 try:
 new_url = urllib.parse.quote(stream_url.encode(), safe=':/?&=')
 logger.info(f"NEW_URL: {new_url}")

 ffmpeg_cmd = [
 "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-nostats", "-nostdin", "-y", "-re",
 "-i", new_url,
 "-c:v", "libx264", "-preset", "veryfast",
 "-an", "-sn",
 "-f", "hls", "-hls_time", "4", "-hls_list_size", "10",
 "-hls_flags", "delete_segments", output_hls,
 ]
 logger.info(f"Starting FFmpeg command: {ffmpeg_cmd}")
 
 process = await asyncio.create_subprocess_exec(
 *ffmpeg_cmd,
 stdout=asyncio.subprocess.DEVNULL,
 stderr=asyncio.subprocess.DEVNULL
 )
 ffmpeg_processes[camera_name] = process
 logger.info(f"Started ffmpeg process with PID: {process.pid}")

 except Exception as e:
 logger.error(f"Error starting FFmpeg for {camera_name}: {e}")

async def stop_ffmpeg_stream(camera_name):
 logger.info(f"Stopping ffmpeg process for {camera_name}")
 ffmpeg_process = ffmpeg_processes.pop(camera_name, None)
 if ffmpeg_process:
 ffmpeg_process.terminate()

 try:
 await ffmpeg_process.wait()
 logger.info(f"{camera_name} stopped successfully")
 except Exception as e:
 print(f"FFMPEG Process didn't stop in time, forcefully terminating: {e}")
 ffmpeg_process.kill()
 else:
 logger.info(f"FFmpeg process for {camera_name} already stopped")

async def shutdown(signal, loop):
 logger.info(f"Received exit signal {signal.name}...")
 shutdown_event.set()
 tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
 [task.cancel() for task in tasks]
 logger.info(f"Cancelling {len(tasks)} outstanding tasks")
 await asyncio.gather(*tasks, return_exceptions=True)
 loop.stop()

async def main():
 # Initialize PyArlo
 arlo_args = {
 'username': ARLO_USER,
 'password': ARLO_PASS,
 'tfa_source': 'imap',
 'tfa_type': 'email',
 'tfa_host': IMAP_HOST,
 'tfa_username': IMAP_USER,
 'tfa_password': IMAP_PASS,
 'save_session': True,
 'verbose_debug': DEBUG
 }

 # Add optional arguments
 for arg, value in [
 ('refresh_devices_every', PYAARLO_REFRESH_DEVICES),
 ('stream_timeout', PYAARLO_STREAM_TIMEOUT),
 ('backend', PYAARLO_BACKEND),
 ('storage_dir', PYAARLO_STORAGE_DIR),
 ('ecdh_curve', PYAARLO_ECDH_CURVE)
 ]:
 if value:
 arlo_args[arg] = value
 
 try:
 arlo = await asyncio.to_thread(PyArlo, **arlo_args)
 except Exception as e:
 logger.error(f"Failed to initialize PyArlo: {e}")
 return

 logger.info("Connected to Arlo. Monitoring events...")

 # Register event handlers for each camera
 for camera in arlo.cameras:
 camera.add_attr_callback('*', sync_event_handler)

 # Start the status display task
 status_task = asyncio.create_task(display_status(arlo))

 # Start the event processing task
 event_processing_task = asyncio.create_task(process_event_queue())

 # Set up signal handlers
 loop = asyncio.get_running_loop()
 for s in (signal.SIGHUP, signal.SIGTERM, signal.SIGINT):
 loop.add_signal_handler(
 s, lambda s=s: asyncio.create_task(shutdown(s, loop)))

 try:
 # Keep the main coroutine running
 while not shutdown_event.is_set():
 try:
 await asyncio.sleep(1)
 except asyncio.CancelledError:
 break
 except Exception as e:
 logger.error(f"Unexpected error in main loop: {e}")
 finally:
 logger.info("Shutting down...")
 for camera_name in list(ffmpeg_processes.keys()):
 await stop_ffmpeg_stream(camera_name)
 
 # Cancel and wait for all tasks
 tasks = [status_task, event_processing_task]
 for task in tasks:
 if not task.done():
 task.cancel()
 await asyncio.gather(*tasks, return_exceptions=True)
 
 logger.info("Program terminated.")

if __name__ == "__main__":
 try:
 asyncio.run(main())
 except KeyboardInterrupt:
 logger.info("Keyboard interrupt received. Exiting.")
 except Exception as e:
 logger.error(f"Unhandled exception: {e}")
 finally:
 logger.info("Program exit complete.")



My issue is about the ffmpeg command which is hold the main process (or the event loop) when it runs, blocking the events coming from the pyaarlo library. The state of the camera continues to work with the good information.


I tried lot of things, without asyncio, with multiprocessing, with subprocess, ... the behavior is always the same. In some cases, I received the idle event after the key interrupt.


Another information :


- 

- When I stop the active stream, the event is not received but when I start the stream just after, that event is received.
- When I run the same ffmpeg command but with a local long video file, everything is Ok. So, it why I guess that the ffmpeg command is impacting the main process.






I succedeed in running the ffmpeg command with rtsp url stream but without a loop event monitoring :


import asyncio
import signal
import sys
import os

async def run_infinite_command():
 # Start a simple HTTP server as our "infinite" command
 url = "rstp://localhost:8554/camera1/stream" # it is a fake url
 ffmpeg_cmd = [
 "ffmpeg", "-re", "-i", url,
 "-c:v", "libx264", "-preset", "veryfast",
 "-c:a", "copy",
 "-f", "hls", "-hls_time", "4", "-hls_list_size", "10",
 "-hls_flags", "delete_segments", "/tmp/output.m3u8"
 ]
 
 process = await asyncio.create_subprocess_exec(
 *ffmpeg_cmd,
 stdout=asyncio.subprocess.DEVNULL,
 stderr=asyncio.subprocess.DEVNULL
 )
 
 print(f"Started HTTP server with PID: {process.pid}")
 return process

async def main():
 # Start the infinite command
 process = await run_infinite_command()

 # Run the main loop for a few seconds
 for i in range(10):
 print(f"Main loop iteration {i+1}")
 await asyncio.sleep(1)

 # Stop the infinite command
 print("Stopping the HTTP server...")
 if sys.platform == "win32":
 # On Windows, we need to use CTRL_C_EVENT
 os.kill(process.pid, signal.CTRL_C_EVENT)
 else:
 # On Unix-like systems, we can use SIGTERM
 process.send_signal(signal.SIGTERM)

 # Wait for the process to finish
 try:
 await asyncio.wait_for(process.wait(), timeout=5.0)
 print("HTTP server stopped successfully")
 except asyncio.TimeoutError:
 print("HTTP server didn't stop in time, forcefully terminating")
 process.kill()

 print("Program finished")

if __name__ == "__main__":
 asyncio.run(main())



With this script, the ffmpeg command is correctly launched and terminated after the for loop.


Could you help ?


-
[ffmpeg][asyncio] main process is held by ffmpeg command
5 octobre 2024, par Michael LopezI created a python program for handling my Arlo Camera. To do that I have been using the
pyaarlo
library (https://github.com/twrecked/pyaarlo) to catch camera's events.
The goal is to monitor if there is an active stream on cameras, get the RTSP stream url and reStream it to a HLS playlist for local usage.

Here the python code :


import asyncio
from decouple import config
import logging
from my_pyaarlo import PyArlo
import urllib.parse
from queue import Queue
import signal

# Read config from ENV (unchanged)
ARLO_USER = config('ARLO_USER')
ARLO_PASS = config('ARLO_PASS')
IMAP_HOST = config('IMAP_HOST')
IMAP_USER = config('IMAP_USER')
IMAP_PASS = config('IMAP_PASS')
DEBUG = config('DEBUG', default=False, cast=bool)
PYAARLO_BACKEND = config('PYAARLO_BACKEND', default=None)
PYAARLO_REFRESH_DEVICES = config('PYAARLO_REFRESH_DEVICES', default=0, cast=int)
PYAARLO_STREAM_TIMEOUT = config('PYAARLO_STREAM_TIMEOUT', default=0, cast=int)
PYAARLO_STORAGE_DIR = config('PYAARLO_STORAGE_DIR', default=None)
PYAARLO_ECDH_CURVE = config('PYAARLO_ECDH_CURVE', default=None)

# Initialize logging
logging.basicConfig(
 level=logging.DEBUG if DEBUG else logging.INFO,
 format='%(asctime)s [%(levelname)s] %(name)s: %(message)s'
)
logger = logging.getLogger(__name__)

ffmpeg_processes = {}
event_queue = Queue()
shutdown_event = asyncio.Event()

async def handle_idle_event(camera):
 logger.info(f"Idle event detected for camera: {camera.name}")
 await stop_ffmpeg_stream(camera.name)

async def get_stream_url(camera):
 try:
 # Attempt to get the stream URL
 stream_url = await asyncio.to_thread(camera.get_stream()
 if stream_url:
 return stream_url
 else:
 logger.warning(f"Unable to get stream URL for {camera.name}. Stream might not be active.")
 return None
 except Exception as e:
 logger.error(f"Error getting stream URL for {camera.name}: {e}")
 return None

async def handle_user_stream_active_event(camera):
 logger.info(f"User stream active event detected for camera: {camera.name}")

 # Get the stream URL
 stream_url = await get_stream_url(camera)
 if stream_url:
 logger.info(f"Stream URL for {camera.name}: {stream_url}")
 await start_ffmpeg_stream(camera.name, stream_url)
 else:
 logger.warning(f"No stream URL available for {camera.name}")

async def event_handler(device, attr, value):
 logger.debug(f"Event: {device.name}, Attribute: {attr}, Value: {value}")
 if attr == 'activityState':
 if value == 'idle':
 await handle_idle_event(device)
 elif value in ['userStreamActive']:
 await handle_user_stream_active_event(device)
 elif attr == 'mediaUploadNotification':
 logger.info(f"Media uploaded for camera: {device.name}")

def sync_event_handler(device, attr, value):
 # This function will be called by PyArlo's synchronous callbacks
 event_queue.put((device, attr, value))

async def process_event_queue():
 while not shutdown_event.is_set():
 try:
 if not event_queue.empty():
 device, attr, value = event_queue.get()
 await event_handler(device, attr, value)
 await asyncio.sleep(0.1) # Small delay to prevent busy-waiting
 except asyncio.CancelledError:
 break
 except Exception as e:
 logger.error(f"Error processing event: {e}")

async def display_status(arlo):
 while not shutdown_event.is_set():
 print("\n--- Camera Statuses ---")
 for camera in arlo.cameras:
 print(f"{camera.name}: {camera.state}")
 print("------------------------")
 await asyncio.sleep(5)

async def start_ffmpeg_stream(camera_name, stream_url):
 if camera_name not in ffmpeg_processes:
 output_hls = f"/tmp/{camera_name}.m3u8"

 try:
 new_url = urllib.parse.quote(stream_url.encode(), safe=':/?&=')
 logger.info(f"NEW_URL: {new_url}")

 ffmpeg_cmd = [
 "ffmpeg", "-hide_banner", "-loglevel", "quiet", "-nostats", "-nostdin", "-y", "-re",
 "-i", new_url,
 "-c:v", "libx264", "-preset", "veryfast",
 "-an", "-sn",
 "-f", "hls", "-hls_time", "4", "-hls_list_size", "10",
 "-hls_flags", "delete_segments", output_hls,
 ]
 logger.info(f"Starting FFmpeg command: {ffmpeg_cmd}")
 
 process = await asyncio.create_subprocess_exec(
 *ffmpeg_cmd,
 stdout=asyncio.subprocess.DEVNULL,
 stderr=asyncio.subprocess.DEVNULL
 )
 ffmpeg_processes[camera_name] = process
 logger.info(f"Started ffmpeg process with PID: {process.pid}")

 except Exception as e:
 logger.error(f"Error starting FFmpeg for {camera_name}: {e}")

async def stop_ffmpeg_stream(camera_name):
 logger.info(f"Stopping ffmpeg process for {camera_name}")
 ffmpeg_process = ffmpeg_processes.pop(camera_name, None)
 if ffmpeg_process:
 ffmpeg_process.terminate()

 try:
 await ffmpeg_process.wait()
 logger.info(f"{camera_name} stopped successfully")
 except Exception as e:
 print(f"FFMPEG Process didn't stop in time, forcefully terminating: {e}")
 ffmpeg_process.kill()
 else:
 logger.info(f"FFmpeg process for {camera_name} already stopped")

async def shutdown(signal, loop):
 logger.info(f"Received exit signal {signal.name}...")
 shutdown_event.set()
 tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
 [task.cancel() for task in tasks]
 logger.info(f"Cancelling {len(tasks)} outstanding tasks")
 await asyncio.gather(*tasks, return_exceptions=True)
 loop.stop()

async def main():
 # Initialize PyArlo
 arlo_args = {
 'username': ARLO_USER,
 'password': ARLO_PASS,
 'tfa_source': 'imap',
 'tfa_type': 'email',
 'tfa_host': IMAP_HOST,
 'tfa_username': IMAP_USER,
 'tfa_password': IMAP_PASS,
 'save_session': True,
 'verbose_debug': DEBUG
 }

 # Add optional arguments
 for arg, value in [
 ('refresh_devices_every', PYAARLO_REFRESH_DEVICES),
 ('stream_timeout', PYAARLO_STREAM_TIMEOUT),
 ('backend', PYAARLO_BACKEND),
 ('storage_dir', PYAARLO_STORAGE_DIR),
 ('ecdh_curve', PYAARLO_ECDH_CURVE)
 ]:
 if value:
 arlo_args[arg] = value
 
 try:
 arlo = await asyncio.to_thread(PyArlo, **arlo_args)
 except Exception as e:
 logger.error(f"Failed to initialize PyArlo: {e}")
 return

 logger.info("Connected to Arlo. Monitoring events...")

 # Register event handlers for each camera
 for camera in arlo.cameras:
 camera.add_attr_callback('*', sync_event_handler)

 # Start the status display task
 status_task = asyncio.create_task(display_status(arlo))

 # Start the event processing task
 event_processing_task = asyncio.create_task(process_event_queue())

 # Set up signal handlers
 loop = asyncio.get_running_loop()
 for s in (signal.SIGHUP, signal.SIGTERM, signal.SIGINT):
 loop.add_signal_handler(
 s, lambda s=s: asyncio.create_task(shutdown(s, loop)))

 try:
 # Keep the main coroutine running
 while not shutdown_event.is_set():
 try:
 await asyncio.sleep(1)
 except asyncio.CancelledError:
 break
 except Exception as e:
 logger.error(f"Unexpected error in main loop: {e}")
 finally:
 logger.info("Shutting down...")
 for camera_name in list(ffmpeg_processes.keys()):
 await stop_ffmpeg_stream(camera_name)
 
 # Cancel and wait for all tasks
 tasks = [status_task, event_processing_task]
 for task in tasks:
 if not task.done():
 task.cancel()
 await asyncio.gather(*tasks, return_exceptions=True)
 
 logger.info("Program terminated.")

if __name__ == "__main__":
 try:
 asyncio.run(main())
 except KeyboardInterrupt:
 logger.info("Keyboard interrupt received. Exiting.")
 except Exception as e:
 logger.error(f"Unhandled exception: {e}")
 finally:
 logger.info("Program exit complete.")



My issue is about the ffmpeg command which is hold the main process (or the event loop) when it runs, blocking the events coming from the pyaarlo library. The state of the camera continues to work with the good information.


I tried lot of things, without asyncio, with multiprocessing, with subprocess, ... the behavior is always the same. In some cases, I received the idle event after the key interrupt.


Another information :


- 

- When I stop the active stream, the event is not received but when I start the stream just after, that event is received.
- When I run the same ffmpeg command but with a local long video file, everything is Ok. So, it why I guess that the ffmpeg command is impacting the main process.






I succedeed in running the ffmpeg command with rtsp url stream but without a loop event monitoring :


import asyncio
import signal
import sys
import os

async def run_infinite_command():
 # Start a simple HTTP server as our "infinite" command
 url = "rstp://localhost:8554/camera1/stream" # it is a fake url
 ffmpeg_cmd = [
 "ffmpeg", "-re", "-i", url,
 "-c:v", "libx264", "-preset", "veryfast",
 "-c:a", "copy",
 "-f", "hls", "-hls_time", "4", "-hls_list_size", "10",
 "-hls_flags", "delete_segments", "/tmp/output.m3u8"
 ]
 
 process = await asyncio.create_subprocess_exec(
 *ffmpeg_cmd,
 stdout=asyncio.subprocess.DEVNULL,
 stderr=asyncio.subprocess.DEVNULL
 )
 
 print(f"Started HTTP server with PID: {process.pid}")
 return process

async def main():
 # Start the infinite command
 process = await run_infinite_command()

 # Run the main loop for a few seconds
 for i in range(10):
 print(f"Main loop iteration {i+1}")
 await asyncio.sleep(1)

 # Stop the infinite command
 print("Stopping the HTTP server...")
 if sys.platform == "win32":
 # On Windows, we need to use CTRL_C_EVENT
 os.kill(process.pid, signal.CTRL_C_EVENT)
 else:
 # On Unix-like systems, we can use SIGTERM
 process.send_signal(signal.SIGTERM)

 # Wait for the process to finish
 try:
 await asyncio.wait_for(process.wait(), timeout=5.0)
 print("HTTP server stopped successfully")
 except asyncio.TimeoutError:
 print("HTTP server didn't stop in time, forcefully terminating")
 process.kill()

 print("Program finished")

if __name__ == "__main__":
 asyncio.run(main())



With this script, the ffmpeg command is correctly launched and terminated after the for loop.


Could you help ?


-
"undefined reference to av···@···"ffmpeg error,when i cross compile opencv4.5.3 which include ffmpeg lib
11 mai 2024, par caiping Pengeveryone,It is sorry to bother you,but i need some help.
I'm working on an embedded deployment project,doing object detection work to real-time video stream. So I have to port my c++ inference prog to RKNN1808 platform. I compile this program with CMake tool,but I cant finish my work because opencv lib cant be compiled rightly.
To FFmpeg,my configure commend is following :


./configure --enable-cross-compile --cross-prefix=/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- --target-os=linux --arch=aarch64 --prefix=/usr/local/ffmpeg --enable-shared



then I am gonna show you the ffmpeg version :


libavutil 56. 70.100
libavcodec 58.134.100
libavformat 58. 76.100
libavdevice 58. 13.100
libavfilter 7.110.100
libswscale 5. 9.100
libswresample 3. 9.100
libpostproc 55. 9.100



next ,I use following commend to build cmake project :


cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_C_COMPILER=/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -D CMAKE_CXX_COMPILER=/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -D BUILD_SHARED_LIBS=ON -D CMAKE_CXX_FLAGS=-fPIC -D CMAKE_C_FLAGS=-fPIC -D CMAKE_EXE_LINKER_FLAGS=-lpthread -ldl -D ENABLE_PIC=ON -D WITH_1394=OFF -D WITH_ARAVIS=OFF -D WITH_ARITH_DEC=ON -D WITH_ARITH_ENC=ON -D WITH_CLP=OFF -D WITH_CUBLAS=OFF -D WITH_CUDA=OFF -D WITH_CUFFT=OFF -D WITH_FFMPEG=ON -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF -D WITH_HALIDE=OFF -D WITH_HPX=OFF -D WITH_IMGCODEC_HDR=ON -D WITH_IMGCODEC_PXM=ON -D WITH_IMGCODEC_SUNRASTER=ON -D WITH_INF_ENGINE=OFF -D WITH_IPP=OFF -D WITH_ITT=OFF -D WITH_JASPER=ON -D WITH_JPEG=ON -D WITH_LAPACK=ON -D WITH_LIBREALSENSE=OFF -D WITH_NVCUVID=OFF -D WITH_OPENCL=OFF -D WITH_OPENCLAMDBLAS=OFF -D WITH_OPENCLAMDFFT=OFF -D WITH_OPENCL_SVM=OFF -D WITH_OPENEXR=OFF -D WITH_OPENGL=OFF -D WITH_OPENMP=OFF -D WITH_OPENNNI=OFF -D WITH_OPENNNI2=OFF -D WITH_OPENVX=OFF -D WITH_PNG=OFF -D WITH_PROTOBUF=OFF -D WITH_PTHREADS_PF=ON -D WITH_PVAPI=OFF -D WITH_QT=OFF -D WITH_QUIRC=OFF -D WITH_TBB=OFF -D WITH_TIFF=ON -D WITH_VULKAN=OFF -D WITH_WEBP=ON -D WITH_XIMEA=OFF -D CMAKE_INSTALL_PREFIX=../CrossCompileResult -D WITH_GTK=OFF -D BUILD_opencv_dnn=OFF ..



following is the outpt about FFmpeg :


-- Video I/O:
-- FFMPEG: YES
-- avcodec: YES (58.134.100)
-- avformat: YES (58.76.100)
-- avutil: YES (56.70.100)
-- swscale: YES (5.9.100)
-- avresample: NO
-- GStreamer: NO
-- v4l/v4l2: YES (linux/videodev2.h)




After building the cmake project,I compiled this project with comment 【make -j16】.After not so long time,I got the Error :


[ 49%] Linking CXX executable ../../bin/opencv_annotation
[ 49%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/ts_tags.cpp.o
[ 49%] Built target opencv_annotation
[ 49%] Linking CXX executable ../../bin/opencv_visualisation
/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libavcodec.so.58, needed by ../../lib/libopencv_videoio.so.4.5.3, not found (try using -rpath or -rpath-link)
/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libavformat.so.58, needed by ../../lib/libopencv_videoio.so.4.5.3, not found (try using -rpath or -rpath-link)
/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libavutil.so.56, needed by ../../lib/libopencv_videoio.so.4.5.3, not found (try using -rpath or -rpath-link)
/home/midsummer/Tool/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/../../../../aarch64-linux-gnu/bin/ld: warning: libswscale.so.5, needed by ../../lib/libopencv_videoio.so.4.5.3, not found (try using -rpath or -rpath-link)
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_init_packet@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_get_riff_video_tags@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_send_packet@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_receive_packet@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_get_mov_video_tags@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_find_decoder@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_find_decoder_by_name@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_frame_alloc@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_get_name@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_transfer_data@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_malloc@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avio_open@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_alloc_context@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_sub_q@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_network_init@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_packet_free@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_flush_buffers@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_find_encoder@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `sws_getContext@LIBSWSCALE_5'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_receive_frame@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_write_frame@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_close_input@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_seek_frame@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `sws_freeContext@LIBSWSCALE_5'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_dict_set@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_descriptor_get_by_name@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `sws_scale@LIBSWSCALE_5'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_packet_unref@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_dict_parse_string@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_frame_get_buffer@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_freep@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_find_stream_info@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_read_frame@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_free_context@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_default_get_format@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_ctx_init@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_register_all@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_free@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_get_buffer@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_guess_sample_aspect_ratio@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_new_stream@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_constraints_free@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwdevice_ctx_create_derived@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_frame_unref@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_buffer_unref@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_write_trailer@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_packet_rescale_ts@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_get_by_name@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_send_frame@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_get_hw_config@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_buffer_ref@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_dict_get@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_free@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_codec_is_decoder@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_open_input@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_lockmgr_register@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_packet_alloc@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_ctx_create_derived@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_send_packet@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_alloc@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_log_set_level@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_image_get_buffer_size@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_open2@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_codec_is_encoder@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_guess_format@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_image_fill_arrays@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_receive_packet@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `sws_getCachedContext@LIBSWSCALE_5'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_codec_get_tag@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwdevice_get_hwframe_constraints@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwdevice_ctx_create@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_codec_iterate@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_log_set_callback@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_opt_set@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_codec_get_id@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avformat_write_header@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_parameters_copy@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_pix_fmt_to_codec_tag@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwframe_ctx_alloc@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_mallocz@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_find_input_format@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_dict_free@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_get_hw_frames_parameters@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwdevice_get_type_name@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avio_close@LIBAVFORMAT_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_frame_free@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_bsf_init@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_close@LIBAVCODEC_58'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `av_hwdevice_find_type_by_name@LIBAVUTIL_56'
../../lib/libopencv_videoio.so.4.5.3: undefined reference to `avcodec_get_context_defaults3@LIBAVCODEC_58'
collect2: error: ld returned 1 exit status
make[2]: *** [apps/visualisation/CMakeFiles/opencv_visualisation.dir/build.make:89: bin/opencv_visualisation] Error 1
make[1]: *** [CMakeFiles/Makefile2:3357: apps/visualisation/CMakeFiles/opencv_visualisation.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 49%] Linking CXX shared library ../../lib/libopencv_calib3d.so
[ 49%] Built target opencv_calib3d
[ 50%] Linking CXX static library ../../lib/libopencv_ts.a
[ 50%] Built target opencv_ts
make: *** [Makefile:163: all] Error 2




I dont know what's wrong with it,It has confused me for a few days,I real hope someone can help me solve the prob.
I promise the the ffmpeg version match the version of opencv strictly,promising the PKG_CONFIG_PATH is right.


I have tried many method like changing opencv version or ffmpeg version,recompiling the ffmpeg,changing PKG_CONFIG_PATH,coping ffmpeg pc file from /usr/local/ffmpeg/lib/pkgconfig to /usr/local/lib/pkgconfig.
I hope somebody can give some idea about how to solve this problem.